Add example of retrieving / streaming historical data

This commit is contained in:
moshferatu 2024-07-06 05:13:39 -07:00
parent 42e4641cf3
commit b06a407109

View File

@ -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)
)