Gamestudio Links
Zorro Links
Newest Posts
Zorro FIX plugin - Experimental
by flink. 04/20/24 06:09
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:46
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
2 registered members (flink, Edgar_Herrera), 695 guests, and 0 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, howardR, 11honza11, ccorrea, sakolin
19047 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
contractPrice(CONTRACT*) crashing script #473919
08/27/18 21:31
08/27/18 21:31
Joined: Jul 2016
Posts: 93
Düsseldorf, Germany
M
mhdus Offline OP
Junior Member
mhdus  Offline OP
Junior Member
M

Joined: Jul 2016
Posts: 93
Düsseldorf, Germany
Hi,
I'm using the simple test script below which is working almost as expected unless I'm commenting-in the contractPrice(C1); row which is causing the script to crash.
"Almost" because contractDays() is returning numbers such as 43369.50 - I assume this happens because I'm using it within a main() function so there is no current bar time, correct?
However, what's wrong with contractPrice()?? The futures chain seems loading just fine as the outputs are looking good.
I'm have been testing with Zorro 1.87 and 1.88.1, same issue.

Test Script:

#include <contract.c>
void main()
{
contractUpdate("GC",0,FUTURE);
printf("nLoaded %d contracts.",NumContracts);
CONTRACT* C1 =contract(FUTURE,5,0);
CONTRACT* C2 =contract(FUTURE,50,0);
// contractPrice(C1);
printf("ncontractDays C1 = %.2f",contractDays(C1));
contractPrint (C1);
printf("ncontractDays C2 = %.2f",contractDays(C2));
contractPrint (C2);
contractPrint ();
}

Re: contractPrice(CONTRACT*) crashing script [Re: mhdus] #473920
08/28/18 06:15
08/28/18 06:15
Joined: Apr 2008
Posts: 585
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 585
Austria
Better test with if(C1) that the pointer is not 0 before you do something with it.

Re: contractPrice(CONTRACT*) crashing script [Re: Petra] #473921
08/28/18 07:29
08/28/18 07:29
Joined: Jul 2016
Posts: 93
Düsseldorf, Germany
M
mhdus Offline OP
Junior Member
mhdus  Offline OP
Junior Member
M

Joined: Jul 2016
Posts: 93
Düsseldorf, Germany
Fully agreed, as a general rule this should always be tested first.

However, for this small test script I thought the call to contractDays(C1) is a sufficient indirect confirmation that C1 is valid. Anyway, the script is still crashing, even after changing this line to

if(C1) contractPrice(C1);

Meanwhile I also changed the asset (to something trading at this time of day):

contractUpdate("DAX-IDX-SMART-EUR",0,FUTURE);

Here is the output:

MH_Fut_Chk01
Login 0 IB..
!IB Socket connected
!Account Unnnnnnn at UTC 08-28 07:13
!Get Future Chain DAX-FUT--0----EUR
Chain of 6 DAX-IDX-SMART-EUR contracts
Loaded 6 contracts.
Error 111: Crash in function: main() at bar 0
Logout.. ok

here is the output if the contractPrice() line is commented out:

MH_Fut_Chk01
Login 0 IB..
!IB Socket connected
!Account Unnnnnnn at UTC 08-28 07:23
!Get Future Chain DAX-FUT--0----EUR
Chain of 6 DAX-IDX-SMART-EUR contracts
Loaded 6 contracts.
contractDays C1 = 43364.50
FDXM,Future,20180921,0.0000,0.0000,0.0000,0.0000,5,0
contractDays C2 = 43455.50
FDXM,Future,20181221,0.0000,0.0000,0.0000,0.0000,5,0
Logout.. ok

The script is creating the following CSV:

Class,Type,Expiry,Strike,Underlying,Ask,Bid,Multiplier,Vol
FDXM,Future,20180921,0.0000,0.0000,0.0000,0.0000,5,0
FDAX,Future,20180921,0.0000,0.0000,0.0000,0.0000,25,0
FDXM,Future,20181221,0.0000,0.0000,0.0000,0.0000,5,0
FDAX,Future,20181221,0.0000,0.0000,0.0000,0.0000,25,0
FDAX,Future,20190315,0.0000,0.0000,0.0000,0.0000,25,0
FDXM,Future,20190315,0.0000,0.0000,0.0000,0.0000,5,0

Could this be a bug related to futures chains?

Re: contractPrice(CONTRACT*) crashing script [Re: mhdus] #473924
08/28/18 13:29
08/28/18 13:29
Joined: Jul 2000
Posts: 27,978
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,978
Frankfurt
No, but it is in fact a bug related to contractPrice. This will be fixed in the final 1.88 release.

Re: contractPrice(CONTRACT*) crashing script [Re: jcl] #473925
08/28/18 13:47
08/28/18 13:47
Joined: Jul 2016
Posts: 93
Düsseldorf, Germany
M
mhdus Offline OP
Junior Member
mhdus  Offline OP
Junior Member
M

Joined: Jul 2016
Posts: 93
Düsseldorf, Germany
Great, thanks for the feedback.


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