Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
Data from CSV not parsed correctly
by EternallyCurious. 04/20/24 21:39
M1 Oversampling
by 11honza11. 04/20/24 20:57
Scripts not found
by juergen_wue. 04/20/24 18:51
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
folder management functions
by VoroneTZ. 04/17/24 06:52
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
1 registered members (rki), 405 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
IB Options - Issue with multiple Assets #469041
11/03/17 20:36
11/03/17 20:36
Joined: Nov 2016
Posts: 103
NSW
V
vinsom Offline OP
Member
vinsom  Offline OP
Member
V

Joined: Nov 2016
Posts: 103
NSW

Hi,
I just slightly modified the SellRandom script from FinancialHacker to be able to trade multiple options assets.

In test works fine.
But when I go in Demo account on IB, in the second loop for the second asset (AAPL) the contract is always invalid.
First Asset (is always fine).
I did another test Still in IB demo account, removing the first asset(SPY), leaving only AAPL, and then the contract is valid and the trade is entered.

Is there anything I'm missing ?
Thanks for your help



// Options Test //////////////////////////

#include <contract.c>
static int LastExpiry[2];

void run()
{
int Handle=0;
BarPeriod = 1440;
BarZone = ET;
BarOffset = 15*60;
StartDate = 20140101;
EndDate = 20171001;
set(PRELOAD|LOGFILE);
PlotWidth = 1000;
PlotHeight1 = 400;

while(asset(loop("SPY","AAPL")))
{
Handle++;
assetHistory(Asset,FROM_AV|UNADJUSTED);
if(is(INITRUN))
{
char FileName[100];
sprintf(FileName, "%s_SimOptions.t8",Asset );
dataLoad(Handle,FileName,9);
}

contractUpdate(Asset,Handle,CALL|PUT);
Multiplier = 100;
int Type = ifelse(random() > 0,CALL,PUT);
CONTRACT *c=contract(Type,30,priceClose());

if(c && ContractType && LastExpiry[Handle-1] != ContractExpiry && !is(LOOKBACK))
{
contractPrint(c);
printf("n %s %s ContractType:%d ContractExpiry:%d Strike:%f LastExpiry:%d",Asset,strdate("%Y-%m-%d %H:%M:%S"), ContractType, ContractExpiry, priceClose(), LastExpiry[Handle-1]);
enterShort();
printf("n SOLD!");
LastExpiry[Handle-1] = ContractExpiry;
}
else if(!is(LOOKBACK))
{
printf("n %s %s ContractType:%d ContractExpiry:%d Strike:%f LastExpiry:%d",Asset,strdate("%Y-%m-%d %H:%M:%S"), ContractType, ContractExpiry, priceClose(), LastExpiry[Handle-1]);
printf("n INVALID!");
}
}
}

Re: IB Options - Issue with multiple Assets [Re: vinsom] #469130
11/06/17 09:09
11/06/17 09:09
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
The script looks ok at first glance. Maybe it is an issue with the IB plugin. I've forwarded this to the developers for looking into the problem.

Re: IB Options - Issue with multiple Assets [Re: jcl] #469174
11/07/17 09:35
11/07/17 09:35
Joined: Jul 2000
Posts: 27,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
Frankfurt
I was told that this is really a bug, but it cannot be fixed on the Zorro side. It must be accounted for in the script. The IB API can sometimes not deliver two option chains directly in sequence. It needs a couple seconds between the SPY and the AAPL options chain. That's why you did not get the chain for the second asset.

Solution: use Sleep() or wait() in your loop for waiting 10-30 seconds before the second contractUpdate call. This behavior is apparently dependent on the market situation, in the past we observed no problem to get several options chains in sequence.

This will be mentioned in the manual.

Re: IB Options - Issue with multiple Assets [Re: jcl] #469321
11/10/17 20:41
11/10/17 20:41
Joined: Nov 2016
Posts: 103
NSW
V
vinsom Offline OP
Member
vinsom  Offline OP
Member
V

Joined: Nov 2016
Posts: 103
NSW
Thanks, looks like the wait is fixing the issue


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