Hi,
Referring to the blog on options trading.
1) Obtaining an option symbol
string osym = OptionSynthetic.GetOptionsSymbol
2) To match the requirements of the PlaceTrade(_obars call
_obars = OptionSynthetic.GetHistory(bars, osym
I am assuming that in _obars
(l) _obars(_obars.Count - 1) corresponds to the current actual option quote for the symbol.
(ii) _obars(_obars.Count - 2) corresponds to the previous actual option quote if GetHistory was also called in the previous idx?
In my WL6 scheme I use signals from the underlying to trade options.
Thus, all I need is the latest option quote and a few before to double check.
I collected these over time and created a small most recent data set.
I used code I wrote to get this from TD Ameritrade.
I have two questions:
a) Are the steps mentioned in (1) and (2) correct to obtain an actual option quote?
b) Is there a simpler option quote request?
Please assume IBKR as an example.
Thanks!
Referring to the blog on options trading.
1) Obtaining an option symbol
string osym = OptionSynthetic.GetOptionsSymbol
2) To match the requirements of the PlaceTrade(_obars call
_obars = OptionSynthetic.GetHistory(bars, osym
I am assuming that in _obars
(l) _obars(_obars.Count - 1) corresponds to the current actual option quote for the symbol.
(ii) _obars(_obars.Count - 2) corresponds to the previous actual option quote if GetHistory was also called in the previous idx?
In my WL6 scheme I use signals from the underlying to trade options.
Thus, all I need is the latest option quote and a few before to double check.
I collected these over time and created a small most recent data set.
I used code I wrote to get this from TD Ameritrade.
I have two questions:
a) Are the steps mentioned in (1) and (2) correct to obtain an actual option quote?
b) Is there a simpler option quote request?
Please assume IBKR as an example.
Thanks!
Rename
Generally, a BarHistory for option contracts contains trade data only. If the contract is illiquid (most are), then that data isn't a good reference for the current price.
The exception is if you use IB with the "MidPoint" (not Trades) option - see WL's IB Config Settings. That gives you Option BarHistories of the Bid/Ask Midpoint historically. Consequently, the closing value of that "MidPoint" BarHistory is the current midpoint quote for the contract.
You can't do much better than that, but for all providers, you can request the "greeks" in realtime - we wrap that result in the OptionGreek class, which contains fields for Bid, Ask, and Midpoint, i.e., the current quote.
The exception is if you use IB with the "MidPoint" (not Trades) option - see WL's IB Config Settings. That gives you Option BarHistories of the Bid/Ask Midpoint historically. Consequently, the closing value of that "MidPoint" BarHistory is the current midpoint quote for the contract.
You can't do much better than that, but for all providers, you can request the "greeks" in realtime - we wrap that result in the OptionGreek class, which contains fields for Bid, Ask, and Midpoint, i.e., the current quote.
Thanks!
I use the spread in buy evaluation. If the spread is too large with respect to that day's volatility (I estimate this from one minute SPX OHLC history), I do not enter the option buy trade for example. So, in this scheme I must choose greeks. I gather that if you ask for greeks then the quote takes a couple more seconds.
I use the spread in buy evaluation. If the spread is too large with respect to that day's volatility (I estimate this from one minute SPX OHLC history), I do not enter the option buy trade for example. So, in this scheme I must choose greeks. I gather that if you ask for greeks then the quote takes a couple more seconds.
That's right. Requesting the greeks for IB requires it to start a streaming subscription, so that takes extra time.
Requesting greeks from Schwab is probably much faster and would be a better experience.
Just understand, greeks (including bid/ask) are realtime only - there's no backtesting for that.
Requesting greeks from Schwab is probably much faster and would be a better experience.
Just understand, greeks (including bid/ask) are realtime only - there's no backtesting for that.
I was a TDA customer. But somehow in the transition to Schwab I have not been able to get a working developer.schwab.com account going. Perhaps they thought my volumes were small. They have no phone access, only email. In two days of interacting with IBKR I found them to be responsive. Too bad they lump bid/ask info with greeks.
What is your experience with the bid/ask delay at IBKR? Is it a couple of seconds or more?
Any suggestion you may have regarding Schwab developer access is appreciated.
Thanks!
What is your experience with the bid/ask delay at IBKR? Is it a couple of seconds or more?
Any suggestion you may have regarding Schwab developer access is appreciated.
Thanks!
Re: Schwab
You have to wait up to a week for the approval since they only do the processing for that once a week. I can't help more than that.
I'm not trading realtime options, but I just ran this example -
The result for several runs:
There's some housekeeping to do for the first run (so that's the big first delay), and then price needs to tick to change the data to get a response. If the stock is illiquid, the delay will be longer.
You have to wait up to a week for the approval since they only do the processing for that once a week. I can't help more than that.
I'm not trading realtime options, but I just ran this example -
CODE:
using WealthLab.Backtest; using System; using WealthLab.Core; using WealthLab.Data; using WealthLab.Indicators; using System.Collections.Generic; using WealthLab.InteractiveBrokers; using System.Diagnostics; namespace WealthScript41 { public class OCSnapshotIBDemo : UserStrategyBase { public override void Initialize(BarHistory bars) { Stopwatch sw = new(); sw.Start(); string atm = IBHistorical.Instance.GetOptionsSymbol(bars, OptionType.Call, bars.LastValue, bars.EndDate, 1); double C = OptionsHelper.SymbolStrike(atm); double s1 = C; double s2 = C; List<OptionGreek> chain = IBHistorical.Instance.GetOptionChainSnapshot(bars.Symbol, bars.NextOptionExpiryDate(bars.Count - 1), OptionType.Put, s1, s2); sw.Stop(); WriteToDebugLog($"GetOptionChainSnapshot returned in {sw.Elapsed.TotalSeconds:N2} seconds"); if (chain?.Count == 0) { WriteToDebugLog($"No data"); return; } else { foreach (var og in chain) WriteToDebugLog($"{og.UpdatedAt:HH:mm:ss.fff} {og.Symbol,-18}\t{og.OptionPrice:N2}; {og.Bid:N2}x{og.Ask:N2}; Δ:{og.Delta:N4}, Γ:{og.Gamma:N4}"); } } public override void Execute(BarHistory bars, int idx) { } } }
The result for several runs:
CODE:
First time: GetOptionChainSnapshot returned in 4.98 seconds 11:07:11.017 C250516P70 1.32; 1.32x1.34; Δ:-0.4602, Γ:0.1099 Thereafter: GetOptionChainSnapshot returned in 0.51 seconds 11:08:13.686 C250516P70 1.32; 0.00x0.00; Δ:-0.4602, Γ:0.1099 >> bid/ask was 0x0 this time, hmmm GetOptionChainSnapshot returned in 0.54 seconds 11:08:46.786 C250516P70 1.36; 1.36x1.38; Δ:-0.4672, Γ:0.1095 GetOptionChainSnapshot returned in 0.50 seconds 11:09:19.629 C250516P70 1.36; 1.36x1.38; Δ:-0.4672, Γ:0.1095
There's some housekeeping to do for the first run (so that's the big first delay), and then price needs to tick to change the data to get a response. If the stock is illiquid, the delay will be longer.
Your Response
Post
Edit Post
Login is required