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.03k stars 261 forks source link

KeyError: 'multiplierDown' #217

Closed josvanos closed 1 year ago

josvanos commented 1 year ago

Description

After clean install with blankly init and the use of example RSI bot, the following error occurs when backtesting:

exchange: Binance python: 3.10 blankly: lastest version

settings.json (default)

{
    "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 (default)

{
    "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)

Traceback (most recent call last):
  File "/opt/homebrew/lib/python3.10/site-packages/blankly/frameworks/strategy/strategy.py", line 127, in rest_event
    callback(*args)
  File "/Users/university/blankly.finance/bot.py", line 14, in price_event
    state.interface.market_order(symbol, side='buy', size=buy)
  File "/opt/homebrew/lib/python3.10/site-packages/blankly/exchanges/interfaces/paper_trade/paper_trade_interface.py", line 376, in market_order
    market_limits = self.get_order_filter(symbol)
  File "/opt/homebrew/lib/python3.10/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 "/opt/homebrew/lib/python3.10/site-packages/blankly/exchanges/interfaces/binance/binance_interface.py", line 880, in get_order_filter
    percent_min_price = float(filters[1]["multiplierDown"]) * current_price
KeyError: 'multiplierDown'

Additional context filters is structured this way

[{'filterType': 'PRICE_FILTER', 'minPrice': '0.01000000', 'maxPrice': '1000000.00000000', 'tickSize': '0.01000000'}, {'filterType': 'LOT_SIZE', 'minQty': '0.00001000', 'maxQty': '9000.00000000', 'stepSize': '0.00001000'}, {'filterType': 'MIN_NOTIONAL', 'minNotional': '10.00000000', 'applyToMarket': True, 'avgPriceMins': 5}, {'filterType': 'ICEBERG_PARTS', 'limit': 10}, {'filterType': 'MARKET_LOT_SIZE', 'minQty': '0.00000000', 'maxQty': '246.25571456', 'stepSize': '0.00000000'}, {'filterType': 'TRAILING_DELTA', 'minTrailingAboveDelta': 10, 'maxTrailingAboveDelta': 2000, 'minTrailingBelowDelta': 10, 'maxTrailingBelowDelta': 2000}, {'filterType': 'PERCENT_PRICE_BY_SIDE', 'bidMultiplierUp': '5', 'bidMultiplierDown': '0.2', 'askMultiplierUp': '5', 'askMultiplierDown': '0.2', 'avgPriceMins': 5}, {'filterType': 'MAX_NUM_ORDERS', 'maxNumOrders': 200}, {'filterType': 'MAX_NUM_ALGO_ORDERS', 'maxNumAlgoOrders': 5}]
EmersonDove commented 1 year ago

Hey @josvanos thanks for opening an issue. I'm aware of this binance.com issue I just haven't had a chance to fix it. It looks like their international api and the .us api are totally different now on this endpoint and blankly is just written for the the .us one

EmersonDove commented 1 year ago

This issue should be resolved in v1.18.23-beta. Try it out there and if it still isn't working we'll reopen.