This repository contains an automated trading bot that connects to the OANDA v20 API. It implements an Opening Range Breakout (ORB) strategy. The bot streams real-time pricing data for specified currency pairs, generates trading signals based on a breakout strategy, and executes market orders accordingly. By default, it trades the following instruments: EUR/DKK, XAU/CHF, and XPD/USD. The application is designed to be configurable and extensible for different trading strategies and instruments.
- Language: Python 3.8
- API: OANDA v20 API
- Core Libraries:
v20: The official Python wrapper for the OANDA v20 REST API.pandas: Used for data manipulation and analysis, particularly for handling time-series data.numpy: For numerical operations.pyyaml: For parsing the configuration file.iso8601&rfc3339: For handling date and time formats.
- Real-time price data streaming from the OANDA API.
- Dynamic candle generation from streaming price data.
- Opening Range Breakout (ORB) trading strategy implementation.
- Automated order execution (market orders).
- Position management with stop-loss and take-profit levels.
- Concurrent processing using multithreading for handling multiple currency pairs simultaneously.
- Data logging for prices, candles, and trade orders.
.
├── .gitignore
├── Pipfile
├── Pipfile.lock
├── README.md
├── configure.py
├── main.py
├── signal_detector.py
├── DataDump.py
├── exit_control.py
├── logger.py
└── v20.conf
The following directories must be created in the root of the project for data logging:
candles/: Stores the generated candle data in CSV format.logs/: Contains logs of trade orders.prices/: Stores the raw price data streamed from the API in CSV format.
- Python 3.8
pipenv
- Clone the repository:
git clone <repository-url> cd ORBitrage
- Create required directories:
mkdir candles logs prices
- Install dependencies:
pipenv install
- Configure API Credentials:
Create a
v20.conffile in the root directory with your OANDA API credentials. You can use the following template:hostname: "api-fxpractice.oanda.com" streaming_hostname: "stream-fxpractice.oanda.com" port: 443 ssl: true token: "YOUR_API_TOKEN" username: "YOUR_USERNAME" accounts: - "YOUR_ACCOUNT_ID" active_account: "YOUR_ACCOUNT_ID" datetime_format: "RFC3339"
To start the trading bot, run the following command:
pipenv run python main.pyThe bot will start streaming data, processing it, and executing trades based on the implemented strategy. To stop the bot, press Ctrl+C.
This bot is designed for demonstration and educational purposes. Trading with real money involves significant risk. Please test thoroughly in a demo environment before deploying with a live account.