Gamestudio Links
Zorro Links
Newest Posts
zorro 64bit command line support
by 7th_zorro. 04/20/24 10:06
StartWeek not working as it should
by jcl. 04/20/24 08:38
Data from CSV not parsed correctly
by jcl. 04/20/24 08:32
Zorro FIX plugin - Experimental
by jcl. 04/20/24 08:30
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
3 registered members (7th_zorro, Aku_Aku, 1 invisible), 579 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 3 1 2 3
Loading the options chain with additional data #468090
09/18/17 08:49
09/18/17 08:49
Joined: Sep 2017
Posts: 6
A
asdvao Offline OP
Newbie
asdvao  Offline OP
Newbie
A

Joined: Sep 2017
Posts: 6
Hi, new Zorro user here. The software seems quite promising so far, but I'm struggling with how to get the data I want to work with in.

I have a few ideas for options trading strategies that I would like to try out. The historical data that I have already has some of the greeks and other parameters calculated by the source, plus, I've added some of my own calculations. This in total amounts to over a dozen of potential data columns (not necessarily all of which will be useful).

I realize that the Zorro's T8 (CONTRACT) format supports 2 extra fields except for the price data. Would it be possible to load the data consisting of "richer" records?
Could the system be extended with a custom data type used instead of the CONTRACT, so that the classical Zorro backtesting functionality could be used - but with more data available for the decisions (and machine learning)? If so, what would need to be extended?

Re: Loading the options chain with additional data [Re: asdvao] #468094
09/18/17 11:07
09/18/17 11:07
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
The CONTRACT struct has a fixed structure. For more data, add datasets and store the data in them. But I would not store greeks. Better calculate the greeks directly.

Re: Loading the options chain with additional data [Re: jcl] #468127
09/19/17 10:33
09/19/17 10:33
Joined: Sep 2017
Posts: 6
A
asdvao Offline OP
Newbie
asdvao  Offline OP
Newbie
A

Joined: Sep 2017
Posts: 6
If using datasets, are you suggesting simply loading the dataset, and (for the backtest) looping through it, and then retrieving individual values via dataVar/dataInt functions?

As for the greeks, my thought was that it may be beneficial to store greeks to speed up the backtest. Furthermore, I already have a dataset containing those, as well as some other pieces of information obtained from the broker, so I was considering testing a few things using those. Can you explain your thoughts why you would prefer to calculate the greeks on the fly?

Re: Loading the options chain with additional data [Re: asdvao] #468268
09/27/17 15:53
09/27/17 15:53
Joined: Sep 2017
Posts: 6
A
asdvao Offline OP
Newbie
asdvao  Offline OP
Newbie
A

Joined: Sep 2017
Posts: 6
What would be the appropriate way to backtest while using additional data contained in a data set?

Is it somehow possible to run the backtest directly off the dataset? That is, is it possible to use the contractUpdate on the dataset containing more data columns? In that case, is it correct to presume that the first few fields have to be in the same order as in the T8/CONTRACT struct definition?

If not, would the most appropriate way be to load the full dataset, and save its subset containing the data consisting of the fields from the CONTRACT struct to a T8 file? Then, each invocation of the run function during a backtest, one would need to look up the additional information from the backtest?

Last edited by asdvao; 09/27/17 15:54.
Re: Loading the options chain with additional data [Re: asdvao] #468280
09/28/17 00:02
09/28/17 00:02
Joined: Jul 2017
Posts: 784
Z
Zheka Offline
User
Zheka  Offline
User
Z

Joined: Jul 2017
Posts: 784
I have the exact same problem and questions! IB streams pre-calculated greeks, and I would guestimate that using those is more efficient than calculating locally for a number of strikes.

I too wanted to suggest to add 2-3 more fields for the greeks to the T8/Contract struct definition (or make it extendable by a user) and verify that IB plug-in can also populate those...Backtesting would be more efficient and RT too.

Re: Loading the options chain with additional data [Re: Zheka] #468283
09/28/17 06:05
09/28/17 06:05
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
You have no limit for the data. When your options data is in a dataset options.t8, put the greeks and other data in a parallel dataset greeks.t99. To retrieve all greeks that belong to the current options chain, use dataFind() with the current date. It returns the row with the additional data for the first contract of the chain. The other contracts are in the next rows.

