Giter Club home page Giter Club logo

backtrader-binance's Introduction

backtrader-binance's People

Contributors

lindomar-oliveira avatar yairfrid avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

backtrader-binance's Issues

Futures

Hello,
Have you maybe plan to add binance futures to backtrader_binance? :)
I'm strugged with add changes for it. But my skill of python is to low :(

I have done for now only: using futures data, running strategy in multiproceses and checking assets on futures account for each threaded pair coins.
But I need to also somehow creates bracket orders:

  • BUY with market TP and SL (canceled all when one of them will be filled)
  • SELL with market TP and SL (canceled all when one of them will be filled)
  • receiving information about canceletion (for SELL or BUY brackets orders) - probably from user_stream_data (or sth. like this) to close also a position in backtrader strategy.

Can you somehow help me with understand how to do this? Or maybe you are working on this as a next version of backtrader_binance? :)

Thanks in advance for any feedback! ;)
BR, Piotr

How to perform back testing?

Sorry I'm new to backtrader.

Is there any way to use this package to test strategy on past data without placing real order?

Account has insufficient balance for requested action.

Hello,
thank you for your work. It appears that when I try the example code on Binance Spot (not the testnet) I have a BinanceApiException. Account has insufficient balance for requested action.

I am looking at testing the algorithm with 100 EUR and targeting ETH/EUR.

What should be the minimum initial cash ? Can it be a parameter (like in fastquant).

Thanks

How to use proxy?

I have added proxies parameer code in binance_store.py, eg:
def init(self, api_key, api_secret, coin_refer, coin_target, testnet=False, retries=5):
proxies = {
"http": "127.0.0.1:19180",
"https": "127.0.0.1:19180"
}
# self.binance = Client(api_key, api_secret, testnet=testnet)
self.binance = Client(api_key, api_secret, testnet=testnet, requests_params={"proxies": proxies})
print(self.binance.get_account())
and I have print my account message, such as:
image

but my code also print error message, as follows:
image

Can you help me?

get_symbol_info in line 140 returns none in both Testnet and Spot

@retry def get_symbol_info(self, symbol): return self.binance.get_symbol_info(symbol)

returns None
This leads to a TypeError: 'NoneType' object is not subscriptable error when you run
store = BinanceStore( api_key=BINANCE.get("key"), api_secret=BINANCE.get("secret"), coin_refer=COIN_REFER, coin_target=COIN_TARGET, testnet=True )

binance.exceptions.BinanceAPIException: APIError(code=-2015): Invalid API-key, IP, or permissions for action.

Traceback (most recent call last):
  File "qbot/engine/trading/live_trade_binance.py", line 36, in <module>
    store = BinanceStore(
  File "/home/qcraft/anaconda3/envs/qlib/lib/python3.8/site-packages/backtrader_binance/binance_store.py", line 47, in __init__
    self.get_balance()
  File "/home/qcraft/anaconda3/envs/qlib/lib/python3.8/site-packages/backtrader_binance/binance_store.py", line 128, in get_balance
    free, locked = self.get_asset_balance(self.coin_target)
  File "/home/qcraft/anaconda3/envs/qlib/lib/python3.8/site-packages/backtrader_binance/binance_store.py", line 68, in wrapper
    return func(self, *args, **kwargs)
  File "/home/qcraft/anaconda3/envs/qlib/lib/python3.8/site-packages/backtrader_binance/binance_store.py", line 124, in get_asset_balance
    balance = self.binance.get_asset_balance(asset)
  File "/home/qcraft/anaconda3/envs/qlib/lib/python3.8/site-packages/binance/client.py", line 1979, in get_asset_balance
    res = self.get_account(**params)
  File "/home/qcraft/anaconda3/envs/qlib/lib/python3.8/site-packages/binance/client.py", line 1954, in get_account
    return self._get('account', True, data=params)
  File "/home/qcraft/anaconda3/envs/qlib/lib/python3.8/site-packages/binance/client.py", line 371, in _get
    return self._request_api('get', path, signed, version, **kwargs)
  File "/home/qcraft/anaconda3/envs/qlib/lib/python3.8/site-packages/binance/client.py", line 334, in _request_api
    return self._request(method, uri, signed, **kwargs)
  File "/home/qcraft/anaconda3/envs/qlib/lib/python3.8/site-packages/binance/client.py", line 315, in _request
    return self._handle_response(self.response)
  File "/home/qcraft/anaconda3/envs/qlib/lib/python3.8/site-packages/binance/client.py", line 324, in _handle_response
    raise BinanceAPIException(response, response.status_code, response.text)
binance.exceptions.BinanceAPIException: APIError(code=-2015): Invalid API-key, IP, or permissions for action.

to use with backtest

hi,
thanks for a nice library! Ive played around with it for a bit and the example script for live trading seems to work ok. But I dont see how to use it to download data for backtests. is this supported? Also, any suggestions on how to use it for multi-asset trading?

change the Strategy

class RSIStrategy(bt.Strategy):
def init(self):
self.rsi = bt.indicators.RSI(period=14) # RSI indicator

def next(self):

    print('Open: {}, High: {}, Low: {}, Close: {}'.format(
        self.data.open[0],
        self.data.high[0],
        self.data.low[0],
        self.data.close[0]))
    print('RSI: {}'.format(self.rsi[0]))

    if not self.position:
        if self.rsi < 30:  # Enter long
            self.buy()
    else:
        if self.rsi > 70:
            self.sell()  # Close long position

How to change it to an EMA policy or a Bolling policy in this instance,I change the bt.indicators.rsi as bt.indicators.ema it casus problems.

Can't receive data when testnet=False

I change testnet=False to testnet=True in the example which you give and run, and then I receive one data, but I can't receive any data after that.
It seem that when testnet=False , websocket will be disconnected after a few seconds and will never be connected again. However I can receive data normally when testnet=True, and I can also use class ThreadedWebsocketManager normally when testnet=False in other programs.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.