Brokerages
CFD and FOREX Brokerages
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.
QuantConnect integrates with OANDA for CFD and FOREX trading. 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:
- Create an OANDA demo account.
- Log in to your demo account.
- On the Account page, in the My Services section, click .
- On the Your key to OANDA's API page, click .
- In the top navigation bar, click .
- On the Account page, in the Manage Funds section, click .
- On the My Funds page, in the Account Summary section, note your v20 Account Number.
Your access token displays. Store it somewhere safe. You need your access token to deploy an algorithm with your paper trading account.
You need your v20 Account Number to deploy an algorithm with your paper trading account.
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 Type | Forex | CFD |
---|---|---|
Market | ||
Limit | ||
Stop market |
Time In Force
We model the GoodTilCanceled
GOOD_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.
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:
- Open the project you want to deploy.
- Click the Deploy Live icon.
- On the Deploy Live page, click the Brokerage field and then click from the drop-down menu.
- Enter your OANDA account Id and access token.
- Click the Environment field and then click one of the environments.
- Click the Node field and then click the live trading node that you want to use from the drop-down menu.
- (Optional) In the Data Provider section, click and change the data provider or add additional providers.
- (Optional) Set up notifications.
- Configure the Automatically restart algorithm setting.
- Click .
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.
The following table shows the supported environments:
Environment | Description |
---|---|
Real | Trade real money with fxTrade |
Demo | Trade paper money with fxTrade Practice |
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.
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.