Gamestudio Links
Zorro Links
Newest Posts
MT5 bridge not working on MT5 v. 5 build 4160
by EternallyCurious. 04/25/24 20:49
Data from CSV not parsed correctly
by EternallyCurious. 04/25/24 10:20
Trading Journey
by howardR. 04/24/24 20:04
M1 Oversampling
by Petra. 04/24/24 10:34
Zorro FIX plugin - Experimental
by flink. 04/21/24 07:12
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
AUM Magazine
Latest Screens
The Bible Game
A psychological thriller game
SHADOW (2014)
DEAD TASTE
Who's Online Now
4 registered members (EternallyCurious, AndrewAMD, TipmyPip, Quad), 902 guests, and 8 spiders.
Key: Admin, Global Mod, Mod
Newest Members
Mega_Rod, EternallyCurious, howardR, 11honza11, ccorrea
19048 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: 586
Austria
Petra Offline
Support
Petra  Offline
Support

Joined: Apr 2008
Posts: 586
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,982
Frankfurt
jcl Offline

Chief Engineer
jcl  Offline

Chief Engineer

Joined: Jul 2000
Posts: 27,982
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