Brokerages

Oanda

Introduction

QuantConnect enables you to run your algorithms in live mode with real-time market data. We have successfully hosted more than 200,000 live algorithms and have had more than $22B in volume traded on our servers since 2015.

Oanda was founded by Dr. Michael Stumm and Dr. Richard Olsen in 1995 with the goal to "transform all aspects of how the world interacts with currencies, whether that be trading or utilizing currency data and information". Oanda provides access to trading Forex and CFDs for clients in over 240 countries and territories with no minimum deposit. Oanda also provides demo accounts, advanced charting tools, and educational content

To view the implementation of the Oanda brokerage integration, see the Lean.Brokerages.OANDA repository.

Account Types

Oanda supports margin accounts. To set the account type in an algorithm, see the Oanda brokerage model documentation.

Create an Account

Follow the How to open an account page on the Oanda website to open an Oanda account.

You will need your account number and access token to deploy live algorithms. To get your account number, open the Account Statement page on the Oanda website. Your account number is formatted as ###-###-######-###. To get your access token, open the Manage API Access on the Oanda website.

Important note for European Union residents: On March 17th, 2023, OANDA Europe Markets Ltd. ("OEML") closed operations and transferred accounts to OANDA TMS Brokers S.A. ("OANDA TMS")1. OANDA TWS does not offer REST API endpoints for live trading. EU residents can trade with OANDA if they can open an account with another member of the OANDA Group, for example, US citizens.

Paper Trading

Oanda supports paper trading. Follow these steps to set up an Oanda paper trading account:

  1. Create an Oanda demo account.
  2. Log in to your demo account.
  3. On the Account page, in the My Services section, click Manage API Access.
  4. On the Your key to OANDA's API page, click Generate.
  5. Your access token displays. Store it somewhere safe. You need your access token to deploy an algorithm with your paper trading account.

  6. In the top navigation bar, click My Account.
  7. On the Account page, in the Manage Funds section, click View.
  8. On the My Funds page, in the Account Summary section, note your v20 Account Number.
  9. You need your v20 Account Number to deploy an algorithm with your paper trading account.

Asset Classes

Our Oanda integration supports trading Forex and CFDs.

Data Providers

The QuantConnect data provider providers Forex and CFD trading data during live trading.

Orders

We model the Oanda API by supporting several order types, a TimeInForce order instruction, and order updates. When you deploy live algorithms, you can place manual orders through the IDE.

Order Types

The following table describes the available order types for each asset class that our Oanda integration supports:

Order TypeForexCFD
Marketgreen checkgreen check
Limitgreen checkgreen check
Stop marketgreen checkgreen check

Time In Force

We model the GoodTilCanceledGOOD_TIL_CANCELED TimeInForce from the Oanda API.

Updates

We model the Oanda API by supporting order updates.

Fees

To view the Oanda trading fees, see the Our Charges and Fees page on the Oanda website. To view how we model their fees, see Fees.

Margin

We model buying power and margin calls to ensure your algorithm stays within the margin requirements.

Slippage

Orders through Oanda do not experience slippage in backtests. In paper trading and live trading, your orders may experience slippage.

To view how we model Oanda slippage, see Slippage.

Fills

We fill market orders immediately and completely in backtests. In live trading, if the quantity of your market orders exceeds the quantity available at the top of the order book, your orders are filled according to what is available in the order book.

To view how we model Oanda order fills, see Fills.

Settlements

Trades settle immediately after the transaction

To view how we model settlement for Oanda trades, see Settlement.

Security and Stability

Note the following security and stability aspects of our Oanda integration.

Account Credentials

When you deploy live algorithms with Oanda, we don't save your brokerage account credentials.

API Outages

We call the Oanda API to place live trades. Sometimes the API may be down. Check the Oanda status page to see if the API is currently working.

Deposits and Withdrawals

You can deposit and withdraw cash from your brokerage account while you run an algorithm that's connected to the account. We sync the algorithm's cash holdings with the cash holdings in your brokerage account every day at 7:45 AM Eastern Time (ET).

Demo Algorithm

The following algorithm demonstrates the functionality of the Oanda brokerage:

Deploy Live Algorithms

You must have an available live trading node for each live trading algorithm you deploy.

Follow these steps to deploy a live algorithm:

  1. Open the project you want to deploy.
  2. Click the Lightning icon Deploy Live icon.
  3. On the Deploy Live page, click the Brokerage field and then click Oanda from the drop-down menu.
  4. Enter your Oanda account Id and access token.
  5. To get your account ID and access token, see the Create an Account section in the Account Types documentation. Your account details are not saved on QuantConnect.

  6. Click the Environment field and then click one of the environments.
  7. The following table shows the supported environments:

    EnvironmentDescription
    RealTrade real money with fxTrade
    DemoTrade paper money with fxTrade Practice
  8. Click the Node field and then click the live trading node that you want to use from the drop-down menu.
  9. (Optional) In the Data Provider section, click Show and change the data provider or add additional providers.
  10. (Optional) Set up notifications.
  11. Configure the Automatically restart algorithm setting.
  12. By enabling automatic restarts, the algorithm will use best efforts to restart the algorithm if it fails due to a runtime error. This can help improve the algorithm's resilience to temporary outages such as a brokerage API disconnection.

  13. Click Deploy.

The deployment process can take up to 5 minutes. When the algorithm deploys, the live results page displays. If you know your brokerage positions before you deployed, you can verify they have been loaded properly by checking your equity value in the runtime statistics, your cashbook holdings, and your position holdings.

You can also see our Videos. You can also get in touch with us via Discord.

Did you find this page helpful?

Contribute to the documentation: