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
6 registered members (EternallyCurious, AndrewAMD, ricky_k, 7th_zorro, 2 invisible), 478 guests, and 3 spiders.
Key: Admin, Global Mod, Mod
Newest Members
EternallyCurious, 11honza11, ccorrea, sakolin, rajesh7827
19046 Registered Users
Previous Thread
Next Thread
Print Thread
Rate Thread
GET_TRADES via BrokerCommand #485391
03/04/22 16:49
03/04/22 16:49
Joined: Jan 2014
Posts: 86
London City
B
byakuren81 Offline OP
Junior Member
byakuren81  Offline OP
Junior Member
B

Joined: Jan 2014
Posts: 86
London City
Hello,

I implemented BrokerCommand for GET_TRADES in the broker API and called from Zorro at INITRUN:
int npos = brokerTrades(0);
printf("\nNumber of positions loaded: %d", npos);

However I do not get any opened trades when calling: for(open_trades).

I get the correct number of positions but I cannot modify the value of the argument dwParameters in my implementation of BrokerCommand as it is of type DWORD.
So I cannot pass the address of the first element of the TRADE array to Zorro.

I thought I could call brokerCommand on GET_TRADES directly and add the trades to Zorro internal trade list using the method enterTrade but I face the same issue on passing to Zorro the address of the first TRADE array element.
In the documentation I see 3 overloaded methods for brokerCommand but only one BrokerCommand in the broker API.

Moreover extern "C" functions cannot be overloaded so I cannot specialize BrokerCommand to pass this address Zorro.

Could you please tell me how to proceed?



Last edited by byakuren81; 03/06/22 14:24.
Re: GET_TRADES via BrokerCommand [Re: byakuren81] #485397
03/06/22 20:12
03/06/22 20:12
Joined: Jan 2014
Posts: 86
London City
B
byakuren81 Offline OP
Junior Member
byakuren81  Offline OP
Junior Member
B

Joined: Jan 2014
Posts: 86
London City
I found the solution:

In your broker API code, within your implementation of the function BrokerCommand(int nCommand, DWORD dwParameters), convert the argument dwParameters to an hexadecimal pointer address:

char hex[10];
sprintf(hex, "%x", dwParameters );
TRADE* trades = (TRADE*)strtoul(hex, NULL, 16);

Then fill the trades array with the trades you will have loaded from the broker.

Important: remember to set the structure alignment of your code to 4 as mentioned in Zorro documentation in Broker / Feed Plugin.
In Visual Studio 2017, go to your project properties, then under C/C++ Code Generation set Struct Member Alignment to 4.

Finally from Zorro call during INITRUN:
int npos = brokerTrades(0);

And check your broker API code works:
for(open_trades)
{
printf("\nTradeID number %d is loaded", TradeID);
}


Last edited by byakuren81; 03/06/22 20:13.

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