3 registered members (MadJack, AndrewAMD, Quad),
540
guests, and 1
spider. |
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.
|
|
|
|