FXCM ForexConnectAPI

repository·master·Indexed 41 days ago

https://github.com/fxcm/forexconnectapi

An SDK for FXCM clients to automate trading, retrieve trading data, load price histories, and subscribe to real-time price streams. It supports multiple platforms including Windows, Linux, and Mobile, with API references available for C++, C#, Java, and Python.

Tokens
1.9K
Snippets
5
Records
9
Agent score
50%

What's inside ForexConnectAPI

  1. Compare Table Manager vs Non-Table Manager

    master

    The ForexConnectAPI provides two ways to handle data tables, each with different trade-offs:

    Table Manager

    • Mechanism: Preloads all tables into local memory as an in-memory representation of API tables.
    • Features: Allows you to subscribe to table change events (updates, adding rows, or removing rows). The SummaryTable is only accessible via the Table Manager.
    • Trade-off: Higher performance overhead because it constantly recalculates fields.

    Non-Table Manager

    • Mechanism: Captures table updates ad-hoc by implementing the IO2GResponseListener interface.
    • Features: Provides a performance advantage for high-frequency needs.
    • Trade-off: You are responsible for manually calculating certain fields, such as PipCost or P/L (Profit/Loss).
  2. Get started with ForexConnectAPI

    master

    To begin using the ForexConnectAPI for automated trading, market analysis, or data retrieval, follow these steps:

    1. Sign the EULA: You must first sign the EULA form.
    2. Obtain an Account: You need a FXCM TSII account. Demo accounts can be applied for here.
    3. Download the SDK: Download the ForexConnect SDK.
    4. Access Documentation: Examples and documentation are included in the ForexConnectAPI packages after installation. You can also refer to the Getting Started PDF.

    Supported Platforms & Languages:

    • Languages: C++, C#, Java, VB, VBA, Python.
    • Operating Systems: Windows, Linux, iOS, Android, macOS.

    Note on Deprecation: If you are using the O2G2 namespace, be aware that it has been deprecated since 2015 and may cause errors or compatibility issues.

  3. Access the full C++ API reference documentation

    master

    The C++ API reference contains over 1,500 pages. Because GitHub's web interface limits directory listings to 1,000 files, you may not see all documentation pages by browsing the repository on GitHub.com. To access the complete set of reference pages, use one of the following methods:

    1. Clone the repository: This is the most reliable way to get the full documentation locally.
    2. Search for specific files: Use the t key on any GitHub repository page to open the file finder and search for specific API filenames directly.
    3. Download as a ZIP: Use the 'Code' button on the main repository page to download the entire repository as a compressed archive.
    git clone https://github.com/fxcm/ForexConnectAPI.git
  4. Access the full DotNet API reference

    master

    The DotNet API reference contains over 1,600 pages. Because GitHub's web interface limits directory listings to 1,000 files, you may not see all documentation entries in the browser. To access the complete set of reference pages, use one of the following methods:

    1. Clone the repository: This is the most reliable way to ensure you have every file locally.
    2. Search for specific files: Use the t key on any GitHub repository page to open the file finder, allowing you to jump directly to a specific API reference by name.
    3. Download as ZIP: Use the 'Code' button on the main repository page to download the entire repository as a compressed archive.
    git clone https://github.com/fxcm/ForexConnectAPI.git
  5. Access the full Java API reference

    master

    The Java API documentation contains 1,538 reference pages. Because GitHub's web interface limits directory listings to 1,000 files, you may not see all documentation files by browsing the repository online. To access the complete set of API references, use one of the following methods:

    1. Clone the repository: This is the most reliable way to get all files locally.
    2. Search for specific files: Use the GitHub file finder (press t on any repository page) to jump directly to a specific filename.
    3. Download as a ZIP: Use the 'Code' button on the main repository page to download the entire repository as a compressed archive.
    git clone https://github.com/fxcm/ForexConnectAPI.git
  6. Access the full Python API reference

    master

    The Python API documentation consists of 1,240 reference pages. Because GitHub's web interface limits directory listings to 1,000 files, you may not see all documentation files by browsing the repository online. To access the complete set of documentation, use one of the following methods:

    1. Clone the repository: This is the most reliable way to get all files locally.
    2. Search for specific files: Use the t key on any GitHub repository page to open the file finder and search for specific filenames directly.
    3. Download as a ZIP: Use the 'Code' button on the main repository page to download the entire repository as a compressed archive.
    git clone https://github.com/fxcm/ForexConnectAPI.git
  7. Configure connection parameters for ForexConnectAPI

    master

    When establishing a connection to the ForexConnect API, use the following parameters:

    ParameterValue
    URLwww.fxcorporate.com/Hosts.jsp
    UsernameYour FXCM username
    PasswordYour FXCM password
    Connectiondemo (or your specific environment)

    Note: SessionID and PIN can be ignored during connection setup.

  8. Retrieve current account balance using Non-Table Manager

    master

    To get the current account balance, you must request the table from the server. The following example demonstrates how to use an O2GSession and O2GResponseReaderFactory to iterate through account rows and print the AccountID and Balance using the Non-Table Manager approach.

    Refer to the NonTableManagerSamples/PrintTable example in the SDK for full implementation details.

    private static O2GAccountRow GetAccount(O2GSession session)
    {
        O2GResponseReaderFactory readerFactory = session.getResponseReaderFactory();
        if (readerFactory == null)
        {
            throw new Exception("Cannot create response reader factory");
        }
        O2GLoginRules loginRules = session.getLoginRules();
        O2GResponse response = loginRules.getTableRefreshResponse(O2GTableType.Accounts);
        O2GAccountsTableResponseReader accountsResponseReader = readerFactory.createAccountsTableReader(response);
        for (int i = 0; i < accountsResponseReader.Count; i++)
        {
            O2GAccountRow accountRow = accountsResponseReader.getRow(i);
            Console.WriteLine("AccountID: {0}, Balance: {1}", accountRow.AccountID, accountRow.Balance);
        }
        return accountsResponseReader.getRow(0);
    }