Netanelshoshan / freqAI-LSTM

A Trading Model Utilizing a Dynamic Weighting and Aggregate Scoring System with LSTM Networks
MIT License
88 stars 27 forks source link

math domain error #3

Closed JulAius closed 3 months ago

JulAius commented 4 months ago

Hello, i got this error in dry-run :

2024-05-28 21:00:07.354430: W tensorflow/core/framework/local_rendezvous.cc:404] Local rendezvous is aborting with status: OUT_OF_RANGE: End of sequence
/usr/local/lib/python3.12/contextlib.py:158: UserWarning: Your input ran out of data; interrupting training. Make sure that your dataset or generator can generate at least `steps_per_epoch * epochs` batches. You may need to use the `.repeat()` function when building your dataset.
  self.gen.throw(value)
2024-05-28 21:00:07,355 - freqtrade.strategy.strategy_wrapper - WARNING - Strategy caused the following exception: math domain error<bound method IStrategy._analyze_ticker_internal of <LSTMStrategy2.LSTMStrategy2 object at 0x7f1bea6c1c70>>
2024-05-28 21:00:07,356 - freqtrade.strategy.interface - WARNING - Unable to analyze candle (OHLCV) data for pair BTC/USDT:USDT: math domain error

do you know what is the problem please? thanks a lot for your help

Netanelshoshan commented 4 months ago

Hi,

Didn't have that problem. Can you share more info about your setup (OS, TensorFlow and config - make sure to send only the freqai part ).

In addition, make sure that your config.json file has the following two fields:

"dataformat_ohlcv": "json", "dataformat_trades": "jsongz",

You're welcome!

JulAius commented 4 months ago

Hi, thank you for your time I'm using the docker image : tensorflow/tensorflow:latest-gpu with : TensorFlow version: 2.16.1

Here's the “freqai” part of the configuration, I haven't changed any values.

"freqai": {
    "enabled": true,
    "keras": true,
    "model_save_type": "keras",
    "identifier": "tf_dryrun_0.0.2",
    "optuna_hyperopt": false,
    "backtest_period_days": 120,
    "train_period_days": 360,
    "conv_width": 2,
    "expiration_hours": 4,
    "purge_old_models": 5,
    "save_backtest_models": true,
    "track_performance": true,
    "auto_training_window": true,
    "write_metrics_to_disk": true,
    "activate_tensorboard": false,
    "feature_parameters": {
      "include_corr_pairlist": [
        "BTC/USDT:USDT"
      ],
      "include_timeframes": [
        "1h",
        "4h"
      ],
      "label_period_candles": 12,
      "DI_threshold": 1,
      "weight_factor": 0.65,
      "include_shifted_candles": 5,
      "indicator_periods_candles": [
        10
      ],
      "noise_standard_deviation": 0.1,
      "buffer_train_data_candles": 20
    },
    "data_split_parameters": {
      "test_size": 0.2,
      "random_state": 42,
      "shuffle": false
    },
    "model_training_parameters": {
      "num_lstm_layers": 3,
      "epochs": 45,
      "batch_size": 32,
      "learning_rate": 0.001,
      "dropout_rate": 0.3
    }

I also include the 2 formats in my configuration:

  "trading_mode": "futures",
  "margin_mode": "isolated",
  "max_open_trades": -1,
  "stake_currency": "USDT",
  "stake_amount": 2600,
  "tradable_balance_ratio": 0.99,
  "fiat_display_currency": "USD",
  "dry_run": true,
  "strategy": "LSTMStrategy",
  "freqaimodel": "LSTMRegressor",
  "dataformat_ohlcv": "json",
  "dataformat_trades": "jsongz",
  "cancel_open_orders_on_exit": false,
  "dry_run_wallet": 11000,
  "unfilledtimeout": {
    "entry": 10,
    "exit": 30

I can run the strategy in backtesting but not in dry run. I tested with different exchange (Binance, Okx, Gateio) same errors.

thank you in advance for your precious help

Netanelshoshan commented 4 months ago

Alright, I'll take a look into it.

Will you please tell me the version of Freqtrade you're using so I could try to pinpoint the diff / change in code ..

Best, Nate

Netanelshoshan commented 4 months ago

And I think I'll just port this to PyTorch since It has better GPU support across platforms and overall faster dev (since one won't need to edit the core of freqAI (maybe just increasing the timeframe limit from 5m to a bigger one))

JulAius commented 4 months ago

Alright, I'll take a look into it.

Will you please tell me the version of Freqtrade you're using so I could try to pinpoint the diff / change in code ..

Best, Nate

Hello Nate, Here is my current version of freqtrade : freqtrade 2024.4

which version of freqtrade do you recommend ?

thank you very much for your time and expert feedback, have a nice day

Netanelshoshan commented 4 months ago

Hi,

I'd recommend using the latest one - dev branch. pip install -r requirements-dev.txt && pip install -e . With my latest update, I encourage you to use the early version of the pytorch model. All you need to do is to copy and paste the files. Use the same config.json, add the torch config I added in my pull request and use the same example strategy. It will work right out of the box. No edits needed.

You're welcome, Nate

JulAius commented 4 months ago

Hi,

I'd recommend using the latest one - dev branch. pip install -r requirements-dev.txt && pip install -e . With my latest update, I encourage you to use the early version of the pytorch model. All you need to do is to copy and paste the files. Use the same config.json, add the torch config I added in my pull request and use the same example strategy. It will work right out of the box. No edits needed.

You're welcome, Nate

Hi Nate, Works perfectly with Pytorch model and new freqtrade version (freqtrade 2024.4) in dry run,

thank you very much you are the Goat :)

Netanelshoshan commented 4 months ago

You're welcome! I'll appreciate if you keep me posted if you tackle any problems or bugs. I'm gonna keep this issue open.

Netanelshoshan commented 3 months ago

It’s Working for me. Closing for now.