From b06a407109f448d0e441d3995795f9517a8df985 Mon Sep 17 00:00:00 2001 From: moshferatu Date: Sat, 6 Jul 2024 05:13:39 -0700 Subject: [PATCH] Add example of retrieving / streaming historical data --- historical_data_example.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 historical_data_example.py diff --git a/historical_data_example.py b/historical_data_example.py new file mode 100644 index 0000000..0189dc0 --- /dev/null +++ b/historical_data_example.py @@ -0,0 +1,18 @@ +from datetime import datetime, timedelta +from dotenv import load_dotenv +from os import getenv +from tastytrade import Tastytrade + +load_dotenv() +account = getenv("TASTYTRADE_ACCOUNT") +username = getenv("TASTYTRADE_USERNAME") +password = getenv("TASTYTRADE_PASSWORD") + +tastytrade = Tastytrade(username, password) +tastytrade.login() + +tastytrade.stream_historical_data( + symbol = 'SPX', + period = 1, type = 'd', + from_time = datetime.now() - timedelta(days = 365) +) \ No newline at end of file