From bae7f7bd66db69d957ca4bd062bdf99ea8615184 Mon Sep 17 00:00:00 2001 From: moshferatu Date: Fri, 22 Sep 2023 08:09:03 -0700 Subject: [PATCH] Add order submission example --- order_submission_example.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 order_submission_example.py diff --git a/order_submission_example.py b/order_submission_example.py new file mode 100644 index 0000000..8dd1968 --- /dev/null +++ b/order_submission_example.py @@ -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) \ No newline at end of file