neka-nat / python-forexconnect

Python binding of forexconnect api
40 stars 24 forks source link

Logs #1

Closed ehault closed 8 years ago

ehault commented 8 years ago

Hi there, I am really interested by what you have done here!

small stuff: you actually need a export LD_LIBRARY_PATH=pathtoForexConnectAPI/lib/ before using python or you will get: Traceback (most recent call last): File "<stdin>", line 1, in <module> ImportError: XXX.so: cannot open shared object file: No such file or directory (or possibly move them to /usr/local/lib or smth)

Could you add some logs?

I fail on login with RuntimeError: Login fail. and am sure the credentials are correct.

Cheers!

neka-nat commented 8 years ago

Thank you, Lepthy. The message, RuntimeError: Login fail., means python importing is ok, but login session can't get login status. If you create login session normally, you get the message, [2015-11-27 23:54:04.805880] [0x60d53740] [info] status::connecting before runtime error.

Did you get this message?

ehault commented 8 years ago

Yes importing works fine.

I do no get the [2015-11-27 23:54:04.805880] [0x60d53740] [info] status::connecting message =( the credentials are the same as those from the webapp right?

neka-nat commented 8 years ago

No, status::connecting message means only connecting login session. If credentials are correct, you get the message like this,

[2015-11-27 23:53:31.735702] [0x60d53740] [info]    status::connecting
[2015-11-27 23:53:33.216418] [0x3be3b700] [info]    status::connected

If credentials are wrong, you get the message like this,

[2015-11-28 00:56:59.414207] [0x60d53740] [info]    status::connecting
[2015-11-28 00:57:00.100241] [0x3be3b700] [error]   Login error:...

Can I see your executed python code and the full log?

ehault commented 8 years ago

Python 2.7.6 (default, Jun 22 2015, 17:58:13) [GCC 4.8.2] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import forexconnect >>> cl = forexconnect.ForexConnectClient(<account>, <passzord>, "Real") [2015-11-27 17:56:31.532988] [0x92639740] [info] status::connecting Traceback (most recent call last): File "<stdin>", line 1, in <module> RuntimeError: Login fail.

This is just taken from your example, did i miss something obvious? (i logged into the webinterface using the same account&password with success)

neka-nat commented 8 years ago

Thank you. I think the connected URL is wrong. I wrote the URL in forexconnect/src/ForexConnectClient.cpp:8

static std::string FOREX_URL = "http://www40.fxcorporate.com/Hosts.jsp";

If you know the URL you should access, can you try to change the URL and re-install?

If you don't know the URL, please try to execute original cpp samples.

cd ForexConnectAPI/samples/cpp/NonTableManagerSamples/Login/
./fxbuild.sh
cd bin
./Login -l <your account> -p <your password> -u http://www40.fxcorporate.com/Hosts.jsp -c Real
ehault commented 8 years ago

Still no luck it seems

Running Login with arguments: 7200106621 * www.fxcorporate.com/Hosts.jsp Real status::connecting Login error: 19915;DAS 19915: ZDas Exception ORA-20101: Wrong user name or password ORA-06512: at "E10R2.API", line 429 ORA-06512: at line 1 status::disconnected Segmentation fault (core dumped)

Good thing is, it's not in your code, ill contact the support, thanks!

neka-nat commented 8 years ago

Thank you.

heliosDI commented 8 years ago

Hi neka-nat, starting off I would like to thank you for the great work you are doing. Excellent job!

Currently I am running into a similar issue as the one described by Lepthy. When connecting to my demo account with forexconnect I get the following error message:

cl = forexconnect.ForexConnectClient("myusername","mypassword","Demo") [2016-01-24 15:44:54.803018] [0xacc76740] [info] status::connecting Traceback (most recent call last): File "", line 1, in RuntimeError: Login fail.

I followed your previous advice to execute the original cpp samples and the connection works fine. Any idea what could be the issue here?

Thanks in advance

neka-nat commented 8 years ago

Hi peterhilde, I'd like you to check the connected URL. I changed how to change the URL. In the latest version, you can change the URL using cmake. Please try the following command.

cd build
cmake .. -DDEFAULT_FOREX_URL="Correct URL"
make install
heliosDI commented 8 years ago

Hi neka-nat, thanks for the quick reply. I followed your advice to set the URL manually but unfortunately I am getting the same error. When executing the cpp samples directly I use the default URL and that works nicely. Is there any way to print the used URL to make sure it is correctly forwarded internally? Cheers

neka-nat commented 8 years ago

I update this repository and in the latest version, you can print the used URL to check login parameters. Can you try the following script?

import forexconnect
forexconnect.set_log_level(forexconnect.LOG_DEBUG)
forexconnect.ForexConnectClient("myusername","mypassword","Demo")
heliosDI commented 8 years ago

Unfortunately no luck so far. I was able to run your updated code and it appears that the credentials are correct. Unfortunately I am not an expert in C++ otherwise I could do some debugging myself. Any other suggestion to solve the issue would be appreciated. Some other observation I am making: When logging in to the demo account with the cpp samples directly I get the following:

status::connecting status::connected AccountID: ---, Balance: ---, Used margin: --- Done! status::disconnecting status::disconnected

Is the immediate disconnection to be expected?

neka-nat commented 8 years ago

It's working for the cpp samples. I update this repository again to add traceable logs. Can you try the following script again and send the feedback?

import forexconnect
forexconnect.set_log_level(forexconnect.LOG_TRACE)
forexconnect.ForexConnectClient("myusername","mypassword","Demo")
heliosDI commented 8 years ago

This is what I get:

cl = forexconnect.ForexConnectClient('_','_','Demo') [2016-01-26 17:41:39.388344] [0xc80fd740] [trace] void pyforexconnect::SessionStatusListener::reset() [2016-01-26 17:41:39.388363] [0xc80fd740] [trace] virtual long int pyforexconnect::SessionStatusListener::addRef() [2016-01-26 17:41:39.388368] [0xc80fd740] [trace] void pyforexconnect::SessionStatusListener::reset() [2016-01-26 17:41:39.388372] [0xc80fd740] [debug] user name: [2016-01-26 17:41:39.388375] [0xc80fd740] [debug] password: [2016-01-26 17:41:39.388378] [0xc80fd740] [debug] url: http://www40.fxcorporate.com/Hosts.jsp [2016-01-26 17:41:39.388381] [0xc80fd740] [debug] connection: Demo [2016-01-26 17:41:39.388390] [0xc80fd740] [trace] virtual long int pyforexconnect::SessionStatusListener::addRef() [2016-01-26 17:41:39.388394] [0xc80fd740] [trace] virtual void pyforexconnect::SessionStatusListener::onSessionStatusChanged(IO2GSessionStatus::O2GSessionStatus) [2016-01-26 17:41:39.388398] [0xc80fd740] [info] status::connecting [2016-01-26 17:41:39.388401] [0xc80fd740] [trace] virtual long int pyforexconnect::SessionStatusListener::release() [2016-01-26 17:41:39.388559] [0xc80fd740] [trace] bool pyforexconnect::SessionStatusListener::waitEvents()

ehault commented 8 years ago

Just dropping by to say that I am following this!

heliosDI commented 8 years ago

Lephty, glad to hear this might be of relevance to you as well. I highly appreciate the effort neka-nat puts into this one!

neka-nat commented 8 years ago

Thank you, peterhilde. I checked the log message but I have't understood why it wasn't working yet. I will prepare some test programs and want you to execute them in your environment to solve this issue. Please, wait for several days.

neka-nat commented 8 years ago

I updated this repository to add checking login code. Can you try to make and execute a program? Please send me the logs.

make
cd forexconnect
./login <username> <password> <url> <Real/Demo>
joaofranca commented 8 years ago

Just a probably related quote from a recent chat I had with a FXCM person:

"All other servers except servers in Japan TY3 data center, should use http://www.fxcorporate.com/Hosts.jsp "

heliosDI commented 8 years ago

Below the output when I run ./login. The programme gets kind of stuck as it does not return to the command line. I waited several minutes without any change. It does not make a difference if I use http://www.fxcorporate.com/Hosts.jsp or http://www40.fxcorporate.com/Hosts.jsp although both domains work when running the cpp samples directly.

[2016-02-01 22:06:46.616604] [0x267c1780] [trace] void SessionStatusListener::reset() [2016-02-01 22:06:46.616652] [0x267c1780] [trace] virtual long int SessionStatusListener::addRef() [2016-02-01 22:06:46.616659] [0x267c1780] [trace] void SessionStatusListener::reset() [2016-02-01 22:06:46.616672] [0x267c1780] [trace] virtual long int SessionStatusListener::addRef() [2016-02-01 22:06:46.616680] [0x267c1780] [trace] virtual void SessionStatusListener::onSessionStatusChanged(IO2GSessionStatus::O2GSessionStatus) [2016-02-01 22:06:46.616685] [0x267c1780] [info] status::connecting [2016-02-01 22:06:46.616690] [0x267c1780] [trace] virtual long int SessionStatusListener::release() [2016-02-01 22:06:46.616799] [0x267c1780] [trace] bool SessionStatusListener::waitEvents() [2016-02-01 22:07:16.616909] [0x267c1780] [trace] virtual long int SessionStatusListener::release() [2016-02-01 22:07:16.616927] [0x267c1780] [trace] virtual long int SessionStatusListener::release()

neka-nat commented 8 years ago

Thank you, peterhilde and joaofranca! I found a bug and fixed it. Please update repository and try to execute "login" program again.

ehault commented 8 years ago

nice to hear that! ill check that when i get home

Cordialement,

Thibault LEPEU Epitech 2015

On Tue, Feb 2, 2016 at 3:32 PM, neka-nat notifications@github.com wrote:

Thank you, peterhilde and joaofranca! I found a bug and fixed it. Please update repository and try to execute "login" program again.

— Reply to this email directly or view it on GitHub https://github.com/neka-nat/python-forexconnect/issues/1#issuecomment-178599352 .

heliosDI commented 8 years ago

Hi neka-nat, thanks for the update. Unfortunately I am getting the same output. Maybe some of the other followers can confirm/disconfirm.

joaofranca commented 8 years ago

Perhaps the problem is system related. I mean something external like a library version (for instance, boost), gcc, etc. I've recently deployed this to a remote cloud machine from scratch without any problems.

For reference, I used a clean Ubuntu 14.04 instance.

heliosDI commented 8 years ago

Good point joaofranca, I just installed the API as well as the current project on another computer running Ubuntu 14.04. Unfortunately getting the same error. Seems to be a difficult one.

joaofranca commented 8 years ago

From a clean Ubuntu 14.04 install can you setup the project like this:

Update Ubuntu

sudo add-apt-repository -y "deb http://archive.ubuntu.com/ubuntu/ trusty main universe"
sudo apt-get update -qq

Install Boost, cmake and build-essential

sudo apt-get install build-essential sudo apt-get install cmake sudo apt-get install libboost-log-dev libboost-date-time-dev libboost-python-dev

Get and Setup ForexConnect

wget http://fxcodebase.com/bin/forexconnect/1.3.2/ForexConnectAPI-1.3.2-Linux-x86_64.tar.gz
tar xvf ForexConnectAPI-1.3.2-Linux-x86_64.tar.gz
mv ForexConnectAPI-1.3.2-Linux-x86_64 ForexConnectAPI
export FOREXCONNECT_ROOT=$(pwd)/ForexConnectAPI
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$(pwd)/ForexConnectAPI

Get and Setup python-forexconnect

git clone https://github.com/neka-nat/python-forexconnect.git
cd python-forexconnect
mkdir build
cd build
cmake ..
sudo make install

Notes: The python-forexconnect library will be installed for the default python (be it the system one or the anaconda if it is set as the default in the PATH, you can check which one will be used with 'which python').

Setup /etc/environment

sudo nano /etc/environment

Add the following lines to the file and save (note that the paths to the linked folders may differ from this example):

FOREXCONNECT_ROOT=/home/vagrant/ForexConnectAPI
LD_LIBRARY_PATH=/home/vagrant/ForexConnectAPI/lib:/home/vagrant/git/python-forexconnect/build/forexconnect/sample_tools/lib

Load changes: source /etc/environment

Test

You are good to go, test by launching a python interactive shell and executing the following code (no errors should occur):

import forexconnect
cl = forexconnect.ForexConnectClient("login", "pass", "Demo", "http://www.fxcorporate.com/Hosts.jsp")
cl.open_position("EUR/USD", forexconnect.BUY, 1)
ti = cl.get_trades()
cl.close_position(ti[0].trade_id)
cl.logout()

This is exactly what I've done. If it doesn't work, maybe it's a network related problem?

heliosDI commented 8 years ago

Thanks for the extensive documentation, much appreciated. Yesterday evening I tried to follow the described steps but ended up at the same point. I must admit I did not find the time yet to install ubuntu from scratch. I will also follow the procedure on another Linux machine at a different location so network related issues can possibly excluded.

neka-nat commented 8 years ago

It's difficult issue... If you are pretty good at c++, can you try to analyze difference between my login test code and the original login sample code? The two programs are much the same.

heliosDI commented 8 years ago

Gents, I am still looking into it although I am not very familiar with c++. To me it appears that the actual login (session->login(login.c_str(), pass.c_str(), url.c_str(), connection.c_str());) fails as statusListener->isConnected() returns 0 afterwards. Can you tell me where the source file for session->login is located and if it is the same in the original samples and the python wrapper? If that's the case, it really should be input related although the login, pass, url and connection seem to be correct. I wonder if the data type of these variables might not be interpreted correctly on my system. Anyway, a hint where to find the respective source code would help already. Thx

neka-nat commented 8 years ago

I meant my login test code was for generating ./login executable file. I compared the following files,

I have found the following differences,

I guess these differences are the causes of this issue.

heliosDI commented 8 years ago

I got good news as I got it working! The bad news is I have no idea what the problem was. Together with a friend we successfully compiled the project on two of his machines and we tried to identify possible differences to my setup. At the end I removed all related data from my system and re-compiled without any issues. I really appreciate supports and apologise for the fact that I cannot explain what the apparent issue was.

ehault commented 8 years ago

Hi, ill install on brand new server, will report

ehault commented 8 years ago

Got it working on new server with new account, log seem clear! Time to code (: Thanks for everything

Cordialement,

Thibault LEPEU Epitech 2015

On Sun, Feb 14, 2016 at 6:11 PM, peterhilde notifications@github.com wrote:

I got good news as I got it working! The bad news is I have no idea what the problem was. Together with a friend we successfully compiled the project on two of his machines and we tried to identify possible differences to my setup. At the end I removed all related data from my system and re-compiled without any issues. I really appreciate supports and apologise for the fact that I cannot explain what the apparent issue was.

— Reply to this email directly or view it on GitHub https://github.com/neka-nat/python-forexconnect/issues/1#issuecomment-183929588 .

neka-nat commented 8 years ago

Thanks, Lepthy and peterhilde! I'm grad to work it and thank you for working together.