Page 1 of 1

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

Posted: Wed Jan 13, 2021 10:18 am
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

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

Posted: Thu Jan 14, 2021 1:24 pm
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

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

Posted: Thu Jan 14, 2021 1:55 pm
by hkenrique
Hello,

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