Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backtesting - ValueError: Out of range float values are not JSON compliant #49

Open
rapcmia opened this issue Jun 25, 2024 · 0 comments
Labels
bot orchestration bug Something isn't working

Comments

@rapcmia
Copy link
Contributor

rapcmia commented Jun 25, 2024

Describe the bug

When running backtesting for kucoin with 3 order levels on a total amount of 70usdt, im getting an error of Expecting value: line 1 column 1 (char 0). I tried to increase the total amount but getting same error

image

Check the backend-api logs found:

INFO:     192.168.0.2:34744 - "GET /is-docker-running HTTP/1.1" 200 OK
INFO:     192.168.0.2:34750 - "GET /all-controller-configs HTTP/1.1" 200 OK
/opt/conda/envs/backend-api/lib/python3.10/site-packages/hummingbot/strategy_v2/backtesting/backtesting_engine_base.py:279: RuntimeWarning: divide by zero encountered in scalar divide
  sharpe_ratio = returns.mean() / returns.std() if len(returns) > 1 else 0
INFO:     192.168.0.2:34760 - "POST /run-backtesting HTTP/1.1" 500 Internal Server Error
ERROR:    Exception in ASGI application
Traceback (most recent call last):
  File "/opt/conda/envs/backend-api/lib/python3.10/site-packages/uvicorn/protocols/http/h11_impl.py", line 396, in run_asgi
    result = await app(  # type: ignore[func-returns-value]
  File "/opt/conda/envs/backend-api/lib/python3.10/site-packages/uvicorn/middleware/proxy_headers.py", line 70, in __call__
    return await self.app(scope, receive, send)
  File "/opt/conda/envs/backend-api/lib/python3.10/site-packages/fastapi/applications.py", line 1054, in __call__
    await super().__call__(scope, receive, send)
  File "/opt/conda/envs/backend-api/lib/python3.10/site-packages/starlette/applications.py", line 123, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/opt/conda/envs/backend-api/lib/python3.10/site-packages/starlette/middleware/errors.py", line 186, in __call__
    raise exc
  File "/opt/conda/envs/backend-api/lib/python3.10/site-packages/starlette/middleware/errors.py", line 164, in __call__
    await self.app(scope, receive, _send)
  File "/opt/conda/envs/backend-api/lib/python3.10/site-packages/starlette/middleware/exceptions.py", line 65, in __call__
    await wrap_app_handling_exceptions(self.app, conn)(scope, receive, send)
  File "/opt/conda/envs/backend-api/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "/opt/conda/envs/backend-api/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "/opt/conda/envs/backend-api/lib/python3.10/site-packages/starlette/routing.py", line 756, in __call__
    await self.middleware_stack(scope, receive, send)
  File "/opt/conda/envs/backend-api/lib/python3.10/site-packages/starlette/routing.py", line 776, in app
    await route.handle(scope, receive, send)
  File "/opt/conda/envs/backend-api/lib/python3.10/site-packages/starlette/routing.py", line 297, in handle
    await self.app(scope, receive, send)
  File "/opt/conda/envs/backend-api/lib/python3.10/site-packages/starlette/routing.py", line 77, in app
    await wrap_app_handling_exceptions(app, request)(scope, receive, send)
  File "/opt/conda/envs/backend-api/lib/python3.10/site-packages/starlette/_exception_handler.py", line 64, in wrapped_app
    raise exc
  File "/opt/conda/envs/backend-api/lib/python3.10/site-packages/starlette/_exception_handler.py", line 53, in wrapped_app
    await app(scope, receive, sender)
  File "/opt/conda/envs/backend-api/lib/python3.10/site-packages/starlette/routing.py", line 72, in app
    response = await func(request)
  File "/opt/conda/envs/backend-api/lib/python3.10/site-packages/fastapi/routing.py", line 307, in app
    response = actual_response_class(content, **response_args)
  File "/opt/conda/envs/backend-api/lib/python3.10/site-packages/starlette/responses.py", line 184, in __init__
    super().__init__(content, status_code, headers, media_type, background)
  File "/opt/conda/envs/backend-api/lib/python3.10/site-packages/starlette/responses.py", line 41, in __init__
    self.body = self.render(content)
  File "/opt/conda/envs/backend-api/lib/python3.10/site-packages/starlette/responses.py", line 187, in render
    return json.dumps(
  File "/opt/conda/envs/backend-api/lib/python3.10/json/__init__.py", line 238, in dumps
    **kw).encode(obj)
  File "/opt/conda/envs/backend-api/lib/python3.10/json/encoder.py", line 199, in encode
    chunks = self.iterencode(o, _one_shot=True)
  File "/opt/conda/envs/backend-api/lib/python3.10/json/encoder.py", line 257, in iterencode
    return _iterencode(o, 0)
ValueError: Out of range float values are not JSON compliant
2024-06-25 12:24:54,084 - apscheduler.executors.default - WARNING - Run time of job "update_active_bots (trigger: interval[0:00:10], next run at: 2024-06-25 12:25:02 UTC)" was missed by 0:00:01.109299
INFO:     192.168.0.2:42104 - "GET /is-docker-running HTTP/1.1" 200 OK
INFO:     192.168.0.2:42106 - "GET /all-controller-configs HTTP/1.1" 200 OK

Steps to reproduce bug

  1. Clone https://github.com/hummingbot/deploy and run bash setup.sh to setup
  2. Once setup is complete, open the deploy directory and go to bots/conf/controllers
  3. Create a .yml file and paste the config below.( This was created from dashboard )
    buy_amounts_pct:
    - 0.16666666666666666
    - 0.16666666666666666
    - 0.16666666666666666
    buy_spreads:
    - 0.01
    - 0.015
    - 0.02
    candles_config: []
    connector_name: kucoin
    controller_name: pmm_simple
    controller_type: market_making
    cooldown_time: 60.0
    executor_refresh_time: 180.0
    id: robin-compute_0.2
    leverage: 20
    manual_kill_switch: null
    position_mode: HEDGE
    sell_amounts_pct:
    - 0.16666666666666666
    - 0.16666666666666666
    - 0.16666666666666666
    sell_spreads:
    - 0.01
    - 0.015
    - 0.02
    stop_loss: 0.015
    take_profit: 0.006999999999999999
    take_profit_order_type: 2
    time_limit: 900
    total_amount_quote: 70
    trading_pair: XCAD-USDT
    trailing_stop:
      activation_price: 0.018
      trailing_delta: 0.002
    
  4. Reload dashboard page, go to config generator
  5. Load the config then run backtest
@rapcmia rapcmia added bug Something isn't working bot orchestration labels Jun 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bot orchestration bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant