2 registered members (AndrewAMD, TipmyPip),
923
guests, and 4
spiders. |
Key:
Admin,
Global Mod,
Mod
|
|
|
Options trading questions
#473974
09/04/18 18:04
09/04/18 18:04
|
Joined: Jul 2017
Posts: 784
Zheka
OP
User
|
OP
User
Joined: Jul 2017
Posts: 784
|
JCL,
there are several classes of FX options having the same expiry date, some are illiquid or not desirable for trading for some other reason. However,contractUpdate() gets everything and selecting a contract via standard contract functions sometimes gets such an "undesirable" contract.
I am exploring 2 approaches: 1)"pruning" the received contract chain, getting rid of unnecessary lines or - preferably- 2)creating own 'mini-chain' from the very beginning.
So, questions: for 1) - how to access the first field - which in [Trade] mode contains "class" (a string, rather than time). - will it be possible to set Expiry of selected structs to zero, or Contracts is a "read-only" list? - can you implement a way to trim such live contract chain based on class and strikes?
for 2) - can you enable loading/using a user-supplied chain dataset in [Trade] mode, like it is done in [Test] mode? - how to properly fill in the Contract struct to pass to the contractPrice() to request a price update for an arbitrary, user-defined contract?
Thank you.
Last edited by Zheka; 09/04/18 21:41.
|
|
|
Re: Options trading questions
[Re: Zheka]
#473981
09/05/18 08:11
09/05/18 08:11
|
Joined: Jul 2017
Posts: 784
Zheka
OP
User
|
OP
User
Joined: Jul 2017
Posts: 784
|
Thank you! (string)C works with the downloaded chain. How do you recommend to reset PUT/CALL flags? Why is preferable to setting Expiry to 0? I then thought of sorting the Contracts list and cutting the unnecessary lines altogether by setting NumContracts to a smaller value..Is this at all possible?
Is the class just typecasted to/from double? I.e. a dataset will need to have the first column saved as e.g.(double)Class (where Class is a string)? And when such Contract* C is passed to contractPrice(C) it is automatically assumed to contain class in its first field?
Last edited by Zheka; 09/05/18 12:28.
|
|
|
Re: Options trading questions
[Re: jcl]
#473989
09/05/18 16:43
09/05/18 16:43
|
Joined: Jul 2017
Posts: 784
Zheka
OP
User
|
OP
User
Joined: Jul 2017
Posts: 784
|
I am trying to get the option chain to a dataset before trimming as needed. string Format="s,sss8,i7,f6,f5,f1,f2,f3,f4"; char* exClass="EU"; CONTRACTS* C; for (ii=0;ii<NumContracts;ii++) { C=Contracts+ii; if (strstr((string)C,exClass)) contractPrint(C,TO_CSV); } dataParse(2,Format,"C:ZorroLogTradeOptions.csv"); file_delete("C:ZorroLogTradeOptions.csv"); ii=0; while(C = dataStr(2,ii++,0)) contractPrint(C,TO_CSV); All good except for one character lost in the class string. Downloading chain.. !Get Future Option Chain EUR-FOP--0----USD Chain of 3044 EUR contracts 3044 contracts Parse C:ZorroLogTradeOptions.csv.. EUU,FutureCall,20180907,1.1650,0.0000,0.0000,0.0000,125000,0 EU FutureCall 20180907 1.16500 0.00000 0.00000 0.00000 125000.00000 0.00000 And then the last contractPrint() prints nothing for the class at all. Why would this happen? The manual states "s" parses a 3-character text field, and as you can see this is the case. Is there a more elegant way of getting from Contracts to a dataset? Given that formation of a more relevant contracts set is a typical step, it might make sense to store the retrieved option chain as a dataset (rather then an internal list of structs), seamlessly with [Test] mode. contractUpdate() would then just return a handle to such dataset. And both contract() and dataset functions will be available at once.
Last edited by Zheka; 09/05/18 16:47.
|
|
|
Re: Options trading questions
[Re: Zheka]
#473991
09/05/18 17:26
09/05/18 17:26
|
Joined: Jul 2017
Posts: 784
Zheka
OP
User
|
OP
User
Joined: Jul 2017
Posts: 784
|
contractPrice() does not seem to work. C=contract(CALL,2,priceClose()); print(TO_WINDOW,"n Future price=%f",contractPrice(C)); contractPrint(C,TO_WINDOW); produces this output: NY Time: 13:19 Downloading chain.. !Get Future Option Chain EUR-FOP--0----USD Chain of 3044 EUR contracts 3044 contracts !EUR-FOP-20180907-1.16-C-GLOBEX: 0.00000 0.00000 0 Future price=0.000000 EUU,FutureCall,20180907,1.1650,1.1641,0.0000,0.0000,125000,0 V 1.883 on Wed 18-09-05 13:18:38 EUR 1.16406 0.00005 0.000 0.000 0.00010 0.00010 0.0200 125000.0 285312.0
Trade: TradeOptions EUR 2018-09-05 Assets AssetsIB
[1: Wed 18-09-05 17:19] 1.1641/1.16411.1640/1.1641 -0.000050000 Future price=0.000000 EUU,FutureCall,20180907,1.1650,1.1641,0.0000,0.0000,125000,0 The price of an underlying is updated (but not returned), neither are bid-ask for the option.
|
|
|
Re: Options trading questions
[Re: jcl]
#474140
09/24/18 14:40
09/24/18 14:40
|
Joined: Jul 2017
Posts: 784
Zheka
OP
User
|
OP
User
Joined: Jul 2017
Posts: 784
|
For loading a chain from a file while live trading, use dataLoad() JCL, HAving loaded a custom chain with dataLoad(), I would like to use standard contract() search functions for looking up a desired contract. However, doing Contracts = (CONTRACT*) dataStr(2,0,0); //with or without typecast C=contract(CALL,3,priceClose()); print(TO_WINDOW,"n Option price=%f",contractPrice(C)); generates: Error 016: Invalid date 0 Is there a workaround? Or would it be possible to add handle as input to all contract() functions?
|
|
|
Re: Options trading questions
[Re: jcl]
#474144
09/24/18 15:11
09/24/18 15:11
|
Joined: Jul 2017
Posts: 784
Zheka
OP
User
|
OP
User
Joined: Jul 2017
Posts: 784
|
This is in Trade mode following contract chain 'trimming': for (ii=0;ii<NumContracts;ii++) { C=Contracts+ii;
if (strstr((string)C,incClass)) contractPrint(C,TO_CSV); }
int sNumContracts=dataParse(2,Format,"C:ZorroLogEA_TradeOptions.csv");
|
|
|
Re: Options trading questions
[Re: Zheka]
#474155
09/25/18 15:36
09/25/18 15:36
|
Joined: Jul 2017
Posts: 784
Zheka
OP
User
|
OP
User
Joined: Jul 2017
Posts: 784
|
I got this to (somewhat) work. The problem has been that contractPrint() exported a text field and i parsed it as such, while proper CONTRACT struct needs an int in this place. So, the trick with assigning a ptr to the dataset to Contracts works. However, C=contract(CALL,3,priceClose()) still generates Error 016: Invalid date 0 And then selects some arbitrary contract strike. Does contract() make any assumption on the order of expiries (or something else) in the option chain?
|
|
|
Re: Options trading questions
[Re: jcl]
#474311
10/05/18 13:34
10/05/18 13:34
|
Joined: Jul 2017
Posts: 784
Zheka
OP
User
|
OP
User
Joined: Jul 2017
Posts: 784
|
JCL, I have a problem with obtaining a contractPrice() in Trade Mode for a correctly selected Contract - when I load a chain from a dataset, rather then when using a contractUpdate(). (actually, occasionally also when i DO use contractUpdate()). The difference between cases when it works and when it doesn't comes down to this. BrokerAsset ??? - FOP-20181109-1.16-C-GLOBEX: : 0.0000 0.004145 ms BrokerAsset EUR-FOP-20181109-1.16-C-GLOBEX: : 0.0118 6983.145685 ms i.e. the underlying "string" is not recognized ("EUR" is dropped from the symbol string). I of course do call asset ("EUR") before contractUpdate() and contractPrice().I got this reply from support: the part "EUR" of the contract symbol is stored by contractUpdate(). asset() is for selecting an asset, not for storing a contract symbol. Since the "EUR" is sometimes missing in your symbol, we suspect that the first argument to the previous contractUpdate call was wrong. For testing that, please print the first argument of contractUpdate() to the log. If it turns out that "EUR" was correctly set but is still missing in the symbol, then we have to look elsewhere. To which I have 2 questions: 1) Which variable in an Asset struct - or anywhere else - that holds this value - and so could be set? - I thought this should be taken by Zorro from the very first part of the SYMBOL string. 2) Is it possible at all to NOT call contractUpdate() in a script? Answer from support suggests it is not possible, but you earlier wrote that it is indeed possible to load a chain from a file. I think it should be made possible.
|
|
|
|