Add order submission example

This commit is contained in:
moshferatu 2023-09-22 08:09:03 -07:00
parent 85da22cf2b
commit bae7f7bd66

View File

@ -0,0 +1,23 @@
from dotenv import load_dotenv
from os import getenv
from tastytrade.option_type import CALL, PUT
from tastytrade.order import create_credit_spread
from tastytrade.symbology import zero_dte_spx_contract as contract
from tastytrade import Tastytrade
load_dotenv()
account = getenv("TASTYTRADE_ACCOUNT")
username = getenv("TASTYTRADE_USERNAME")
password = getenv("TASTYTRADE_PASSWORD")
tastytrade_api = Tastytrade(username, password)
tastytrade_api.login()
put_credit_spread = create_credit_spread(contract(PUT, 4455), contract(PUT, 4435), 0.35, 1)
call_credit_spread = create_credit_spread(contract(CALL, 4490), contract(CALL, 4505), 0.35, 1)
put_spread_result = tastytrade_api.submit_order(account, put_credit_spread)
call_spread_result = tastytrade_api.submit_order(account, call_credit_spread)
print(put_spread_result)
print(call_spread_result)