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

Much Faster Version of Supertrend.py #242

Open
perkmeister opened this issue Feb 14, 2022 · 9 comments
Open

Much Faster Version of Supertrend.py #242

perkmeister opened this issue Feb 14, 2022 · 9 comments
Labels

Comments

@perkmeister
Copy link

Describe your environment

  • Operating system: Windows10 Pro
  • Python Version: 3.8.10
  • CCXT version: 1.72.36
  • Freqtrade Version: develop-119d4d520
  • Strategy: Supertrend.py

Describe the problem:

This is not strictly a problem per se, but Supertrend.py is very slow due to dataframe accesses within the loops that it uses. It also uses the old way of creating columns during hyperopting by creating multiple columns in the dataframe, and can result in performance warnings.

Here is an updated version that uses numpy arrays in place of the dataframe accesses within the loops, and this has resulted in a 46 times speed improvement with the supertrend() function when testing ATOM/USDT over the timerange 20210801-20220201. Also dataframe columns are now calculated in populate_buy_trend() rather than creating multiple columns in the dataframe.

As far as I can tell the behaviour is identical to the Supertrend.py strategy, except much faster.

These are the results with the default settings using ATOM/USDT over the range above showing the results are exactly the same and the difference in speed. I've attached the updated FastSupertrend.py.

FastSupertrend1
FastSupertrend2
FastSupertrend.py.TXT

@perkmeister perkmeister added the bug Something isn't working label Feb 14, 2022
@xmatthias
Copy link
Member

In general, i'm not a huge fan of inlining indicators to a strategy (i know the original strategy did that, too).

instead, i'd want to compare the indicator performance with the one in pandas_ta - maybe the performance enhancement is already there (and if not, it might be a good enhancement).

At either rate, i'd rather have this as a pull request contributing the strategy directly, rather than a txt file appended to an issue, as the first makes it

  • easier to review / test
  • clear who authored it
  • easier to refind

@xmatthias xmatthias added question and removed bug Something isn't working labels Jul 30, 2022
@FahadAziz
Copy link

FahadAziz commented Nov 4, 2022

Hi, I know this is an old issue but I am facing an issue with the running the strategy. Everything is set correctly and I hyper opt and backtested the strategy in the futures market everything is running smoothly but we I run it live it does not buy or sell anything. I am running the latest stable version 2022.10 on linux and Python 3.10.4. no errors whatsoever but the bot does not buy anything with this strategy. Backtesting says it averages almost 70 transactions a day but it has been almost 24 hours with no transactions. Am I missing something?

@xmatthias
Copy link
Member

keep in mind that backtesting tells you an average of 70 trades per day - so it could just as well be weeks without a trade followed by weeks with 200 trades per day.

You can however always look at freqUI to see signals - if there's been signals throughout the day (but no trades) - then check the logs if something happened (maybe there's an unrelated miss-configuration that's causing trades to not be entered)

@FahadAziz
Copy link

Thanks Matt, signals are there but bot is not trading at all and there are no errors in the log only heartbeat. Bot was working fine until I stopped it and did the update to the latest version and run this strategy then it stopped working all together. I tried running the old strategy and it worked just fine. Here is my strategy file
FastSupertrend.py.txt

@stawari
Copy link

stawari commented Feb 3, 2023

Hi, sorry about my question if it not right place to ask, but I just want to get some suggest. I'm working on SuperTrend file also, but the Strategy not showing the line in chart like TradingView. Anyway that I can made it showing the line look this in Freqtade Chart?
image

@clbenoit
Copy link

clbenoit commented Feb 3, 2023

Hi,
Same issue than @FahadAziz in dry run for FastSuperTrend strategy. Backtesting on the last day says 31 entries... I'll look deeper into it

@clbenoit
Copy link

clbenoit commented Feb 3, 2023

Replacing
last_row = dataframe.tail(1).index.item()
with
last_row = len(df)
fixed it

@vassilux
Copy link

Hi all,

I've been testing this strategy and I believe the code needs to be modified for live trading:

def custom_entry_price(self, pair: str, current_time: datetime, proposed_rate: float, entry_tag: str, side: str, **kwargs) -> float: if 'live' in self.config and self.config['live']: # Get ticker in live mode ticker = self._freqtrade.exchange.get_ticker(pair) return ticker['last'] else: # Use last candle's close in backtesting mode dataframe, last_updated = self.dp.get_analyzed_dataframe(pair=pair, timeframe=self.timeframe) return dataframe['close'].iat[-1]

In live mode, I am not able to execute any trades. I suspect the issue might be related to how the entry price is determined in the live environment. Any insights or suggestions would be greatly appreciated.

Thank for your advise

@saketina
Copy link

Hello,

Just wanted to ask if anyone else used this strategy and managed to get it working fully and get it to actually get some profit...

Thank you for your time :3

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

7 participants