Git Product home page Git Product logo

andrew-drogalis / fx-order-management Goto Github PK

View Code? Open in Web Editor NEW
0.0 1.0 0.0 5.24 MB

An automated order management system for the Gain Capital API. Customize the trade parameters in the user_settings.json. Design your own trading model with the built in FXTradingModel Class.

License: GNU General Public License v3.0

CMake 1.81% C++ 81.18% C 15.20% Makefile 1.63% Shell 0.01% Dockerfile 0.17%

fx-order-management's Introduction

FX Order Management

Table of Contents

Getting Started

This repository is dependent upon the API from Gain Capital's Forex.com. To make an account visit their website Forex.com. Once an account is made you will need to send them an email and request an API key.

Downloading Dependencies

Please see a link to required dependencies below. If you are in Linux, Boost, OpenSSL, libsecret, & libmicrohttpd can be installed with the following commands below.

    Fedora:
        dnf install boost-devel openssl-devel libsecret-devel libmicrohttpd-devel
    Debian:
        apt-get install libboost-all-dev libssl-dev libsecret-1-dev libmicrohttpd-devel
    Arch: 
        pacman -Ss boost libmicrohttpd
        pacman -S --needed openssl
        pacman -Sy libsecret

Instructions

Running the Executable

The arguments to the main function are as follows:

./FX-Order-Management -a [Account Type], -p [Place Trades] -m [Max Retry Failures] -e [Emergency Close] -f [File Logging]
Types:
    Account Type: String - Must be "Live" or "Paper" 
    Place Trades: Boolean 
    Emergency Close: Boolean
    File Logging: Boolean 
    Max Retry Failures: Int 

The default settings in the main.cpp file are the following:

int main(int argc, char* argv[])
{
    // USER INPUT DEFAULTS
    std::string ACCOUNT = "PAPER";
    bool PLACE_TRADES = true, EMERGENCY_CLOSE = false, FILE_LOGGING = true;
    int MAX_RETRY_FAILURES = 3;
    ...

Storing User Credentials

The user should replace the usernames and API key, but the password should not be stored in plain text. The program will prompt the user to assign a new password if one doesn't already exist in the keyring.

{
    "Username": "Blank",
    "Paper_Username": "Blank",
    "API_Key": "Blank",
    "Positions": [
        "USD/JPY",
        "EUR/USD",
        "USD/CHF",
        "USD/CAD"
    ],
    "Order_Size": 1000,
    "Update_Interval": "Minute",
    "Update_Span": 5,
    "Num_Data_Points": 10000,
    "Start_Hour_London_Exchange": 8,
    "End_Hour_London_Exchange": 20
}
Types:
    Order_Size: Intervals of 1,000;
    Update_Interval: Minute or Hour;
    Update_Span: MINUTES: 1, 2, 3, 5, 10, 15, 30; HOURS: 1, 2, 4, 8;
    Start_Hour_London_Exchange: 0 - 24; All local times are adjusted to coordinate with the London Forex Exchange;
    End_Hour_London_Exchange: 0 - 24; All local times are adjusted to coordinate with the London Forex Exchange;

Updating Order Parameters

The user can replace the order parameters with any valid combination as described in the Gain Capital API documents. In the case of a typo, the code provides appropriate checks to confirm the user is compliant with the documentation.

Setting Password in Keyring

User will be prompted the first time they use the application. The password will be stored securely in the keyring and automatically loaded for the next use.

Updating Trading Model

Please don't run in a live trading environment with the placeholder trading model provided. The user should modify with their own trading strategy.

int FXTradingModel::send_trading_signal()
{
    // Replace with User's Code 
    return (rand() % 2) ? 1 : -1;
}

Profitability Reports

{
    "Last Updated": "Thu Feb  1 14:04:06 2024",
    "Performance Information": 
    {
        "Current Funds": 45884.16,
        "Inital Funds": 45887.76,
        "Margin Utilized": 121.73,
        "Profit Cumulative": -3.59,
        "Profit Percent Cumulative": -0.0
    },
    "Position Information": 
    {
        "EUR/USD": 
        {
            "Current Price": 1.087210,
            "Direction": "buy",
            "Entry Price": 1.08727,
            "Profit": -5.999999e-05,
            "Profit Percent": -0.009999,
            "Quantity": 1000.0
        },
        "USD/CAD": 
        {
            "Current Price": 1.337329,
            "Direction": "buy",
            "Entry Price": 1.33754,
            "Profit": -0.000209,
            "Profit Percent": -0.019999,
            "Quantity": 1000.0
        }
    }
}

Closing Trades Manually

Changing the value to true will either close the trade immediately upon the update interval, or wait until the trading model signal changes.

{
    "EUR/USD": 
    {
        "Close_Position": false,
        "Position_Size_Multiple": 1.0
    },
    "USD/CAD": 
    {
        "Close_Position": false,
        "Position_Size_Multiple": 1.0
    }
}
Types:
    Close_Position: true or false; Closes position at next update interval;
    Position_Size_Multiple: Any Double Number; Changes the quantity relative to the Order_Size;

Building Executable

    $ mkdir build
    $ cmake -S . -B build
    $ cmake --build build --target FX-Order-Management

Dependencies

This repository contains a .devcontainer directory. The .devcontainer has all the required dependencies and can be run inside Docker with the Dev Containers VSCode extension.

Included In Repository

User Install Required

License

This software is distributed under the GNU license. Please read LICENSE for information on the software availability and distribution.

Contribution

Please open an issue of if you have any questions, suggestions, or feedback.

Please submit bug reports, suggestions, and pull requests to the GitHub issue tracker.

fx-order-management's People

Contributors

andrew-drogalis avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.