A fast cryptocurrency trading bot framework implemented in Go. Ninjabot permits users to create and test custom strategies for spot markets.
Documentation: https://rodrigo-brito.github.io/ninjabot/
go get -u github.com/rodrigo-brito/ninjabot/...
Check examples directory:
- Paper Wallet (Live Simulation)
- Backtesting (Simulation with historical data)
- Real Account (Binance)
To download historical data you can download ninjabot CLI from:
- Pre-build binaries in release page
- Or with
go install github.com/rodrigo-brito/ninjabot/cmd/ninjabot@latest
Example of usage
# Download candles of BTCUSDT to btc.csv file (Last 30 days, timeframe 1D)
ninjabot download --pair BTCUSDT --timeframe 1d --days 30 --output ./btc.csv
- Backtesting a custom strategy from examples directory:
go run examples/backtesting/main.go
Output:
INFO[2021-09-29 00:00] [SETUP] Using paper wallet
INFO[2021-09-29 00:00] [SETUP] Initial Portfolio = 10000.000000 USDT
finished
+---------+--------+-----+------+--------+--------+----------+-----------+
| PAIR | TRADES | WIN | LOSS | % WIN | PAYOFF | PROFIT | VOLUME |
+---------+--------+-----+------+--------+--------+----------+-----------+
| BTCUSDT | 17 | 6 | 11 | 35.3 % | 7.038 | 7424.37 | 250246.73 |
| ETHUSDT | 17 | 9 | 8 | 52.9 % | 7.400 | 9270.30 | 168350.93 |
+---------+--------+-----+------+--------+--------+----------+-----------+
| TOTAL | 34 | 15 | 19 | 44.1 % | 7.219 | 16694.67 | 418597.66 |
+---------+--------+-----+------+--------+--------+----------+-----------+
--------------
WALLET SUMMARY
--------------
0.000000 ETH
0.000000 BTC
TRADING VOLUME
ETHUSDT = 185030.63 USDT
BTCUSDT = 255182.59 USDT
26694.674186 USDT
--------------
START PORTFOLIO = 10000 USDT
FINAL PORTFOLIO = 26694.674186473057 USDT
GROSS PROFIT = 16694.674186 USDT (166.95%)
MARKET CHANGE = 420.18%
VOLUME = 440213.22 USDT
COSTS (0.001*V) = 440.21 USDT (ESTIMATION)
--------------
Chart available at http://localhost:8080
-
Live Trading
- Custom Strategy
- Order Limit, Market, OCO
-
Backtesting
- Paper Wallet (Live Trading with fake wallet)
- Load Feed from CSV
- Order Limit, Market, OCO
-
Bot Utilities
- CLI to download historical data
- Plot (Candles + Sell / Buy orders, Indicators)
- Telegram Controller (Status, Buy, Sell)
- Include trailing stop tool
- Stop Orders in backtesting
Currently, we only support Binance exchange. If you want to include support for other exchanges, you need to implement a new struct
that implements the interface Exchange
. You can check some examples in exchange directory.