pyetrade
pyetrade copied to clipboard
Cannot grab optionchain data with ETrade API in Python
I am using the Sandbox API keys (consumer_key and consumer_secret) Token request, token renewal, account management, stock price quote, etc, all worked.
But when I request optionchain data from https://apisb.etrade.com/v1/market/optionchains.json?symbol=SPY&expiryDay=12&expiryMonth=09&expiryYear=2023 or https://apisb.etrade.com/v1/market/optionchains.json?symbol="SPY"&expiryDay=12&expiryMonth=09&expiryYear=2023
I always get this response shown below, which is the option quote for Apple Inc. for 2013 March 22nd, and is definitely wrong. I put my forked code here (main.py). Anyone knows how to make this work?
{ "OptionChainResponse": { "OptionPair": [ { "Call": { "OptionGreeks": { "currentValue": false, "delta": 0.0848, "gamma": 0.0316, "iv": 0.1407, "rho": 0.0095, "theta": -0.018, "vega": 0.0751 }, "adjustedFlag": false, "ask": 0.01, "askSize": 25, "bid": 0.02, "bidSize": 0, "displaySymbol": "AAPL Mar 22 '13 $485 Call", "inTheMoney": "n", "lastPrice": 0.01, "netChange": -0.01, "openInterest": 2782, "optionCategory": "STANDARD", "optionRootSymbol": "AAPL", "optionType": "CALL", "osiKey": "AAPL--130322C00485000", "quoteDetail": "https://api.sit.etrade.com/v1/market/quote/AAPL:2013:3:22:CALL:485.000000", "strikePrice": 485.0, "symbol": "AAPL", "timeStamp": 1363975980, "volume": 178 }, "Put": { "OptionGreeks": { "currentValue": false, "delta": 0.0848, "gamma": 0.0316, "iv": 0.1407, "rho": 0.0095, "theta": -0.018, "vega": 0.0751 }, "adjustedFlag": false, "ask": 23.9, "askSize": 2, "bid": 23.6, "bidSize": 4, "displaySymbol": "AAPL Mar 22 '13 $485 Put", "inTheMoney": "y", "lastPrice": 23.7, "netChange": -8.95, "openInterest": 273, "optionCategory": "STANDARD", "optionRootSymbol": "AAPL", "optionType": "PUT", "osiKey": "AAPL--130322P00485000", "quoteDetail": "https://api.sit.etrade.com/v1/market/quote/AAPL:2013:3:22:PUT:485.000000", "strikePrice": 485.0, "symbol": "AAPL", "timeStamp": 1363974660, "volume": 81 } } ], "SelectedED": { "day": 22, "month": 3, "year": 2013 } } }
I'm pretty sure that sandboxed data is out of date. If you are getting something back, that means your code is correct. You just need regular keys.Tom“Know the truth and it shall set you free” (John 8:32)On Sep 9, 2023, at 4:39 PM, SeanLyn @.***> wrote: I am using the Sandbox API keys (consumer_key and consumer_secret) Token request, token renewal, account management, stock price quote, etc, all worked. But when I request optionchain data from https://apisb.etrade.com/v1/market/optionchains.json?symbol=SPY&expiryDay=12&expiryMonth=09&expiryYear=2023 or https://apisb.etrade.com/v1/market/optionchains.json?symbol="SPY"&expiryDay=12&expiryMonth=09&expiryYear=2023 I always get this response shown below, which is the option quote for Apple Inc. for 2013 March 22nd, and is definitely wrong. I put my forked code here (main.py). Anyone knows how to make this work? { "OptionChainResponse": { "OptionPair": [ { "Call": { "OptionGreeks": { "currentValue": false, "delta": 0.0848, "gamma": 0.0316, "iv": 0.1407, "rho": 0.0095, "theta": -0.018, "vega": 0.0751 }, "adjustedFlag": false, "ask": 0.01, "askSize": 25, "bid": 0.02, "bidSize": 0, "displaySymbol": "AAPL Mar 22 '13 $485 Call", "inTheMoney": "n", "lastPrice": 0.01, "netChange": -0.01, "openInterest": 2782, "optionCategory": "STANDARD", "optionRootSymbol": "AAPL", "optionType": "CALL", "osiKey": "AAPL--130322C00485000", "quoteDetail": "https://api.sit.etrade.com/v1/market/quote/AAPL:2013:3:22:CALL:485.000000", "strikePrice": 485.0, "symbol": "AAPL", "timeStamp": 1363975980, "volume": 178 }, "Put": { "OptionGreeks": { "currentValue": false, "delta": 0.0848, "gamma": 0.0316, "iv": 0.1407, "rho": 0.0095, "theta": -0.018, "vega": 0.0751 }, "adjustedFlag": false, "ask": 23.9, "askSize": 2, "bid": 23.6, "bidSize": 4, "displaySymbol": "AAPL Mar 22 '13 $485 Put", "inTheMoney": "y", "lastPrice": 23.7, "netChange": -8.95, "openInterest": 273, "optionCategory": "STANDARD", "optionRootSymbol": "AAPL", "optionType": "PUT", "osiKey": "AAPL--130322P00485000", "quoteDetail": "https://api.sit.etrade.com/v1/market/quote/AAPL:2013:3:22:PUT:485.000000", "strikePrice": 485.0, "symbol": "AAPL", "timeStamp": 1363974660, "volume": 81 } } ], "SelectedED": { "day": 22, "month": 3, "year": 2013 } } }
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you are subscribed to this thread.Message ID: @.***>
Thanks a lot for the reply. Let me try again once I finish the application to the regular key.
I'm pretty sure that sandboxed data is out of date. If you are getting something back, that means your code is correct. You just need regular keys.Tom“Know the truth and it shall set you free” (John 8:32)On Sep 9, 2023, at 4:39 PM,