|
|
 |

06-03-2009, 11:36 PM
|
|
Member
|
|
Join Date: Nov 2008
Posts: 5
|
|
|
UK login - OpenTrade() timesout
I have my custom application working fine with real US account and demo accounts.
When I tried the UK account today I was able to login but not able to place trades. The "OpenTrade()" function hangs and eventually times out.
I have enabled the multi-sessionl logins enabled and am using the 7 character account number also.
Any insight? I am guessing this is a setting that it might be related to some setting to enable API based trading.
|

06-05-2009, 12:30 PM
|
|
Member
|
|
Join Date: Oct 2008
Posts: 465
|
|
|
Is Trade Station able to work successfully for this account at the same moment of time?
|

06-05-2009, 02:32 PM
|
|
Member
|
|
Join Date: Dec 2006
Posts: 22
|
|
|
I have the same problem
I can get the demo accounts to work perfectly (both standard and micro) with my custom app, but it hangs with the Standard Real account. Trading Station with the accounts works perfectly.
I'm Stumped. Why does it work with my demo account but not my real account?
Dr. Mark
|

06-05-2009, 03:00 PM
|
|
Member
|
|
Join Date: Oct 2008
Posts: 465
|
|
|
Could you provide me, please:
1) The name of connection
2) The URL you use for the connection
(i.e. the last two parameters of the login method)
3) The programming language you use (to provide an example on your language).
Unfortunately, the market is about to be closed, so I will be able to test and provide the solution only the next Monday.
|

06-05-2009, 04:23 PM
|
|
Member
|
|
Join Date: Nov 2008
Posts: 5
|
|
I can place trades with the Trading Station. With the API I am able to login but when I try to place a trade OpenTrade() does nothing.
I am using C# as my programming language. Again, the same application works fine with US based real accounts (I tried 2 of them) and all demo accounts.
The problem is only with my UK real account.
The values you have asked for are:
1)Connection = Real
2)url = www.fxcorporate.com
3)Programming Language = C#
|

06-05-2009, 04:47 PM
|
|
Member
|
|
Join Date: Nov 2008
Posts: 5
|
|
Here is the information you have asked for:
1) Connection = Real
2) URL = www.fxcorporate.com
3) Programming Language = C#
I am able to trade using Trading Station using this new UK account.
Also just to repeat what I have said earlier, I am able trade with my application using two US real accounts.
With UK account the login works but OpenTrade() function hangs.
|

06-06-2009, 12:20 AM
|
|
Member
|
|
Join Date: Dec 2006
Posts: 22
|
|
|
this is how I login
I use VB.net
Dim DemoOrReal as String
If myType = "R" Then
DemoOrReal = "Real"
Else
DemoOrReal = "Demo"
End If
Try
tradeDesk = core.CreateTradeDesk("trader")
tradeDesk.Login(myLogin, myPassword, "http://www.fxcorporate.com", DemoOrReal)
.
.
.
Hope this helps
DrMark
Last edited by DrMark; 06-07-2009 at 06:27 PM..
|

06-06-2009, 09:36 AM
|
|
Member
|
|
Join Date: Nov 2008
Posts: 5
|
|
I posted couple of messages already with my answers to your questions. I don't see that it is showing up in my thread. I will try again.
1) Connection = Real
2) URL = www.fxcorporate.com
3) Programming Language = C#
The problem is only with UK account.
I can place trades using Trading Station.
US real accounts (2) and demo accounts all work fine with the same code.
|

06-07-2009, 06:35 PM
|
|
Member
|
|
Join Date: Dec 2006
Posts: 22
|
|
Just Tested Again - NO LUCK
After the weekend, I just tested my REAL account again and I still have the same Hang on OpenTrade. I have no problem logging on and reading my account balance. The problem is only with openning a trade.
Here is the line of code that hangs......
tradeDesk.OpenTrade(lblAccount.Text, strPair, IsBuy, strAmt, MarketRate, _
QuoteID, 20, 0, 0, 0, OrderID, DealerInt)
IsBuy is a boolean
MarketRate is a Double
QuoteID as a String
OrderID and DealerInt are Objects
Hope this gives you everything you need for diagnosis. I am still stumped.
Dr. Mark
|