We will make this easier in a future version by storing the dataset row number of a found contract.

Re: Loading the options chain with additional data [Re: jcl] #468295
09/28/17 11:45
09/28/17 11:45
Joined: Sep 2017
Posts: 6
A
asdvao Offline OP
Newbie
asdvao  Offline OP
Newbie
A

Joined: Sep 2017
Posts: 6
Thanks jcl, this clears it up somewhat.

Suppose I want to try a simple strategy using the additional data. Suppose I have options.t8 and options_with_additional.t99, where the latter is simply a superset of the former (i.e. the T99 also includes, beside additional data, the data that's already in T8).

I'd first load up both datasets, and update the contract chain with contractUpdate to the T8 dataset.

After that, I need to find the date for which I'm wanting to trade, and get the appropriate rows from the dataset using dataFind and the bar date (wdate?). Then, I'd loop thru the dataset, and figure out which contract(s) I want to trade. With this information, for each contract I want to trade, I'd create the CONTRACT struct, and try to find a matching contract within the chain (contract() function), and enter the appropriate positions.

Would this be a sensible approach?

Alternatively, from what I can figure from your answer, you were suggesting first going thru the contracts, and then use dataFind to use the appropriate greeks. In this approach, it's not clear how would I loop thru all the possible contracts to identify the ones that I want to trade.





Last edited by asdvao; 09/28/17 11:48.
Re: Loading the options chain with additional data [Re: jcl] #468303
09/28/17 14:05
09/28/17 14:05
Joined: Jul 2017
Posts: 784
Z
Zheka Offline
User
Zheka  Offline
User
Z

Joined: Jul 2017
Posts: 784
I somehow missed on the might of free-form datasets! Got into details and here are the questions:

1. Would "99" in suggested "greeks.t99" typically be a Handle?
2.
Quote:
In [Test] or [Train] mode the chain is copied from a dataset containing CONTRACT records, which is either automatically obtained from a Name.t8 file, or copied from a previously loaded dataset with the given Handle

What should be the format of records in dataset with a list of CONTRACT structs to be used in ContractUpdate()?

3. You seem to favor using big single files to store all of the options/ greeks data for an asset. Why? Would storing data in many files e.g. 'by expiry' be less efficient in practice?
Or is it because of the file name convention used?

4. Do i understand correctly that *.t8 files would update in real-time but a "dataset" would not?

IB streams greeks and IV together with prices in RT
https://interactivebrokers.github.io/tws-api/option_computations.html#gsc.tab=0

So, why not just add 4-5 fields to the *.t8 struct? (and avoid having to use several datasets, locating matching records,etc)

Last edited by Zheka; 09/28/17 14:07.
Re: Loading the options chain with additional data [Re: Zheka] #468304
09/28/17 14:16
09/28/17 14:16
Joined: Jul 2017
Posts: 784
Z
Zheka Offline
User
Zheka  Offline
User
Z

Joined: Jul 2017
Posts: 784
I also would like to clarify the example on the "Datasets" page in the manual:
Quote:
// parse iVolatility historical option chain data and store the resulting array
void main()
{
string Format = "+,,%m/%d/%y,,,i,f,s,s,f,f,f,,f";
int records = dataParse(1,Format,"iVolatility_SPY_2014_1.csv");
records += dataParse(1,Format,"iVolatility_SPY_2014_2.csv");
records += dataParse(1,Format,"iVolatility_SPY_2015_1.csv");
records += dataParse(1,Format,"iVolatility_SPY_2015_2.csv");
records += dataParse(1,Format,"iVolatility_SPY_2016_1.csv");
printf("n%d records parsed",records);
dataSave(1,"SPY_Options.t8");
}

The Format is different from the *.t8 struct. How would it map to it?

Re: Loading the options chain with additional data [Re: Zheka] #468356
10/02/17 09:36
10/02/17 09:36
Joined: Jul 2017
Posts: 784
Z
Zheka Offline
User
Zheka  Offline
User
Z

Joined: Jul 2017
Posts: 784
Hi, Jcl,

Would greatly appreciate your answers!

Best
Z.

Page 1 of 3 1 2 3

Moderated by  Petra 

Powered by UBB.threads™ PHP Forum Software 7.7.1