ForexConnect-Python released

Moderator: Moderator

ForexConnect-Python released

Postby Konstantin.Toporov » Tue Oct 02, 2018 10:11 am

We have developed a wrapper allowing to use ForexConnect with python.

ForexConnect API Python provides an ability to create analytics and trading applications in Python.
Functionality of ForexConnect API includes: downloading historical prices,
creating all of the available order types, getting offers, managing positions, getting account reports, and more.

To use ForexConnect API, you need to have an account with the FXCM Group.

Documentation and Support
===============================================================================

Sample scripts for ForexConnect API:
https://github.com/gehtsoft/forex-conne ... er/samples

Online ForexConnect API documentation:
http://fxcodebase.com/bin/forexconnect/ ... ntent.html

License:
http://fxcodebase.com/licenses/forexconnect/eula.html

Prerequisites
===============================================================================

Operating system: Windows 7 or newer, Mac OS X High Sierra, CentOS 7, Ubuntu 18.04.
The package is available for Python 3.5, 3.6, 3.7.


Installation of ForexConnect API
===============================================================================

To install ForexConnect API from PyPI repository:

With Python added to the PATH Environmental Variable,

1. Install the forexconnect library:
python -m pip install forexconnect

2. Install all the required dependencies from requirements.txt:
python -m pip install -r requirements.txt

You can find requirements.txt file on GitHub:
https://github.com/gehtsoft/forex-conne ... ements.txt
Konstantin.Toporov
FXCodeBase: Initiate
 
Posts: 113
Joined: Mon Aug 31, 2015 10:16 am

Re: ForexConnect-Python released

Postby Cactus » Mon Apr 08, 2019 4:02 pm

Amazing. I will use this a lot soon.
One question, are you aware of anything special this API Python wrapper can do compared to FXCM REST Api "fxcmpy" ? Are they both same thing? REST asks for token verification but forexconnect no. Other than that they both do the same things or is forexconnect better for something particular? All can place trades, get report, download historical data, manage positions. Is one quicker than the other?
Never chase the money, let the money come to me
User avatar
Cactus
FXCodeBase: Graduate
 
Posts: 239
Joined: Fri Feb 19, 2016 11:46 am
Location: Errywhere

Re: ForexConnect-Python released

Postby Konstantin.Toporov » Mon Apr 08, 2019 6:30 pm

Both API generally do the same.
FC API is a bit heavier and does a bit more: for example, calculates balances, PL and other dynamic properties.
Konstantin.Toporov
FXCodeBase: Initiate
 
Posts: 113
Joined: Mon Aug 31, 2015 10:16 am

Re: ForexConnect-Python released

Postby Sdoof2708 » Wed Sep 02, 2020 7:53 pm

Thanks so much for making this package available Konstantin.

It seems there is timestamp bug when it comes to Tick, because the timestamp for each update is not set to milliseconds, only showing the seconds.

As pointed out on github, I currently get the following timestamps.
2019-06-24 19:13:43
2019-06-24 19:13:43
2019-06-24 19:13:43
2019-06-24 19:13:43
2019-06-24 19:13:43

Should be something like this.
2019-06-24 19:13:43.022
2019-06-24 19:13:43.053
2019-06-24 19:13:43.068
2019-06-24 19:13:43.070

This is a fairly critical bug because there is no way to eliminate 'out of order' ticks/updates, what is the best way to fix this?
Code: Select all
import pandas as pd
import datetime
import csv
import numpy as np
data_file='C:\\Users\\FOREXCONNECT_DB.csv'

from forexconnect import fxcorepy, ForexConnect


def session_status_changed(session: fxcorepy.O2GSession,
                           status: fxcorepy.AO2GSessionStatus.O2GSessionStatus):
    print("Trading session status: " + str(status))


def main():
    with ForexConnect() as fx:
        try:
            fx.login(REAL_ACCOUNT_ID, PASSWORD, "fxcorporate.com/Hosts.jsp",
                     "Real", session_status_callback=session_status_changed)
            history = fx.get_history("EUR/USD", "t1",
                                     datetime.datetime.strptime("08.06.2020 17:51:21.000", '%m.%d.%Y %H:%M:%S.%f').replace(
                                         tzinfo=datetime.timezone.utc),
                                     datetime.datetime.strptime("08.06.2020 18:00:21.000", '%m.%d.%Y %H:%M:%S.%f').replace(
                                         tzinfo=datetime.timezone.utc))
            np.savetxt(data_file, history, delimiter=",")

            print("Date, Bid, Ask")
            for row in history:
                print("{0:s}, {1:,.5f}, {2:,.5f}".format(
                    pd.to_datetime(str(row['Date'])).strftime('%m.%d.%Y %H:%M:%S.%f'), row['Bid'], row['Ask']))
                    # row['BidLow'], row['BidClose'], row['Volume']))

        except Exception as e:
            print("Exception: " + str(e))

        try:
            fx.logout()
        except Exception as e:
            print("Exception: " + str(e))


if __name__ == "__main__":
    main()

Sdoof2708
 
Posts: 2
Joined: Sun Aug 23, 2020 10:02 am


Return to ForexConnect-Python API

Who is online

Users browsing this forum: No registered users and 1 guest