Gamestudio Links
Zorro Links
Newest Posts
Data from CSV not parsed correctly
by EternallyCurious. 04/18/24 10:45
StartWeek not working as it should
by Zheka. 04/18/24 10:11
folder management functions
by VoroneTZ. 04/17/24 06:52
lookback setting performance issue
by 7th_zorro. 04/16/24 03:08
zorro 64bit command line support
by 7th_zorro. 04/15/24 09:36
Zorro FIX plugin - Experimental
by flink. 04/14/24 07:48
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 (MadJack, AndrewAMD, Quad), 540 guests, and 1 spider.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
Page 1 of 2 1 2
Options trading questions #473974
09/04/18 18:04
09/04/18 18:04
Joined: Jul 2017
Posts: 784
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

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] #473979
09/05/18 06:52
09/05/18 06:52
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
You can get a pointer to the whole chain with the Contracts pointer, and this way evaluate the class and reset the PUT/CALL flags on wrong classes. The class string of a contract pointer C is simply (string)C. For loading a chain from a file while live trading, use dataLoad(). The .t8 file has the same structure as a dataset with 9 fields.

Re: Options trading questions [Re: jcl] #473980
09/05/18 07:34
09/05/18 07:34
Joined: Jul 2017
Posts: 784
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 784
OK. But please give some more details on the first field:
it is of DATE type in a Contract structure, but somehow is a string in a downloaded chain (which is supposedly a dataset/list of Contract structs...

How do I access the class? c->xxx?

Re: Options trading questions [Re: Zheka] #473981
09/05/18 08:11
09/05/18 08:11
Joined: Jul 2017
Posts: 784
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

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: Zheka] #473984
09/05/18 12:48
09/05/18 12:48
Joined: Jul 2017
Posts: 784
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 784
Trading a portfolio of options/expirations, it is needed to have a futures chain alongside the options chain.

What's the recommended way to maintain both, usable by the standard contract() functions?

Re: Options trading questions [Re: Zheka] #473988
09/05/18 13:44
09/05/18 13:44
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
The probably simplest method is splitting the asset in two, one for the options and one for the futures.

Sorting and reducing the contracts list should work, although I haven't tested it - just try. For resetting PUT and CALL, simply set C->Type=0. Expiry=0 will probably also work. Class and timestamp are a union of the same struct element. In live trading it's the class, in the backtest it's the timestamp.

Re: Options trading questions [Re: jcl] #473989
09/05/18 16:43
09/05/18 16:43
Joined: Jul 2017
Posts: 784
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 784
I am trying to get the option chain to a dataset before trimming as needed.
Quote:
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.
Quote:
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
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 784
contractPrice() does not seem to work.

Quote:
C=contract(CALL,2,priceClose());

print(TO_WINDOW,"n Future price=%f",contractPrice(C));
contractPrint(C,TO_WINDOW);

produces this output:
Quote:
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: Zheka] #474068
09/17/18 18:53
09/17/18 18:53
Joined: Jul 2017
Posts: 784
Z
Zheka Offline OP
User
Zheka  Offline OP
User
Z

Joined: Jul 2017
Posts: 784
JCL,

will appreciate your attention to get this resolved.

Thank you.

Re: Options trading questions [Re: Zheka] #474077
09/18/18 15:52
09/18/18 15:52
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
What resolved? We got a bug report about that, I suppose from you, but could not confirm that problem. You can only trade options when you got the needed IB account permissions and subscribed the needed market data - then all is fine. If you have another problem, just give details.

Page 1 of 2 1 2

Moderated by  Petra 

Gamestudio download | chip programmers | Zorro platform | shop | Data Protection Policy

oP group Germany GmbH | Birkenstr. 25-27 | 63549 Ronneburg / Germany | info (at) opgroup.de

Powered by UBB.threads™ PHP Forum Software 7.7.1