mabdullahsoyturk
trading-bot
Python

An engulfing based crypto trading bot

Last updated Jul 28, 2026
10
Stars
5
Forks
0
Issues
0
Stars/day
Attention Score
5
Language breakdown
Python 99.7%
Shell 0.3%
Files click to expand
README

A trading bot that I've used for a while

This repository contains a trading bot that I used in Binance for a while. It's for educational purposes. Even though, the strategy seems profitable, I don't advise or recommend you to use it. Get a professional help for that.

Project Structure

trading-bot/
    backtest/                 # Backtesting package
        backtesting.py
        summary.py
    data/                     # Dataclasses
        ohlcv.py              # (O)pen, (H)ighest, (L)owest, (C)lose, (V)olume
        order.py              # Contains order info
        position.py           # Contains position info
    strategies/               # Contains different strategies
        engulfing.py          # Main engulfing strategy that I use
        macd.py               # An macd based strategy
        strategy.py           # Abstract strategy class
main.py                       # Main file to execute the bot
run.sh                        # Script for crontab

Strategy

Long Strategy

Requirements:

  • Price is above 200 EMA
  • Two red candles, followed by an engulfing green candle.
  • The price move of engulfing candle is no more than 2 times ATR.
Position info:
  • Entry price: Closing of engulfing candle.
  • Stop price: Lowest price of either engulfing or lowest price of the candle before engulfing candle (whichever is lower).
Take profit price: Entry Price + rr (Entry Price - Stop Price)

Long example:

Long

Short Strategy

Requirements:

  • Price is below 200 EMA
  • Two green candles, followed by an engulfing red candle.
  • The price move of engulfing candle is no more than 2 times ATR.
Position info:
  • Entry price: Closing of engulfing candle.
  • Stop price: Highest price of either engulfing or highest price of the candle before engulfing candle (whichever is higher).
Take profit price: Entry Price + rr (Stop Price - Entry Price)

Short example:

Short

Backtest Results

TIMEFRAME = 30m RR = 2 EMA = 200 ATR = 2

You can run the following backtest with:

python main.py --backtest --days-ago 370 --ema-timeperiod 200 --rr 2 --timeframe 30m atr-multiplier 2

| Side | Total R | Win Rate | Num Stops | Num Profits | Num Positions | | ------------- | ------------- | ------------- | ------------- | ------------- | ------------- | | LONG | 51 | 0.405 | 141 | 96 | 237 | | SHORT | 95 | 0.395 | 309 | 202 | 512 |

| Side | Longest Winning Streak | Longest Losing Streak | | ------------- | ------------- | ------------- | | LONG | 10 | 8 | | SHORT | 14 | 17 |

Return

Install Dependencies

pip install -r requirements.txt

Setup your API_KEY and SECRET

Put your API_KEY and SECRET in a new .env file.

Example:

APIKEY=<YOURAPI_KEY>
SECRET=<YOUR_SECRET>

Deploy

crontab -e
/30     * bash <repopath>/run.sh >> <repopath>/log.txt 2>&1

is the path where you cloned the repository.

🔗 More in this category

© 2026 GitRepoTrend · mabdullahsoyturk/trading-bot · Updated daily from GitHub