Skip to content

Algorithmic Trading Pipeline for Deriv - Synthetic Indices Trading using Python Deriv API. This trading pipeline application is designed to perform real-time data streaming, process tick data, and execute trades based on Bollinger Bands and Rejection candlestick patterns.

License

Notifications You must be signed in to change notification settings

stephen-njiu/Trading-Pipeline

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 

Repository files navigation

Trading Pipeline Application

This trading pipeline application is designed to perform real-time data streaming, process tick data, and execute trades based on Bollinger Bands and Rejection candlestick patterns. It uses the Deriv API for connecting to the market, fetching tick data, and placing trades on the selected symbol.

Features

  • Live Data Streaming: Connects to the Deriv WebSocket API to fetch tick data in real time.
  • Technical Analysis: Uses Bollinger Bands and RSI to analyze market conditions and identify buy/sell signals.
  • Automated Trading: Automatically executes trades when the appropriate signal is generated.
  • Data Preprocessing: Processes live data to generate OHLC (Open, High, Low, Close) candlesticks from tick data.

Prerequisites

Ensure that you have the following before running the application:

Python 3.8+
Pip for managing dependencies.
Deriv API app ID and token. You can register for these at Deriv.

Setup

Step 1: Clone the Repository

git clone https://github.com/stephen-njiu/Trading-Pipeline
cd <your-repo-directory>

Step 2: Install the Requirements

You can install the required dependencies using the requirements.txt file:

pip install -r requirements.txt

Step 3: Set Up Your Environment

  • You will need to provide your app ID and API token in the code:

      app_id = '<your_app_id>'
      api_token = '<your_api_token>'
    

Running the Application

Step 1: Connect to the Market

The application connects to the Deriv WebSocket and streams tick data in real time. The first connection is established in the connect() function:

api = asyncio.run(connect())

Step 2: Data Preprocessing and Candlestick Generation

Tick data is processed and converted into candlestick data using the create_candle() function. The data_preprocess() function applies Bollinger Bands, RSI, and Rejection candlestick patterns to the data:

df = data_preprocess(df)

Step 3: Trading Logic

The trading strategy is based on Bollinger Bands and Rejection patterns. It triggers a buy or sell based on the signal generated:

Signal 1: Sell when the close and open prices are above the upper Bollinger Band.
Signal 2: Buy when the close and open prices are below the lower Bollinger Band.

The application places a trade using the api.proposal() and api.buy() functions once a signal is detected.

Usage Example

To run the application, execute the following command:

python main.py
  • Once the application is running, it will stream tick data, process it into candlestick format, and execute trades based on the predefined strategy.

Key Components

  • WebSocket Connection: The application connects to Deriv’s WebSocket using websockets.connect().
  • Tick Data Handling: Tick data is fetched and stored in the ticks list, which is later used to create candlesticks.
  • Bollinger Bands & RSI: These are used to detect overbought or oversold conditions.
  • Trade Execution: Trades are placed when the appropriate conditions are met.

Customization

  • Timeframe: You can change the candlestick timeframe by modifying the candle_stick_timeframe variable.
  • Symbol: To trade on a different asset, replace the value of the tick_symbol variable.
  • Trade Amount: Adjust the amount variable to set the stake for each trade.

License

This project is open-source under the MIT License.

About

Algorithmic Trading Pipeline for Deriv - Synthetic Indices Trading using Python Deriv API. This trading pipeline application is designed to perform real-time data streaming, process tick data, and execute trades based on Bollinger Bands and Rejection candlestick patterns.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages