项目作者: gr-satt

项目描述 :
python wrapper: BitMEX OHLCV data & 150+ technical indicator values, BitMEX REST API
高级语言: Python
项目地址: git://github.com/gr-satt/bordem.git
创建时间: 2019-12-01T17:39:51Z
项目社区:https://github.com/gr-satt/bordem

开源协议:

下载


Image of logo

Build automated trading strategies for BitMEX contracts.

Easily return BitMEX OHLCV data, 150+ indicator values.

Interacts directly with BitMEX REST API v1.

Main & Testnet support

Python 3.7+

Usage

  1. from bordemwrapper import Data, Trade
  2. from bordemwrapper import schedule, alert
  3. # return BitMEX daily OHLCV data for the past 25 (instances) days
  4. # timeframe options: 1m, 5m, 1h, 1d
  5. data = Data().ohlcv(symbol='XBTUSD', timeframe='1d', instances=25)
  6. # return XBTUSD 14-period RSI values for the past 20 (instances) hourly candles
  7. # params: symbol, timeframe, instances, indicator, <indicator args>, <indicator kwargs>
  8. # args: 'close' arg converts to array of close values | 'open' 'high' 'low' 'close' 'volume'
  9. # call indicator_help to see needed args, kwargs
  10. indicator = Data().indicator('XBTUSD', '1h', 20, 'RSI', 'close', timeperiod=14)
  11. # indicator help - show params & output
  12. help_ = Data().indicator_help('STOCH')
  13. # return current price
  14. price = Trade().price(symbol='XBTUSD')
  15. # set leverage - 2x on XBTUSD
  16. Trade().qty_update(lev=2, symbol='XBTUSD')
  17. # market order
  18. Trade().market(symbol='XBTUSD', qty=10)
  19. # bulk order: 10 (default amt) orders of 25 contracts every 1% above $10,000
  20. Trade().bulk(symbol='XBTUSD', qty=25, price=10000, offset=1)
  21. # bulk order: 10 (default amt) orders of 25 contracts every 1% below $10,000
  22. Trade().bulk(symbol='XBTUSD', qty=25, price=10000, offset=-1)
  23. # handling multiple accounts
  24. Trade(api_key='Acct_1_Key', api_secret='Acct_2_Secret')\
  25. .limit(symbol='XBTUSD', qty=10, price=1000)
  26. Trade(api_key='Acct_2_Key', api_secret='Acct_2_Secret')\
  27. .limit(symbol='XBTUSD', qty=-1, price=1000)
  28. # schedule - 9:30AM, 5:00PM
  29. # sleep until given time
  30. schedule(9, 30, 0)
  31. schedule(17, 0, 0)
  32. # send email alert
  33. alert(subj='example', msg='message')

Methods

Data(…)

  • .ohlcv(…)
  • .indicator(…) full list here: https://github.com/mrjbq7/ta-lib#supported-indicators-and-functions
  • .indicator_help(…)

Trade(…)

  • .balance() XBT quoted
  • .position() open position details
  • .price(…) current contract price
  • .market(…) market order
  • .limit(…) limit order
  • .bulk(…) order staggering
  • .close(…) close open positions
  • .cancel() cancel open order(s)
  • .balance_check() check/log balance
  • .qty_update(…) change leverage

Other

  • schedule(…)
  • alert(…) email alert - from address, gmail support only