blankly-finance / blankly

🚀 💸 Easily build, backtest and deploy your algo in just a few lines of code. Trade stocks, cryptos, and forex across exchanges w/ one package.
https://package.blankly.finance
GNU Lesser General Public License v3.0
2.17k stars 271 forks source link

KeyError: 'bidMultiplierUp' #241

Closed StayFoolisj closed 1 year ago

StayFoolisj commented 1 year ago

Description

First time user of Blankly. Did a clean install and attempted to run a backtest of the RSI demo strategy:

% blankly init
? What exchange would you like to connect to? Binance
? What type of model do you want to create? Strategy
? What template would you like to use for your new model? rsi_bot
? Would you like to add keys for this exchange?
You can do this later at any time by running `blankly key add` Yes
? What TLD are you using? binance.com
? Give this key a name:  (Optional) demo
? API Key: OBFUSCATED
? API Secret: OBFUSCATED
? Is this testnet/sandbox key? No
✔ Checked Binance API Key
✔ Your API key for Binance was added to this model
✔ Generated files
✔ Done! Your model was created. Run `python bot.py` to run a backtest and get started.

settings.json

{
    "settings": {
        "use_sandbox_websockets": false,
        "websocket_buffer_size": 10000,
        "test_connectivity_on_auth": true,
        "auto_truncate": false,
        "global_shorting": false,
        "simulate_margin": true,
        "coinbase_pro": {
            "cash": "USD"
        },
        "binance": {
            "cash": "USDT",
            "binance_tld": "com"
        },
        "binance_futures": {
            "cash": "USDT",
            "margin_type": "USDT-M"
        },
        "alpaca": {
            "websocket_stream": "iex",
            "cash": "USD",
            "enable_shorting": true,
            "use_yfinance": false
        },
        "oanda": {
            "cash": "USD"
        },
        "okx": {
            "cash": "USDT"
        },
        "keyless": {
            "cash": "USD"
        },
        "kucoin": {
            "cash": "USDT"
        },
        "ftx": {
            "cash": "USD",
            "ftx_tld": "com"
        },
        "ftx_futures": {
            "cash": "USD",
            "ftx_tld": "com"
        },
        "paper": {
            "price_source": "api"
        }
    }
}

backtest.json (if applicable)

{
    "price_data": {
        "assets": []
    },
    "settings": {
        "use_price": "close",
        "smooth_prices": false,
        "GUI_output": true,
        "show_tickers_with_zero_delta": false,
        "save_initial_account_value": true,
        "show_progress_during_backtest": true,
        "cache_location": "./price_caches",
        "continuous_caching": true,
        "resample_account_value_for_metrics": "1d",
        "quote_account_value_in": "USDT",
        "ignore_user_exceptions": true,
        "risk_free_return_rate": 0.0,
        "benchmark_symbol": null
    }
}

Error (if applicable)

% python3 bot.py
INFO: No portfolio name to load specified, defaulting to the first in the file: (demo). This is fine if there is only one portfolio in use.
No cached data found for BTC-USDT from: 1658566550.532497 to 1690016150.5324988 at a resolution of 86400 seconds.

