-1 return value of ibgCREATE_POSITION_SNAPSHOT in IB dem/live account

IBPlugin is further development of TWSLink.It is focused for the useage with MetaTrader. But as it is a DLL, you can use it everywhere on Windows which supports DLL, e.g. in Trade Station or C++ applications or make wrapper for Perl, Python etc.

Users who just registered, please write an email to
forum@trade-commander.de
with your username mentioned.
So we can distinguish you from bots.
Thank you
Post Reply
hkenrique
Posts: 28
Joined: Tue Jul 28, 2020 3:23 pm

-1 return value of ibgCREATE_POSITION_SNAPSHOT in IB dem/live account

Post by hkenrique »

Hello,

I am trying to test the position management module of my EA.
My code looks like this (which is basically the same as the demo in the donwload package):

Code: Select all

   
   	Print("+++ positions START");
	// create a snapshot of current non zero positions (resolution down to (sub-) account)
	int total_objects=0;
	long serverPos=get_position(__conid);
	
	total_objects=ibgCREATE_POSITION_SNAPSHOT(__conid);
	debugPrint(StringFormat("no. of positions=%f, pos value:%d",total_objects,serverPos),INFO);
	// list all positions by index
	string dt;
	for(int idx=0;idx < total_objects;++idx)
   {
		// print out a string fingerprint of positions (12 is id of position fingerprint;4 id of signed position;5 id of avg. entry price)		
		dt=ibgPOSITION_INFO_INT(idx,tcpi_dt_last_update);
		
		PrintFormat("Position Info: dt:%d",dt);
		// to get double values returned use function <ibgPOSITION_INFO_DBL>
	}
	Print("--- positions END");
	
The output looks like this:

Code: Select all

+++ positions START
INFO no. of positions=-1.000000, pos value:-100000
--- positions END
You can tell I have a sell position of -100000, but the return of ibgCREATE_POSITION_SNAPSHOT(__conid); is -1
I did a test, the error code after the ibgCREATE_POSITION_SNAPSHOT(__conid) is 5039 or 5040:
5039: Amount of parameters more than the format specifiers
5040: Damaged parameter of string type

is there anything wrong with the plugin here? any update on either ibPlugin side or IB side I need to perform?
The version of my IB is: Build 981, Jan 11, 2021
The last modified date of my ibplugin.dll is: 30 Dec, 2020

board_admin
Site Admin
Posts: 244
Joined: Mon Apr 24, 2017 3:24 pm

Re: -1 return value of ibgCREATE_POSITION_SNAPSHOT in IB dem/live account

Post by board_admin »

Hello,

In the call of

ibgCREATE_POSITION_SNAPSHOT(__conid);

it seems you pass a contract uid, which is wrong.

Pass a connection id, the same you pass for function

ibgCONNECT

hkenrique
Posts: 28
Joined: Tue Jul 28, 2020 3:23 pm

Re: -1 return value of ibgCREATE_POSITION_SNAPSHOT in IB dem/live account

Post by hkenrique »

Hello,

This does seem to work.
Thank you for helping out!

Post Reply