06-08-2009, 02:02 PM
|
|
Member
|
|
Join Date: Oct 2008
Posts: 465
|
|
I checked the OpenTrade method on all available for me accounts on UK and US Real databases. The only situation when I can reproduce the hangs is when the wrong account id is specified. Please find the working example below. Pay attention to the lines in bold. If you will comment the first bolded line and uncomment the last, the example will hang. It is a usual problem to use account_name instead of account_id. For some databases these fields may contain the same values, but for some may not.
If this does not help, please send me the login name (I don't need a password, only the login name to find out the database where the associated account is located).
Code:
class Program
{
/// <summary>
/// Instance of the O2GO core.
///
/// It is strongly recommended to keep the core instance in
/// the static or instance property of the class instead of
/// local variable.
/// </summary>
static FXCore.CoreAut mCore;
/// <summary>
/// Instance of the O2GO Trade Desk.
///
/// It is strongly recommended to keep the core instance in
/// the static or instance property of the class instead of
/// local variable.
/// </summary>
static FXCore.TradeDeskAut mDesk;
static void Main(string[] args)
{
if (args.Length != 4)
{
Console.WriteLine("Usage: opentrade_sample user password url connection");
return;
}
try
{
//Create an instance of O2GO core
mCore = new FXCore.CoreAut();
//Create an instance of O2GO core
mDesk = (FXCore.TradeDeskAut)mCore.CreateTradeDesk("trader");
}
catch (Exception e)
{
Console.WriteLine("Creation of O2GO objects failed");
Console.WriteLine("{0}", e.ToString());
return ;
}
try
{
mDesk.Login(args[0], args[1], args[2], args[3]);
}
catch (Exception e)
{
Console.WriteLine("Login failed");
Console.WriteLine("{0}", e.ToString());
return;
}
try
{
//account information
string account_id;
string account_name;
int min_amount;
//qoute information
string instrument;
double rate;
string quote_id;
try
{
//find the account information for the trade
FXCore.TableAut accounts = (FXCore.TableAut)mDesk.FindMainTable("accounts");
//...and get the account identifier, printable account name and
// minimal amount for the trade for the first existing account
account_id = (string)accounts.CellValue(1, "AccountID");
account_name = (string)accounts.CellValue(1, "AccountName");
min_amount = (int)accounts.CellValue(1, "BaseUnitSize");
}
catch (Exception e)
{
Console.WriteLine("Failed to get the account information");
Console.WriteLine("{0}", e.ToString());
return;
}
try
{
//find the quote information
FXCore.TableAut offers = (FXCore.TableAut)mDesk.FindMainTable("offers");
//get the instrument name, the current rate and quote identifier for the
//first available instrument.
instrument = (string)offers.CellValue(1, "Instrument");
rate = (double)offers.CellValue(1, "Ask");
quote_id = (string)offers.CellValue(1, "QuoteID");
}
catch (Exception e)
{
Console.WriteLine("Failed to get the quote information");
Console.WriteLine("{0}", e.ToString());
return;
}
object order_id = null, di = null;
try
{
//open the trade at the fixed rate
mDesk.OpenTrade(account_id, instrument, true, min_amount, rate, quote_id, 0, 0, 0, 0, out order_id, out di);
//the code above works, but the code below hangs
//mDesk.OpenTrade(account_name, instrument, true, min_amount, rate, quote_id, 0, 0, 0, 0, out order_id, out di);
}
catch (Exception e)
{
Console.WriteLine("Failed to open the order");
Console.WriteLine("{0}", e.ToString());
return;
}
Console.WriteLine("Order {0} to buy {1} lots of {2} for {3} on account {4} is created",
order_id, min_amount, instrument, rate, account_name);
//wait while the trade appeared in the table, but no more than
//5 seconds
string trade_id = null;
long start_time = DateTime.Now.Ticks;
FXCore.TableAut trades = (FXCore.TableAut)mDesk.FindMainTable("trades");
while (trade_id == null)
{
if ((DateTime.Now.Ticks - start_time) > 500000000000)
{
Console.WriteLine("5 second timeout to wait for the trade exceeded");
return;
}
try
{
FXCore.RowAut row = (FXCore.RowAut)trades.FindRow("OpenOrderID", order_id, 0);
trade_id = (string)row.CellValue("TradeID");
}
catch (Exception )
{
//the trade is not found
Thread.Sleep(250);
}
}
Console.WriteLine("The ticket is {0}", trade_id);
//and the close the trade by the current market price
try
{
mDesk.CloseTrade(trade_id, min_amount, 0, "", 0, out order_id, out di);
}
catch (Exception e)
{
Console.WriteLine("Close trade operation is failed");
Console.WriteLine("{0}", e.ToString());
return;
}
Console.WriteLine("The trade {0} is closed by order {1}", trade_id, order_id);
}
finally
{
mDesk.Logout();
}
}
}
|

06-09-2009, 12:56 AM
|
|
Member
|
|
Join Date: Dec 2006
Posts: 22
|
|
Getting close to the answer -- I think
I think we may have found something. This is the code I use to create the core object. I copied it from the example program (LoginAndTrade) supplied with the API download and then modifed it for VB.NET.
Private core as Object
.
.
.
Private Function CreateCore() As Boolean
Try
core = CreateObject("Order2Go.core")
CreateCore = True
Catch ex As Exception
Throw ex
End Try
End Function
I also tried your C# test console program in Visual Studio and successfully executed a trade in my real account while I watched it from TS. Now I will adjust my program to look like yours and I think we will have this one solved. Thanks so much for your help !!!!!!! Now all we have to do is get the API to work with Micro Accounts.
DrMark
Last edited by DrMark; 06-09-2009 at 01:47 AM..
|

06-09-2009, 05:31 PM
|
|
Member
|
|
Join Date: Oct 2008
Posts: 465
|
|
|
Just to note:
The code of the instantiation above will work but has one small lack. When "core" is declared as an "Object" and then created via CreateObject("...") - the compiler-time type checking and intellisense technology in which could prevent a lot of programming problems will not work in Microsoft Visual Studio IDE.
For example, if you write
"core.MakeTradeDesk" instead of "core.CreateTradeDesk" - the code above will fail at the execution time, but when you will use project references and declaration in the form: "Dim core as FXCore.CoreAut", the error will be found during the compilation time. This can save your time during the application writing and debugging.
...OLE Automation API in the Windows provides too much variants to do the same things but sometimes helps developers to have "...two ways to tie shoes. One way is only good for lying down. The other way is good for walking." ((c) R.A. Heinlein, Stranger in a Strange Land).
Last edited by Nikolay.Gekht; 06-09-2009 at 05:35 PM..
|

06-09-2009, 08:24 PM
|
|
Member
|
|
Join Date: Dec 2006
Posts: 22
|
|
I don't believe this
Thank you Nikolay.Gekht
I just had my first opportunity to test my MICRO REAL account with your C# console program. I logged into TS and then started VS to run your program. To my surprise, everything worked. I was able to use a multi-login with a Micro account (contrary to what FXCM support says).
I could not be happier. I can easily transfer the login to my own custom program from here. I just wish the samples programs were updated when API changes are made. That would have saved me a lot of grief.
Again, many thanks for your help Nikolay.
I hope SuryaFXCM also reads this thread. I am sure it will also solve all his problems.
Best regards,
Dr.Mark
|

06-27-2009, 08:29 PM
|
|
Member
|
|
Join Date: Nov 2008
Posts: 5
|
|
|
I had the "AccountNumber and "AccountName" values swapped and that is why it was not opening the trades.
I got it working.
Thanks for all you help!
|
 |
| Thread Tools |
|
|
| 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
HTML code is Off
|
|
|
|