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

FTXFutures: Exception: No such market: ETH/PERP #210

Closed PaulCelanCoding closed 1 year ago

PaulCelanCoding commented 1 year ago

Description

Hello, first of all thank you very much for this library. Feels very good!

Unfortunately I get the following bug when using FTXFutures

code to reproduce

import blankly

def price_event(price, symbol, state: blankly.FuturesStrategyState):
    state.interface.market_order(symbol, side='buy', position='short', size=1)

if __name__ == "__main__":
    exchange = blankly.FTXFutures()
    strategy = blankly.FuturesStrategy(exchange)

    strategy.add_price_event(price_event, symbol='ETH-USD', resolution='1d')

    strategy.backtest(to='1y', initial_values={'USD': 10000})

settings.json

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


INFO: No portfolio name to load specified, defaulting to the first in the file: (example-portfolio). This is fine if there is only one portfolio in use.
INFO: Live futures trading is untested due to US relations - this prevents blankly developers from integrating with these exchanges. We are looking for someone who is interested in helping us create & test our integrations.
No cached data found for ETH-USD from: 1634989693.2009823 to 1666439293.2009823 at a resolution of 86400 seconds.
Traceback (most recent call last):
  File "C:\Users\xyz\blankly\rsifutures.py", line 13, in <module>
    strategy.backtest(to='1y', initial_values={'USD': 10000})
  File "C:\Users\xyz\anaconda3\envs\freqtrade-conda\lib\site-packages\blankly\frameworks\strategy\strategy.py", line 320, in backtest
    res = self.model.backtest(args={}, initial_values=initial_values, settings_path=settings_path, kwargs=kwargs)
  File "C:\Users\xyz\anaconda3\envs\freqtrade-conda\lib\site-packages\blankly\frameworks\model\model.py", line 64, in backtest
    backtest = self.__backtester.run(args,
  File "C:\Users\xyz\anaconda3\envs\freqtrade-conda\lib\site-packages\blankly\exchanges\interfaces\paper_trade\backtest_controller.py", line 819, in run
    self.prices = self.sync_prices()
  File "C:\Users\xyz\anaconda3\envs\freqtrade-conda\lib\site-packages\blankly\exchanges\interfaces\paper_trade\backtest_controller.py", line 428, in sync_prices
    download = self.interface.get_product_history(symbol,
  File "C:\Users\xyz\anaconda3\envs\freqtrade-conda\lib\site-packages\blankly\exchanges\interfaces\paper_trade\futures\futures_paper_trade_interface.py", line 241, in get_product_history
    return self.interface.get_product_history(symbol, epoch_start, epoch_stop, resolution)
  File "C:\Users\xyz\anaconda3\envs\freqtrade-conda\lib\site-packages\blankly\exchanges\interfaces\ftx_futures\ftx_futures_interface.py", line 330, in get_product_history
    return FTXInterface.ftx_product_history(self.calls,self.to_exchange_symbol(symbol), epoch_start, epoch_stop, resolution)
  File "C:\Users\xyz\anaconda3\envs\freqtrade-conda\lib\site-packages\blankly\exchanges\interfaces\ftx\ftx_interface.py", line 524, in ftx_product_history
    response = api.get_product_history(symbol, window_open, window_close, resolution)
  File "C:\Users\xyz\anaconda3\envs\freqtrade-conda\lib\site-packages\blankly\exchanges\interfaces\ftx\ftx_api.py", line 111, in get_product_history
    return self._signed_get(
  File "C:\Users\xyz\anaconda3\envs\freqtrade-conda\lib\site-packages\blankly\exchanges\interfaces\ftx\ftx_api.py", line 71, in _signed_get
    return self._signed_request('GET', path, params=params)
  File "C:\Users\xyz\anaconda3\envs\freqtrade-conda\lib\site-packages\blankly\exchanges\interfaces\ftx\ftx_api.py", line 48, in _signed_request
    return self._handle_response(result)
  File "C:\Users\xyz\anaconda3\envs\freqtrade-conda\lib\site-packages\blankly\exchanges\interfaces\ftx\ftx_api.py", line 87, in _handle_response
    raise Exception(result['error'])
Exception: No such market: ETH/PERP```

## Platform Info
 - Python version: Python 3.9.12
 - Platform: Windows 11

Thanks a lot and kind regards,
PaulCelanCoding
EmersonDove commented 1 year ago

Hey Paul, glad you like the library,

We use the dash format so try ETH-PERP

liuqiba commented 1 year ago

I had the same error ,and I tried "ETH-PERP" ,still wrong!