ninjabot

A fast cryptocurrency trading bot framework implemented in Go. Ninjabot permits users to create and test custom strategies for spot markets.

Installation

go get -u github.com/rodrigo-brito/ninjabot/...

Examples of Usage

Check examples directory:

  • Paper Wallet (Live Simulation)
  • Backtesting
  • Real Account (Binance)

CLI

To download historical data you can download ninjabot CLI from release page

  • Download 30 days: ninjabot download --pair BTCUSDT --timeframe 1d --days 30 --output ./btc.csv

Backtesting Example

  • Backtesting a custom strategy from examples directory:
go run examples/backtesting/main.go

Output:

[SETUP] Using paper wallet                   
[SETUP] Initial Portfolio = 10000.000000 USDT 
+---------+--------+-----+------+--------+--------+------------+
|  PAIR   | TRADES | WIN | LOSS | % WIN  | PAYOFF |   PROFIT   |
+---------+--------+-----+------+--------+--------+------------+
| ETHUSDT |     19 |   9 |   10 | 47.4 % |  6.975 |  6334.1268 |
| BTCUSDT |     17 |   6 |   11 | 35.3 % |  7.734 |  4803.0181 |
+---------+--------+-----+------+--------+--------+------------+
|   TOTAL |     36 |  15 |   21 | 41.7 % |  7.333 | 11137.1449 |
+---------+--------+-----+------+--------+--------+------------+
--------------
WALLET SUMMARY
--------------
0.000000 ETH
0.000000 BTC
21137.144920 USDT
--------------
START PORTFOLIO =  10000 USDT
FINAL PORTFOLIO =  21137.14492013396 USDT
GROSS PROFIT    =  11137.144920 USDT (111.37%)
MARKET CHANGE   =  396.71%

--------------
Chart available at http://localhost:8080

Plot result:

Roadmap:

  • [x] Live Trading

    • [x] Custom Strategy
    • [x] Order Limit, Market, OCO
    • [ ] Stop Orders
  • [x] Backtesting

    • [x] Paper Wallet (Live Trading with fake wallet)
    • [x] Load Feed from CSV
    • [x] Market Orders
    • [x] Limit Orders
    • [x] OCO Orders
    • [ ] Stop Orders
  • [x] Bot Utilities

    • [x] CLI to download historical data
    • [x] Plot (Candles + Sell / Buy orders)
    • [x] Telegram Notifier
    • [ ] Plot Indicators

GitHub

https://github.com/rodrigo-brito/ninjabot