Netanelshoshan / freqAI-LSTM

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

The logic always SHORT ! #9

Closed duong4sao closed 1 month ago

duong4sao commented 1 month ago

` def populate_entry_trend(self, df: DataFrame, metadata: dict) -> DataFrame: enter_long_conditions = [ df["do_predict"] == 1, df['&-target'] > self.threshold_buy.value, # "threshold_buy": 0.59453 df['volume'] > 0 ]

    enter_short_conditions = [
        df["do_predict"] == 1,
        df['&-target'] < self.threshold_sell.value, # "threshold_sell": 0.80573
        df["volume"] > 0

    ]

    df.loc[
        reduce(lambda x, y: x & y, enter_long_conditions), ["enter_long", "enter_tag"]
    ] = (1, "long")

    df.loc[
        reduce(lambda x, y: x & y, enter_short_conditions), ["enter_short", "enter_tag"]
    ] = (1, "short")

    return df`

This logic may be always SHORT because every condition bellow "threshold_sell".Please check !

MortonPNZ commented 1 month ago

image The problem is not in the logic, but in the fact that the model returns the same value and it does not change dynamically. Even hyperopt changes it, but on the graph it is still a plane. Even if you set the dropout percentage to 99%, it will still be a straight line without fluctuation for 30 days.

The graph shows training for 120 days and backtest for 30 days

Vintelligence commented 1 month ago

image The problem is not in the logic, but in the fact that the model returns the same value and it does not change dynamically. Even hyperopt changes it, but on the graph it is still a plane. Even if you set the dropout percentage to 99%, it will still be a straight line without fluctuation for 30 days.

The graph shows training for 120 days and backtest for 30 days

I saw this as well by debugging and checking what predicted values the model returns. Did you find a solution for this?

MortonPNZ commented 1 month ago

I saw this as well by debugging and checking what predicted values the model returns. Did you find a solution for this?

The only achievement is the complete destruction of the strategy up to 2 trades on the 5m timeframe

duong4sao commented 1 month ago

I think it just a sample how to wirte a LTSM using freqai, The code looks terrible and doesn't work very well.

Netanelshoshan commented 1 month ago

Hi @duong4sao

  1. The uploaded strategy is an example. It generates only short signals bc you should fine-tune the weights.

  2. This repo was initially a Tensorflow plugin for Freqtrade then I ported it to PyTorch and was served as a "how to". The example strategy was something I uploaded bc asked to give an example.

I highly recommend you rewrite the strategy, fine-tune the weights with one of the loss-functions that Freqtrade offer or implement a custom one yourself (they use scikit-learn in the backend).

As much as all of us wants to find the perfect strategy - ALWAYS test your strategy before you push it to prod (aka live).