Go Back   DailyFX Forex Forum | FX Forum > FXCM Products and Services > FXProgrammers > Discussion / Support Forum > Order2Go COM Trading API Support

Reply
 
Thread Tools Rate Thread
  #1 (permalink)  
Old 08-16-2009, 06:35 PM
Registered User
 
Join Date: Feb 2009
Posts: 2
brenzosa is on a distinguished road
Invalid callee.

Hi,

I recently updated Order2Go (this morning, actually) and am now getting an error message "Invalid callee." when executing CreateEntryOrder() which used to work before.

Anyone know if there are any new requirements on CreateEntryOrder() in the latest build?

Thanks!
Bren
Reply With Quote
  #2 (permalink)  
Old 08-17-2009, 12:12 PM
Member
 
Join Date: Oct 2008
Posts: 609
Nikolay.Gekht is on a distinguished road
DISP_E_BADCALLEE is a system error which usually appears during the marshaling operation when destination object is wrong or is already destroyed.
Could you please provide more details on your problem:
1) Which programming language do you use? In case C++ is used and you use the ATL wrappers, did you rebuild your application to let the compiler recognize changes in the interfaces? (Unlike almost all other languages, C++ with ATL wrappers uses early binding by interface instead of late binding by dispids and requires recompiling of the code).
2) How to you can the CreateEntryOrder method?
3) Do you call the CreateEntryOrder method from the same thread which was used to create the core and desktop objects?
4) Does problem appear in the CreateEntryOrder method itself? (For example, if you get the method parameters from other objects, could you please store them into local variables prior to call CreateEntryOrder)?
5) Does problem appear every time or from time to time?
All this information will greatly help to find the real cause of the problem.
Thank you.
Reply With Quote
  #3 (permalink)  
Old 08-22-2009, 09:01 PM
Registered User
 
Join Date: Feb 2009
Posts: 2
brenzosa is on a distinguished road
Hi Nikolay,

Thanks very much for your reply. I reverted to the pre-update version last week and everything worked fine, but I'm worried that one day I will have no choice but to upgrade to latest version and things won't work again.

To answer your questions:

1) I am using Java using Groovy with Scriptom to get COM+ support which always dynamically links to the components.
2) Sorry I didn't understand the question,...
3) No, I am calling from a different thread -- this used to work before the update so if this is a new requirement, then maybe that's the reason.

However, the call to GetPriceHistoryUTC() succeeds which is running on the same thread that calls CreateEntryOrder() (which subsequently fails)

4) Yes it happens in the dispatch call to CreateEntryOrder method itself (Java Stack Trace points specifically to the call)
5) Problem appears every time, no exceptions.

Thanks!
Reply With Quote
  #4 (permalink)  
Old 08-23-2009, 09:07 PM
Member
 
Join Date: Oct 2008
Posts: 609
Nikolay.Gekht is on a distinguished road
Quote:
Originally Posted by brenzosa
1) I am using Java using Groovy with Scriptom to get COM+ support which always dynamically links to the components.
Thank you for the information. We will try to reproduce the situation.

Quote:
Originally Posted by brenzosa
2) Sorry I didn't understand the question,...
Sorry, I thought faster than typed. The question was "How do you call..." However, all other responses describe situation clearly. Thank you and sorry again for the inconvenience.

Quote:
Originally Posted by brenzosa
3) No, I am calling from a different thread -- this used to work before the update so if this is a new requirement, then maybe that's the reason.
However, the call to GetPriceHistoryUTC() succeeds which is running on the same thread that calls CreateEntryOrder() (which subsequently fails)
Here is not any new requirement. The question was asked in order to reveal more details, since the error is related with cross-threading calls.
Reply With Quote
  #5 (permalink)  
Old 08-23-2009, 10:05 PM
Member
 
Join Date: Oct 2008
Posts: 609
Nikolay.Gekht is on a distinguished road
While we're trying to reproduce the situation, could you please ensure that:
1) The instances of the FXCore.CoreAut, FXCore.TradeDeskAut and all event sink (if you use it) objects are kept in the static fields of the application class in order to avoid premature releasing by the heap manager. I encountered such problems in environments with the automatic memory management.

2) You use the synchronization for all invocations of the TradeDeskAut class in order to avoid simultaneous calls of the TradeDeskAut interface from the concurrent threads.
Reply With Quote
  #6 (permalink)  
Old 08-25-2009, 11:43 AM
Member
 
Join Date: Oct 2008
Posts: 609
Nikolay.Gekht is on a distinguished road
We reproduced the problem with the invalid callee in the groovy. It looks like the VariantByref does not process the output variant values in the correct manner. We will look for the workaround. I'll keep you informed.
Reply With Quote
  #7 (permalink)  
Old 08-26-2009, 11:39 AM
Member
 
Join Date: Oct 2008
Posts: 609
Nikolay.Gekht is on a distinguished road
Yes, the version was confirmed.

Below is the code which surely brings the problem in any release of the O2GO
Code:
import org.codehaus.groovy.scriptom.*;
import com.jacob.com.Variant;

Scriptom.inApartment
{
  def core = new ActiveXObject('Order2Go.Core')
  def td = core.CreateTradeDesk('trader')

  println("Connecting...")
  td.Login("user", "password", "http://www.fxcorporate.com/Hosts.jsp", "Demo")
  println("Connected.")
  println(td.IsLoggedIn())

  def offer = td.FindMainTable("offers").Rows.Item(1)
  def account = td.FindMainTable("accounts").Rows.Item(1)

  def accountID = account.CellValue("AccountID")
  def amount = account.CellValue("BaseUnitSize")
  def instrument = offer.CellValue("Instrument")
  def bid = offer.CellValue("Bid")
  def ptsize = offer.CellValue("PointSize")
  def rate = bid - ptsize * 100
  def buy = true

  VariantByref order_id = new VariantByref("")
  VariantByref di = new VariantByref(false)

  println("Create an entry order...")
  td.CreateEntryOrder(accountID, instrument, buy, amount, rate, 0, 0, 0, order_id, di)
  println("Order is created")

  println(order_id.value)
  println(di.value)
}
CreateEntryOrder shall receive parameters order_id and di as VARIANT*. Scriptom sends it as BSTR* and VARIANT_BOOL* datatypes. As far as I can see from their code, they do not support VARIANT* parameters via VariantByref at all. You have to:
- ask Scriptom developers to provide the correct handling of the COM parameter
- choose other language or COM interop tool
- develop a simple COM-based workaround which provides the interface as Scriptom can call (really, this is a couple of hours of work).
BTW, I can develop such workaround for you if you aren't familiar with C++. Please, contact me to discuss this variant if you're interested.

Unfortunately, we cannot adopt the API for the whole heap of the products which has only limited support of the COM interface, so this fix can't be done directly in the API.
Reply With Quote
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off




Disclaimer: Trading foreign exchange on margin carries a high level of risk, and may not be suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to trade foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with foreign exchange trading, and seek advice from an independent financial advisor if you have any doubts. Any opinions, news, research, analyses, prices, or other information contained on this website is provided as general market commentary and does not constitute investment advice. Forex Capital Markets LLC. will not accept liability for any loss or damage, including without limitation to, any loss of profit, which may arise directly or indirectly from use of or reliance on such information.

All times are GMT -5. The time now is 10:26 AM.
Copyright ©2009 Daily FX. All Rights Reserved.