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.13k stars 268 forks source link

Take and Maker Fee Rate Error (Coinbase Pro Sandbox) #194

Closed tylerbordeaux closed 2 years ago

tylerbordeaux commented 2 years ago

Description

My trades are showing as filled on website but with prices of 0, getting errors on market buy and sell.

settings.json

{
    "settings": {
        "use_sandbox_websockets": false,
        "websocket_buffer_size": 10000,
        "test_connectivity_on_auth": true,
        "auto_truncate": false,
        "global_shorting": false,
        "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"
        }
    }
}

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": "USD",
        "ignore_user_exceptions": true,
        "risk_free_return_rate": 0.0,
        "benchmark_symbol": null
    }
}

Error (if applicable)

File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/blankly/frameworks/strategy/strategy.py", line 127, in rest_event
    callback(*args)
  File "/Users/tylercbordeaux/Downloads/MomentumBot/bot.py", line 27, in price_event
    state.interface.market_order(symbol, side='buy', size=blankly.trunc(buy, 2))
  File "/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/site-packages/blankly/exchanges/interfaces/paper_trade/paper_trade_interface.py", line 449, in market_order
    float((self.get_fees(symbol)["taker_fee_rate"])),
KeyError: 'taker_fee_rate'

Platform Info

Additional context Using CoinbasePro Sandbox mode with paper trading settings.

EmersonDove commented 2 years ago

Hey I can't seem to replicate the error. We updated our integration when coinbase changed their API a few weeks ago, are you running the most recent version?

In my testing I'm just making a simple market order on the coinbase sandbox exchange. Is this the correct way to replicate it?

def price_event(price, symbol, state: blankly.StrategyState):
    """ This function will give an updated price every 15 seconds from our definition below """
    print(state.interface.market_order(symbol, 'sell', 0.01))
tylerbordeaux commented 2 years ago

Think it was an api key problem, switched to binance and it's working great now, thanks.