|
Re: Broker API - Options Questions
[Re: jcl]
#469689
12/02/17 16:34
12/02/17 16:34
|
Joined: Feb 2017
Posts: 1,725 Chicago
AndrewAMD
OP
Serious User
|
OP
Serious User
Joined: Feb 2017
Posts: 1,725
Chicago
|
For buying and selling an option, the symbol is passed in char* Asset, coded in the way as described on the "IB" page of the manual. jcl, Is there some way that my plugin can define a futures/options/futures-options contract symbol so that Zorro's use of char* Asset always matches that of my broker? I mean like this: * Zorro calls GET_OPTIONS or GET_FUTURES. * Plugin copies the CONTRACT structs and then return a **negative** number of contracts to indicate that the plugin has symbols to supply. Plugin saves the symbols. * Zorro calls a new function GET_OPTIONS_SYMBOLS or GET_FUTURES_SYMBOLS. Zorro provides a pointer to an array of strings, and the plugin copies the symbols to the array of strings. * The number of CONTRACT structs and symbols would therefore be identical. * Any BrokerAsset, BrokerHistory2, and BrokerBuy call using one of these contracts would therefore use the respective symbol for char* Asset. This would be especially helpful to me, since my SC plugin will be multi-broker.
|
|
|
Re: Broker API - Options Questions
[Re: jcl]
#469774
12/07/17 17:26
12/07/17 17:26
|
Joined: Feb 2017
Posts: 1,725 Chicago
AndrewAMD
OP
Serious User
|
OP
Serious User
Joined: Feb 2017
Posts: 1,725
Chicago
|
The symbols are fact already loaded, only it's an undocumented function because it's not used yet. The Symbol string is stored at the begin of any CONTRACT* struct in the Contracts list, instead of the date that is not needed in the options chain.
So, string CSymbol = Contracts + ContractRow should get the symbol of the current contract. Earlier in the thread, you gave me this line of code:
strcpy_s((char*)g_Contracts,8,C.tradingClass.c_str());
... and you said it was reserved for the trading class. Are you saying that this has been changed to the actual symbol? Back to the struct...
typedef struct CONTRACT
{
DATE time; // or trading class
float fAsk, fBid; // premium without multiplier (f1,f2)
float fVal; // open interest or multiplier (f3)
float fVol; // volume (f4)
float fUnl; // unadjusted underlying price (f5)
float fStrike; // (f6)
long Expiry; // YYYYMMDD (i7)
long Type; // PUT, CALL, FUTURE, EUROPEAN, BINARY (s8)
} CONTRACT; // for options, futures, FOPs
"time" only has room for 8 characters... I don't think that's enough room for an options / futures / FOP symbol. Did you mean that I can overwrite fAsk and fBid as well, giving me 16 characters?
|
|
|
Re: Broker API - Options Questions
[Re: jcl]
#469989
12/18/17 13:15
12/18/17 13:15
|
Joined: Feb 2017
Posts: 1,725 Chicago
AndrewAMD
OP
Serious User
|
OP
Serious User
Joined: Feb 2017
Posts: 1,725
Chicago
|
Do you mean a code like "AAPL-OPT-150-20180303-USD"? That's not supplied by the plugin. It is an internal code used only by Zorro for sending strike, expiry and other parameters to the IB plugin. The API does not know this code. If broker APIs have similar codes in internal lists, they are then broker specific, and not used by Zorro.
Yes, that's it! Did you know that Zorro has been sending IB codes to my Ally plugin for options, and that my plugin had to parse the IB codes and translate them to Ally codes? (Look at my source. I distinguish between "Zorro Assets" and "Ally Assets".) This approach is not feasible for my new plugin, since it supports many brokers, and therefore many broker codes. I have a new idea: 1) Zorro calls GET_OPTIONS or GET_FUTURES. 2) Plugin fills CONTRACT structs. BUT... instead of filling in the exchange info for the time variable, the plugin sends a uint32_t value instead. This will act as an Asset ID number. Before: strcpy to CONTRACT.time the exchange name, eight bytes max. New approach: memcpy eight bytes to CONTRACT.time: "ID#\0xxxx", where "ID#\0" is a header, and "xxxx" is the uint32_t Asset ID number which the plugin has memorized. Plugin will be responsible for memorizing the Asset broker code associated with each Asset ID number. 3) Plugin returns number of structs. 4) NEW FEATURE: Zorro will see that the plugin has filled out the CONTRACT time value in a certain way (such as with a header) and instead of sending an IB code upon BrokerAsset, will send a string indicating the ID number, so that my plugin can retrieve the broker code. For example: "ID#123456789"; 5) My plugin parses this string and retrieves the ID number. Now it knows what broker code to use. Can this be implemented?
Last edited by AndrewAMD; 12/18/17 14:59. Reason: struct handling clarification
|
|
|
|