SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Wed Aug 15, 2018 3:48 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Tue Jan 06, 2015 3:14 pm 
Offline

Joined: Mon Jan 05, 2015 11:03 pm
Posts: 7
Location: Hungary
Dear Support,

I am using OpenQuant and TT Api with X-trader pro. I would like to trade on CME FUT and Options. TT api, Xtrader and OQ perfectly connected able to trade, able to import instruments. Only issue is the broker account sync. Sometimes I see the broker within the broker info menu sometimes not. The same from code. For example yesterday I connected the system broker info was correct from code and from the menu too. Not shuted down the system and today I not see the broker.

Other side if I see the broker I able to read only the today executed orders and fills. So the previously opened position I not able to see. Xtrader Fills window has a column O/C witch indicates the type of position you are establishing with the order:

O: Open -> only see this type of orders
C: Close
S: Start of Day fill. (Refer to Start of Day Fills) -> this is the previous day or earlier opened positions
M: Manual fill from your workstation or X_RISK.
A: Manual administrator fill from X_RISK.
D: Detailed Start of Day from Back Office Bridge.

For test I use this code within onStart:
--------------------------------------------------------------------------------------------------------------------
BrokerAccountList TTapi = DataManager.GetBrokerInfo().Accounts;
Console.WriteLine(" "+TTapi.Count);
foreach (BrokerAccount brokerAcc in TTapi) {
Console.WriteLine(" acc: " +brokerAcc);
}
if(MarketDataProvider.IsConnected && DataManager.GetBrokerInfo("TT API").Accounts.Count > 0)
{
BrokerAccount TTAccount = DataManager.GetBrokerInfo("TT API").Accounts[0];

Console.WriteLine("tt account count"+TTAccount.Positions.Count);

foreach(BrokerPosition brokerPosition2 in TTAccount.Positions)
{
Console.WriteLine(brokerPosition2.Symbol+" "+brokerPosition2.Strike+" "+brokerPosition2.Qty);
}
Console.WriteLine("orders");
foreach(BrokerOrder brokerOrder in TTAccount.Orders)
{
Console.WriteLine(brokerOrder.Symbol+" "+brokerOrder.Status+" "+brokerOrder.Qty);
}
Console.WriteLine("fields");
foreach(BrokerPositionField brokerField in TTAccount.Fields)
{
Console.WriteLine(brokerField.Name+" "+brokerField.Value);
}
---------------------------------------------------------------------------------------------------------


Top
 Profile  
 
PostPosted: Tue Jan 06, 2015 6:57 pm 
Offline
Site Admin

Joined: Thu Jul 17, 2003 10:39 am
Posts: 1478
Hi,

TT API plugin may receive the broker information (initial state) with some delay after connect.
Could you connect plugin and request the broker info after a couple of seconds (5-10)?

_________________
SmartQuant Development Team


Top
 Profile  
 
PostPosted: Wed Jan 07, 2015 2:58 pm 
Offline

Joined: Mon Jan 05, 2015 11:03 pm
Posts: 7
Location: Hungary
Hello,

yesterday I tested it and tried your recommendation but it not works. I have two risk account within one login in Xtrader. The experience was the following:

If I not trade today I not see the empty accounts. Account count=0
the brokerinfo not see at all the previous day opened positions
If I trade for one risk account the brokerinfo will able to see the account and see the today traded positions but the second account not recognized till I not trade on the second account too.
as the CME evening clearing period reached the brokerinfo also not will see the previous period traded positions (23:00CET-00:00CET) so I not see the accounts again till I not trading on them

My target is to sysnc the positions within OQ with the TT.

Any recommendation please?


Top
 Profile  
 
PostPosted: Thu Jan 08, 2015 2:04 pm 
Offline
Site Admin

Joined: Thu Jul 17, 2003 10:39 am
Posts: 1478
Hi,

There is no way to receive positions from the current version of TT API.
Plugin constructs them from the fills, but the API clears this collection on every session start.

_________________
SmartQuant Development Team


Top
 Profile  
 
PostPosted: Fri Jan 09, 2015 1:34 pm 
Offline

Joined: Mon Jan 05, 2015 11:03 pm
Posts: 7
Location: Hungary
Dear Alexei,

I found two sample code on TT website related the fillupdate. I attached both. From the visual studio both works properly. But I not was able to add to OQ. OQ collapsed all the time. I tried to put the TTapi form in a new thread but no succes. Please check the error message too:
--------------------------------------
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.ObjectDisposedException: Object has been disposed and can no longer be used.
at TradingTechnologies.TTAPI.Dispatcher.beginInvoke(ManagedRunnable runnable)
at TradingTechnologies.TTAPI.TTUSHub.OnUserInfo(Int32 cookie, basic_string<char\,std::char_traits<char>\,std::allocator<char> >* username, shared_ptr<tt_usersetup::UserInfoCollection const >* userInfo)
at TradingTechnologies.TTAPI.TTUSHubNativeObserver.OnUserInfo(TTUSHubNativeObserver* , Int32 cookie, basic_string<char\,std::char_traits<char>\,std::allocator<char> >* username, shared_ptr<tt_usersetup::UserInfoCollection const >* userInfo)
at tt_usersetup.ClientHub.RequestUserInfo(ClientHub* , Int32 , basic_string<char\,std::char_traits<char>\,std::allocator<char> >* , ClientHubObserver* )
at TradingTechnologies.TTAPI.TTUSHub.GetUserInfo()
at TradingTechnologies.TTAPI.TTUSHub.Start()
at TradingTechnologies.TTAPI.TTAPI.initializeTTUSHub(String userName, Dispatcher dispatcher)
at TradingTechnologies.TTAPI.XTraderModeTTAPI.ValidateUserName()
at TradingTechnologies.TTAPI.XTraderModeTTAPI.initialize()
at TradingTechnologies.TTAPI.TTAPI.Initialize()
at TradingTechnologies.TTAPI.TTAPI.startCreateXTraderModeTTAPI(Dispatcher dispatcher, XTraderModeTTAPIOptions options, ApiInitializeHandler callback)
--- End of inner exception stack trace ---
at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
at System.Delegate.DynamicInvokeImpl(Object[] args)
at TradingTechnologies.TTAPI.DynamicRunnable.run()
at TradingTechnologies.TTAPI.ManagedRunnable.Run()
at TradingTechnologies.TTAPI.RunnableWrapper.Run(RunnableWrapper* )
----------------------------------------

Could you please help to integrate this code into OQ?

Thank you indeed

Gábor


Attachments:
File comment: only attached the code files
original:https://developer.tradingtechnologies.com/tt-api

TTAPI_Sample_Console_FillSubscription.rar [5.06 KiB]
Downloaded 168 times
File comment: only attached the code files
FillUpdate.rar [32.35 KiB]
Downloaded 147 times
Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 3 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group