AmiBroker for Options backtesting?

UberMachine

Well-Known Member
#11
How did you manage brokerages and slippages? Custom functions for them too?
You have couple of options
  1. You could model the stock prices and then arrive at the options prices (quite mathematical)
  2. You could treat option data similar to stock prices and then run a backtest on them (by creating a unique symbol for each stock/toption type/strike price)
As far I know, there are no full fledged strategic frameworks that work with options (quantlib is great for pricing). Quantconnect comes close to your requirement but it has a bigger learning curve.

If you prefer the second method, you can use backtrader or try fastbt (fastbt is my library).
Zipline is great but requires strict sanitized data. Quantconnect
I prefer python over amibroker (since I don't know amibroker and I run on linux)
 

NJ23

Well-Known Member
#13
What exact difficulties are you expecting, if you choose to go with Amibroker itself ? Like option symbol names and data management itself is quite tedious work, before any real analysis or backtest could be done. What other issues are you anticipating ?

Are you planning to do it on 1 min time frame data, or use tick data as well ?
Yes, I agree. The data management is tedious. Plus coding has to be absolutely right, when it comes to symbol selection (not a big deal, but something that can go wrong (incorrect spread creation is to be watched out for), hence extremely careful backtesting). Performance is another issue, if it's to be deployed live. AmiBroker has its limitations. The CPU consumption skyrockets randomly for no apparent reason.

Tick data itself. No point in using 1 minute data. As useless as newspaper. :|
 

NJ23

Well-Known Member
#14
You have couple of options
  1. You could model the stock prices and then arrive at the options prices (quite mathematical)
  2. You could treat option data similar to stock prices and then run a backtest on them (by creating a unique symbol for each stock/toption type/strike price)
As far I know, there are no full fledged strategic frameworks that work with options (quantlib is great for pricing). Quantconnect comes close to your requirement but it has a bigger learning curve.

If you prefer the second method, you can use backtrader or try fastbt (fastbt is my library).
Zipline is great but requires strict sanitized data. Quantconnect
I prefer python over amibroker (since I don't know amibroker and I run on linux)
Thought of #1 but again, lots of work for one person.
#2: treat Options as Futures symbols and backtest do you mean?

Backtrader again doesn't support options, I believe.

Thanks for the QC link. I'll check it out.
 

NJ23

Well-Known Member
#15
Yes, AmiBroker can be used. In fact I've created Options auto trader and backtester in AmiBroker (for someone else for US market. So don't ask me about Indian one).
Do you mind sharing the repository/code? Just to get an idea of how to go about it? Even a small sample of code would do. Thanks.
 

UberMachine

Well-Known Member
#16
Thought of #1 but again, lots of work for one person.
#2: treat Options as Futures symbols and backtest do you mean?

Backtrader again doesn't support options, I believe.

Thanks for the QC link. I'll check it out.
Instead of treating them as options, treat them as stock symbols. And have a separate csv file for each one of them.
So NIFTYNOV201810000CE, NIFTYNOV201810000PE and so on to iterate through the files. You can always filter the options out either in strategy or when loading data
 

trash

Well-Known Member
#17
Do you mind sharing the repository/code? Just to get an idea of how to go about it? Even a small sample of code would do. Thanks.
It is not free code.

But that being said. There is no need to iterate through CSV file (or using MySQL). That would be ridiculous.
AmiBroker database can handle any symbol.
 
#18
It is not free code.

But that being said. There is no need to iterate through CSV file (or using MySQL). That would be ridiculous.
AmiBroker database can handle any symbol.
Any suggestion on how AB can loop through different Option contract's string symbols for each bar in order to capture cumulative Call and Put OI for PCR calculation?
 

travi

Well-Known Member
#19
Check out the foreign functions to access other symbols' values.

Knowing the current spot price, its easy to construct the CE/PE for a certain number of strikes on both sides.

I don't think you need to iterate through each bar.
The sum total of Latest OI at each strike should suffice for ce and pe resp.

You can refer past periods and plot hourly changes etc but i doubt for each bar it won't make sense. From my experience, OI doesn't fluctuate as much as price does.
Volume spikes and WRB are far better indicators.

Or you can just store each pcr going forward and just compare periodically.

Sent from my SM-T810 using Tapatalk
 
#20
Check out the foreign functions to access other symbols' values.

Knowing the current spot price, its easy to construct the CE/PE for a certain number of strikes on both sides.

I don't think you need to iterate through each bar.
The sum total of Latest OI at each strike should suffice for ce and pe resp.

You can refer past periods and plot hourly changes etc but i doubt for each bar it won't make sense. From my experience, OI doesn't fluctuate as much as price does.
Volume spikes and WRB are far better indicators.

Or you can just store each pcr going forward and just compare periodically.

Sent from my SM-T810 using Tapatalk
I am working on daily chart and interested to calculate and visualize Current w.r.t. Historical PCR.
The work around that I have found is to calculate PCR from NSE Bhavcopy CSVs using R and then import that as a Symbol into AB using ASCII import. But since @trash is claiming:
But that being said. There is no need to iterate through CSV file (or using MySQL). That would be ridiculous.
AmiBroker database can handle any symbol.
I was simply wondering how he did that solely using AFL!
 

Similar threads

Broker Special Offers

Intraday Higher Leverage

Save up to 90% in brokerage and get higher leverage for intraday trades.

Name:Phone:
Email:City:
State:
Are you a day trader?