tastytrade/order_submission_example.py

23 lines
851 B
Python
Raw Normal View History

2023-09-22 15:09:03 +00:00
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)