New Version 1.5.0.0 Major Update

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
board_admin
Site Admin
Posts: 244
Joined: Mon Apr 24, 2017 3:24 pm

New Version 1.5.0.0 Major Update

Post by board_admin »

A new version has been uploaded:

https://trade-commander.com/wp-content/ ... nSetup.exe

This version is a major update and has in parts a changed interface. So using it, means update some code (not much).
It has a complete help and also some Video Tutorials with examples for TradeStation / MultiCharts and MetaTrader.

The new version is inspired by MetaTrader regarding getting order and position information.
You can now do a NON FLAT position snapshot and cycle over positions with a zero based index
to get information about position: contract/symbol/size/avg. price/etc.
MetaTrader 4/5 code example:

Code: Select all

// --------------------------------------------
	// [#2] List all non zero positions:
	Print("+++ positions START");
	// create a snapshot of current non zero positions (resolution down to (sub-) account)
	int total_objects=ibgCREATE_POSITION_SNAPSHOT(__connection_id);
	Print("#positions=",total_objects );
	// list all positions by index
	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)		
		string fingerprint=ibgPOSITION_INFO_STR(idx,tcpi_str_dmp);
		Print(fingerprint);
		// to get double values returned use function <ibgPOSITION_INFO_DBL>
	}
	Print("--- positions END");
	
Same for orders. Do a pending (active) orders snapshot and cycle overs orders with zero based index:
(each pending order gets also deleted, to demonstrate this function)

Code: Select all

// -----------------------------------------------
	// [#3] List all pending orders placed by this client
	// (The <clientid> passed to ibplugin.dll function selects the
	//  orders that can be seen and mastered by an API client.
	// Each ibplugin.dll instance is an API client.
	// Normally, you do not set the clientid or just pass -1 as the
	// IB trader does it: This will create a clientid based on hash value
	// of your configuration. This way, you be sure to control all orders
	// that have been created by this configuration.
	
    total_objects=ibgCREATE_PENDING_ORDER_SNAPSHOT (__connection_id, 0,1);
	Print("+++ pending orders START. #=",total_objects);
    long uid_order=0;
	// list all positions by index
	for(int idx = 0;idx < total_objects;++idx)
    {

		// print out a string fingerprint of order (1020 is id of order fingerprint)	
		// (the order attribute identifiers are usually listed in help file:
		// C:/Program Files/trade-commander.com/IBPlugin/documentation/tbl_order_attributes.html	)
		string fingerprint=ibgORDER_INFO_STR(idx,1020);
		Print(fingerprint);
		// to get double values returned, use function <ibgPOSITION_INFO_DBL>
		// to get int64 values (order uids) returned, use function <ibgPOSITION_INFO_INT64>
		// to get int values returned, use function <ibgPOSITION_INFO_INT>
		
		// -----------------------------
		// cancel current order[idx]
		// get its uid
		uid_order=ibgORDER_INFO_INT64(idx,1011);
		if(uid_order > 0)
		{
		    // [#3.1]
			int ret_int=ibgORDER_DELETE(__connection_id,uid_order);		
		}
	}
    Print("--- pending orders END");
Video Tutorials about this version, explaining almost all:

Post Reply