[R-SIG-Finance] Using quantstrat with options
Sal Abbasi
abbasi.sal at gmail.com
Sun Apr 8 21:13:21 CEST 2018
I have an options strategy that I’m trying to backtest. It involves buying or selling options that are underpriced or overpriced according to my model and delta hedging them. In some cases I would end up getting rid of the option before expiry and in other cases I would hold the option till expiry. In the cases where I hold till expiry I had to follow the approach below to make this work within quantstrat. I was wondering if somebody had come up with a less “hacky”, more elegant solution.
Best,
Sal
> On Apr 7, 2018, at 2:26 PM, Frank <frankm60606 at gmail.com> wrote:
>
> Traders use bar charts to uncover actionable patterns: double tops, rounded bottoms, selling against a trendline, outside day lower close and lots of others. This is because the price discovery of stocks, futures, FX and bonds follow certain patterns that technical traders use to trade. I have not seen any research that says this can be translated to options.
>
> Implied volatility of option(s) is the closest to price discovery for stocks, bonds ... You can buy historical options to calculate your own volatility or you can buy volatility data from the CBOE. Option traders use the Black-Scholes, Fisher Black or their own option model to analyze options. Which options, the weighting method all impact the implied volatility.
>
> What would be the ultimate goal of your analysis?
>
> Frank
> Chicago, IL
> -----Original Message-----
> From: R-SIG-Finance <r-sig-finance-bounces at r-project.org> On Behalf Of Sal Abbasi
> Sent: Wednesday, April 04, 2018 10:18 PM
> To: Brian G. Peterson <brian at braverock.com>
> Cc: r-sig-finance at r-project.org
> Subject: Re: [R-SIG-Finance] Using quantstrat with options
>
> What is a good way to model holding an option till expiry?
>
> The only way I can think about is this:
>
> 1. For each option, add or update the final bar’s price to option expiry value (0 or intrinsic value). For many options, there is no market data at expiry date / time since the option is too deep in the money or out of the money, so I would have to add the final bar if it does not exist.
> 2. Add or update the penultimate bar so the order can be generated at the penultimate bar and executed at the final bar.
> 3. Add an indicator for time to maturity 3. Add a signal for ttm == 1 minute (since my bars are 1 minute long) 4. Added a rule to exit when ttm == 1 minute (the order is generated at ttm == 1 minute and gets executed when ttm == 0)
>
> Is there a cleaner way to accomplish this?
>
> Best,
>
> Sal
>
>> On Mar 29, 2018, at 3:06 PM, Sal Abbasi <abbasi.sal at gmail.com> wrote:
>>
>> Thank you. Just loaded up a few symbols and it seems to be working great so far.
>>
>>> On Mar 29, 2018, at 12:32 PM, Brian G. Peterson <brian at braverock.com> wrote:
>>>
>>> There should conceptually be no difficulty with lots of symbols and
>>> 1- minute data. We pretty routinely use quantstrat on tick data or
>>> 1- second data.
>>>
>>> We pretty regularly segment our backtests with a loop around the
>>> calls to applyStrategy that load data monthly or quarterly, add
>>> symbols to portfolios or create new portfolios for each segment, and
>>> then run that subset of the overall backtest series.
>>>
>>> I do not trade options, so I can't help there, but you should be able
>>> to manage the meta-data for the contracts by adding fields to your
>>> instrument definitions. If things like tick sizes and multipliers
>>> are set correctly for the root symbol, then the accounting should work.
>>>
>>> Regards,
>>>
>>> Brian
>>>
>>> --
>>> Brian G. Peterson
>>> http://braverock.com/brian/
>>> Ph: 773-459-4973
>>> IM: bgpbraverock
>>>
>>>> On Thu, 2018-03-29 at 12:17 -0500, Sal Abbasi wrote:
>>>> Has anyone used quantstrat with options? I’ve found lots of
>>>> examples where people are using it with equities and one where
>>>> someone is using it with futures but have not been able to find any
>>>> examples of people using it with options yet. I’m trying to
>>>> backtest some index options strategies, and wanted to ask about a
>>>> pragmatic way of using quantstrat when there are so many symbols involved (one per strike /
>>>> maturity). Also there is a lot of market data involved since I’m
>>>> using 1 minute bars, so I was wondering whether I should create a
>>>> subset of my market data for the minimum required before feeding it
>>>> to quantstrat or whether people have done something where quantstrat
>>>> can look up the data it needs from indexed files on disk as it runs
>>>> and does not need to hold it in memory.
>>>>
>>>> Best,
>>>>
>>>> Sal
>>>> _______________________________________________
>>>> R-SIG-Finance at r-project.org mailing list
>>>> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>>>> -- Subscriber-posting only. If you want to post, subscribe first.
>>>> -- Also note that this is not the r-help list where general R
>>>> questions should go.
>>>>
>>
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.
>
More information about the R-SIG-Finance
mailing list