Backtesting...
Traceback (most recent call last):
  File "user/code/blankly-demo/.venv/lib/python3.11/site-packages/blankly/frameworks/strategy/strategy.py", line 127, in rest_event
    callback(*args)
  File "/user/code/blankly-demo/bot.py", line 14, in price_event
    state.interface.market_order(symbol, side='buy', size=buy)
  File "/user/code/blankly-demo/.venv/lib/python3.11/site-packages/blankly/exchanges/interfaces/paper_trade/paper_trade_interface.py", line 376, in market_order
    market_limits = self.get_order_filter(symbol)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/code/blankly-demo/.venv/lib/python3.11/site-packages/blankly/exchanges/interfaces/paper_trade/paper_trade_interface.py", line 743, in get_order_filter
    self.get_order_filter_cache[symbol] = self.calls.get_order_filter(symbol)
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/code/blankly-demo/.venv/lib/python3.11/site-packages/blankly/exchanges/interfaces/binance/binance_interface.py", line 1021, in get_order_filter
    multiplier_up = float(filters[filter_mapping['PERCENT_PRICE_BY_SIDE']]["bidMultiplierUp"])
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
KeyError: 'bidMultiplierUp'
Traceback (most recent call last):
  File "/user/code/blankly-demo/.venv/lib/python3.11/site-packages/blankly/frameworks/strategy/strategy.py", line 127, in rest_event
    callback(*args)
  File "/user/code/blankly-demo/bot.py", line 14, in price_event
    state.interface.market_order(symbol, side='buy', size=buy)
  File "/user/code/blankly-demo/.venv/lib/python3.11/site-packages/blankly/exchanges/interfaces/paper_trade/paper_trade_interface.py", line 376, in market_order
    market_limits = self.get_order_filter(symbol)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/code/blankly-demo/.venv/lib/python3.11/site-packages/blankly/exchanges/interfaces/paper_trade/paper_trade_interface.py", line 743, in get_order_filter
    self.get_order_filter_cache[symbol] = self.calls.get_order_filter(symbol)
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/code/blankly-demo/.venv/lib/python3.11/site-packages/blankly/exchanges/interfaces/binance/binance_interface.py", line 1021, in get_order_filter
    multiplier_up = float(filters[filter_mapping['PERCENT_PRICE_BY_SIDE']]["bidMultiplierUp"])
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
KeyError: 'bidMultiplierUp'
Traceback (most recent call last):
  File "/user/code/blankly-demo/.venv/lib/python3.11/site-packages/blankly/frameworks/strategy/strategy.py", line 127, in rest_event
    callback(*args)
  File "/user/code/blankly-demo/bot.py", line 14, in price_event
    state.interface.market_order(symbol, side='buy', size=buy)
  File "/user/code/blankly-demo/.venv/lib/python3.11/site-packages/blankly/exchanges/interfaces/paper_trade/paper_trade_interface.py", line 376, in market_order
    market_limits = self.get_order_filter(symbol)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/code/blankly-demo/.venv/lib/python3.11/site-packages/blankly/exchanges/interfaces/paper_trade/paper_trade_interface.py", line 743, in get_order_filter
    self.get_order_filter_cache[symbol] = self.calls.get_order_filter(symbol)
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/code/blankly-demo/.venv/lib/python3.11/site-packages/blankly/exchanges/interfaces/binance/binance_interface.py", line 1021, in get_order_filter
    multiplier_up = float(filters[filter_mapping['PERCENT_PRICE_BY_SIDE']]["bidMultiplierUp"])
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
KeyError: 'bidMultiplierUp'
Traceback (most recent call last):
  File "/user/code/blankly-demo/.venv/lib/python3.11/site-packages/blankly/frameworks/strategy/strategy.py", line 127, in rest_event
    callback(*args)
  File "/user/code/blankly-demo/bot.py", line 14, in price_event
    state.interface.market_order(symbol, side='buy', size=buy)
  File "/user/code/blankly-demo/.venv/lib/python3.11/site-packages/blankly/exchanges/interfaces/paper_trade/paper_trade_interface.py", line 376, in market_order
    market_limits = self.get_order_filter(symbol)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/code/blankly-demo/.venv/lib/python3.11/site-packages/blankly/exchanges/interfaces/paper_trade/paper_trade_interface.py", line 743, in get_order_filter
    self.get_order_filter_cache[symbol] = self.calls.get_order_filter(symbol)
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/code/blankly-demo/.venv/lib/python3.11/site-packages/blankly/exchanges/interfaces/binance/binance_interface.py", line 1021, in get_order_filter
    multiplier_up = float(filters[filter_mapping['PERCENT_PRICE_BY_SIDE']]["bidMultiplierUp"])
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
KeyError: 'bidMultiplierUp'
Traceback (most recent call last):
  File "/user/code/blankly-demo/.venv/lib/python3.11/site-packages/blankly/frameworks/strategy/strategy.py", line 127, in rest_event
    callback(*args)
  File "/user/code/blankly-demo/bot.py", line 14, in price_event
    state.interface.market_order(symbol, side='buy', size=buy)
  File "/user/code/blankly-demo/.venv/lib/python3.11/site-packages/blankly/exchanges/interfaces/paper_trade/paper_trade_interface.py", line 376, in market_order
    market_limits = self.get_order_filter(symbol)
                    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/code/blankly-demo/.venv/lib/python3.11/site-packages/blankly/exchanges/interfaces/paper_trade/paper_trade_interface.py", line 743, in get_order_filter
    self.get_order_filter_cache[symbol] = self.calls.get_order_filter(symbol)
                                          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/user/code/blankly-demo/.venv/lib/python3.11/site-packages/blankly/exchanges/interfaces/binance/binance_interface.py", line 1021, in get_order_filter
    multiplier_up = float(filters[filter_mapping['PERCENT_PRICE_BY_SIDE']]["bidMultiplierUp"])
                          ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^
KeyError: 'bidMultiplierUp'
Progress: [##########] 100% Done...

Platform Info

Additional context Add any other context about the problem here.

StayFoolisj commented 1 year ago

I just recreated my virtualenv with Python 3.10.6 and 3.9.6 as I see you haven't tested blankly against 3.11, but same thing happened there.

EmersonDove commented 1 year ago

Binance is always changing their binance internation order filter sorry about that - being american I can only test against the binance us.

Let me update the way we're parsing the binance response which should fix this.

EmersonDove commented 1 year ago

Should be fixed

Try updating to v1.18.25 via pip install --upgrade blankly