Pair trades order #247
Replies: 4 comments
-
|
https://tastyworks-api.readthedocs.io/en/latest/orders.html Check out the documentation there. OCO doesn't seem to work for Debit orders though. |
Beta Was this translation helpful? Give feedback.
-
|
Try placing a pairs trade on the platform, then fetching your complex order history and copy the structure you see there. |
Beta Was this translation helpful? Give feedback.
-
|
Pair trades use a single from decimal import Decimal
from tastytrade import Session, Account
from tastytrade.instruments import Equity
from tastytrade.order import NewOrder, OrderAction, OrderTimeInForce, OrderType
session = Session('client_secret', 'refresh_token')
account = Account.get(session)[0]
# Get both symbols
symbol1 = Equity.get(session, 'SPY')
symbol2 = Equity.get(session, 'QQQ')
# Build legs for the pair
leg1 = symbol1.build_leg(Decimal('100'), OrderAction.BUY_TO_OPEN)
leg2 = symbol2.build_leg(Decimal('100'), OrderAction.SELL_TO_OPEN)
# Create pair order
order = NewOrder(
time_in_force=OrderTimeInForce.DAY,
order_type=OrderType.LIMIT,
legs=[leg1, leg2], # Both legs execute together
price=Decimal('-50.00') # Net debit (negative) or credit (positive)
)
# Place order
response = account.place_order(session, order, dry_run=True) |
Beta Was this translation helpful? Give feedback.
-
|
I get the following error: |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
How does one create a pair trade? When using the platform, it is defined as a Complex order. However, when using the API, I can't find the correct way to formulate it. Can someone help me?
Thanks in advance
Beta Was this translation helpful? Give feedback.
All reactions