Hello, I am an extremely new programmer, and have been trying to figure out the Options Syntax for placing an options order using Collective. I have tried time and time again to get the order syntax for options to play out correctly. I keep getting errors like this below.
Questions I have are:
-
Does collective2 use the OPRA options chain for their offering?
-
When calling the options symbol to place an order in Collective, do you use the full contractID or just the company symbol.
payload = {
“Order”: {
“StrategyId”: int(strategy_id),
“OrderType”: 2, # Limit order
“Side”: 1, # Buy to Open (BTO)
“OrderQuantity”: 1.0, # Quantity set to 1 for simplicity
“Limit”: limit_price,
“TIF”: 1, # Good Till Cancelled (GTC)
“ExchangeSymbol”: {
“Symbol”: option_symbol,
“Currency”: “USD”,
“SecurityExchange”: “OPRA”,
“SecurityType”: “OPT”,
“MaturityMonthYear”: expiration_date.replace(‘-’, ‘’)[:6], # Format as YYYYMM
“PutOrCall”: option_type, # 0 for Put, 1 for Call
“StrikePrice”: strike_price # Include the StrikePrice here
}
}
}headers = {
“Content-Type”: “application/json”,
“Authorization”: f"Bearer {API_TOKEN}"
}
Error Message:
{
“Order”: {
“StrategyId”: Removed,
“OrderType”: 2,
“Side”: 1,
“OrderQuantity”: 1.0,
“Limit”: 0.7875,
“TIF”: 1,
“ExchangeSymbol”: {
“Symbol”: “GOOGL240705P00182500”,
“Currency”: “USD”,
“SecurityExchange”: “OPRA”,
“SecurityType”: “OPT”,
“MaturityMonthYear”: “202407”,
“PutOrCall”: 0,
“StrikePrice”: 182.5
}
}
}
ERROR:root:Error placing order: {“ResponseStatus”:{“ErrorCode”:“400”,“Message”:“BadRequest”,“Errors”:[{“ErrorCode”:“1121”,“FieldName”:“Symbol”,“Message”:“Invalid symbol”}]}}
Any help here is appreciated. Thank you in advance!