All Projects → 10mohi6 → bitmex-backtest-python

10mohi6 / bitmex-backtest-python

Licence: MIT license
bitmex-backtest is a python library for backtest with bitmex fx trade rest api on Python 3.7 and above.

Programming Languages

python
139335 projects - #7 most used programming language

Projects that are alternatives of or similar to bitmex-backtest-python

Ccxt
A JavaScript / Python / PHP cryptocurrency trading API with support for more than 100 bitcoin/altcoin exchanges
Stars: ✭ 22,501 (+172984.62%)
Mutual labels:  btc, trade
Binance Trader
💰 Cryptocurrency Trading Bot for Binance (Experimental)
Stars: ✭ 2,128 (+16269.23%)
Mutual labels:  btc, trade
Telegram Kraken Bot
Python bot to trade on Kraken via Telegram
Stars: ✭ 156 (+1100%)
Mutual labels:  btc, trade
Cryptoinscriber
📈 A live cryptocurrency historical trade data blotter. Download live historical trade data from any cryptoexchange, be it for machine learning, backtesting/visualizing trading strategies or for Quantopian/Zipline.
Stars: ✭ 27 (+107.69%)
Mutual labels:  trade, backtest
SwiftFlyer
An API wrapper for bitFlyer.
Stars: ✭ 39 (+200%)
Mutual labels:  btc, fx
Krypto Trading Bot
Self-hosted crypto trading bot (automated high frequency market making) written in C++
Stars: ✭ 2,589 (+19815.38%)
Mutual labels:  trade, bitmex
oanda-bot-python
oanda-bot is a python library for automated trading bot with oanda rest api on Python 3.6 and above.
Stars: ✭ 20 (+53.85%)
Mutual labels:  fx, backtest
coinaly
🚀 Fast and easy to use mobile trade interface for cryptocurrencies. Track your trades to the moon and beyond. Currently only for Bittrex.
Stars: ✭ 32 (+146.15%)
Mutual labels:  btc, trade
Qtbitcointrader
Secure multi crypto exchange trading client
Stars: ✭ 520 (+3900%)
Mutual labels:  btc, trade
Bot18
Bot18 is a high-frequency cryptocurrency trading bot developed by Zenbot creator @carlos8f
Stars: ✭ 157 (+1107.69%)
Mutual labels:  btc
Cryptocompare
CryptoCompare JavaScript API
Stars: ✭ 212 (+1530.77%)
Mutual labels:  btc
My Token
📈Track token prices of your favorite exchanges in terminal!
Stars: ✭ 141 (+984.62%)
Mutual labels:  btc
Proofofexistence
Core and web app for Proof of Existence - the original blockchain notary service
Stars: ✭ 155 (+1092.31%)
Mutual labels:  btc
Ccxt Rest
Open Source Unified REST API of 100+ Crypto Exchange Sites (18k+ docker pulls) - https://ccxt-rest.io/
Stars: ✭ 210 (+1515.38%)
Mutual labels:  btc
LiuAlgoTrader
Framework for algorithmic trading
Stars: ✭ 514 (+3853.85%)
Mutual labels:  trade
Awesome Bitcoin Cash
A curated list of awesome things related to Bitcoin Cash. Contribute yourself:
Stars: ✭ 136 (+946.15%)
Mutual labels:  btc
java-binance-api
Java Binance API Client
Stars: ✭ 72 (+453.85%)
Mutual labels:  trade
Coinbin.org
₿ A Human–Friendly API Service for Crypto Currency Information.
Stars: ✭ 253 (+1846.15%)
Mutual labels:  btc
Unstoppable Wallet Ios
A secure and decentralized Bitcoin and other cryptocurrency wallet for iPhone. Supports Bitcoin, Ethereum, EOS, Binance Chain, Bitcoin Cash, DASH, ...
Stars: ✭ 180 (+1284.62%)
Mutual labels:  btc
Btcbot Open
在 binance 和 bitfinex 搬砖的机器人,目标是赚更多 BTC 🍺🍺🍺🍺🍺
Stars: ✭ 179 (+1276.92%)
Mutual labels:  btc

bitmex-backtest

PyPI License: MIT codecov Build Status PyPI - Python Version Downloads

bitmex-backtest is a python library for backtest with bitmex fx trade rest api on Python 3.7 and above.

Installation

$ pip install bitmex-backtest

Usage

basic

from bitmex_backtest import Backtest

bt = Backtest()
bt.candles("XBTUSD")
fast_ma = bt.sma(period=5)
slow_ma = bt.sma(period=25)
bt.sell_exit = bt.buy_entry = (fast_ma > slow_ma) & (fast_ma.shift() <= slow_ma.shift())
bt.buy_exit = bt.sell_entry = (fast_ma < slow_ma) & (fast_ma.shift() >= slow_ma.shift())
bt.run()
bt.plot()

advanced

from bitmex_backtest import Backtest

bt = Backtest(test=True)
filepath = "xbtusd-60.csv"
if bt.exists(filepath):
    bt.read_csv(filepath)
else:
    params = {
        "resolution": "60",  # 1 hour candlesticks (default=1) 1,3,5,15,30,60,120,180,240,360,720,1D,3D,1W,2W,1M
        "count": "5000" # 5000 candlesticks (default=500)
    }
    bt.candles("XBTUSD", params)
    bt.to_csv(filepath)

fast_ma = bt.sma(period=10)
slow_ma = bt.sma(period=30)
exit_ma = bt.sma(period=5)
bt.buy_entry = (fast_ma > slow_ma) & (fast_ma.shift() <= slow_ma.shift())
bt.sell_entry = (fast_ma < slow_ma) & (fast_ma.shift() >= slow_ma.shift())
bt.buy_exit = (bt.C < exit_ma) & (bt.C.shift() >= exit_ma.shift())
bt.sell_exit = (bt.C > exit_ma) & (bt.C.shift() <= exit_ma.shift())

bt.quantity = 100 # default=1
bt.stop_loss = 200 # stop loss (default=0)
bt.take_profit = 1000 # take profit (default=0)

print(bt.run())
bt.plot("backtest.png")
total profit       -342200.000
total trades           162.000
win rate                32.716
profit factor            0.592
maximum drawdown    470950.000
recovery factor         -0.727
riskreward ratio         1.295
sharpe ratio            -0.127
average return         -20.325
stop loss               23.000
take profit              1.000

advanced.png

Supported indicators

  • Simple Moving Average 'sma'
  • Exponential Moving Average 'ema'
  • Moving Average Convergence Divergence 'macd'
  • Relative Strenght Index 'rsi'
  • Bollinger Bands 'bband'
  • Stochastic Oscillator 'stoch'
  • Market Momentum 'mom'

Getting started

For help getting started with bitmex REST API, view our online documentation.

Contributing

  1. Fork it
  2. Create your feature branch (git checkout -b my-new-feature)
  3. Commit your changes (git commit -am 'Add some feature')
  4. Push to the branch (git push origin my-new-feature)
  5. Create new Pull Request
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].