A script to parse and display buy_tag and sell_reason for freqtrade backtesting trades

Overview

freqtrade-buyreasons

A script to parse and display buy_tag and sell_reason for freqtrade backtesting trades

Usage

Copy the buy_reasons.py script into your freqtrade/scripts folder. You then need to backtest with the --export options enabled in freqtrade so that this script has the right data to work with:

freqtrade backtesting -c --timeframe 5m --strategy --timerange= --export=trades --export-filename=user_data/backtest_results/ -

Then you can run:

buy_reasons.py -c -s -t -g<[0,1,2,3,4]> [-l ]

The -l option is the same as the --datadir option in freqtrade, in case you have your downloaded historic data in a different folder to user_data/data/

Example:

buy_reasons.py -c my_config.json -s DoNothingStrategy -t 20211001- -g0,1,2

Comments
  • No trades to show

    No trades to show

    I don't seem to get through this error. Even though I have checked the backtest_results dir. It has three files one meta, json backtest results and the pickled signals. But when I run the script it seems to process the pairs but then throw the message 'no trades to show'.

    Processing 71 pairs...
    Strategy258btc
    \_ No trades to show
    

    Could it be a special case not covered by the if conditions under the following sections?

    for sname in stratnames:
            bigdf = pd.DataFrame()
    
            print(f"{sname}")
            for tpair, trades in analysed_trades_dict[sname].items():
                bigdf = pd.concat([bigdf, trades], ignore_index=True)
    
            if outfile:
                outfile.write(bigdf.to_csv())
            else:
                bigdf.to_csv(f'{sname}_all_trade_buys.csv')
    
            if (start_date is not None):
                bigdf = bigdf.loc[(bigdf['date'] > start_date)]
    
            if (end_date is not None):
                bigdf = bigdf.loc[(bigdf['date'] < end_date)]
    
            if bigdf.shape[0] > 0 and ('enter_reason' in bigdf.columns):
                if group is not None: .......................
    

    Would it have been better to use try & except somewhere?

    opened by moinonin 1
  • pickled_signal_candles' referenced before assignment

    pickled_signal_candles' referenced before assignment

    I got the following error when running the buy_reasons script

    Loading backtest trades data for Strategy258btc ...
    Loading all candle data: 20220101- [/home/defi/Desktop/portfolio/projects/python/crypto/freqtrade/user_data/data/binance]
    Traceback (most recent call last):
      File "/home/defi/Desktop/portfolio/projects/python/crypto/freqtrade/scripts/buy_reasons.py", line 585, in <module>
        main()
      File "/home/defi/Desktop/portfolio/projects/python/crypto/freqtrade/scripts/buy_reasons.py", line 479, in main
        parallel=parallel, pickled_signal_candles=pickled_signal_candles)
    UnboundLocalError: local variable 'pickled_signal_candles' referenced before assignment
    

    Any workaround is appreciated!

    opened by moinonin 1
  • Update buy_reasons.py

    Update buy_reasons.py

    Multiple tweaks:

    • clean up use of --no-parallel
    • add --timeframe parameter
    • get data format from config instead of a parameter
    • get pairlist from trades dataframe if pairlist is empty
    opened by rokups 1
  • error with Namespace object

    error with Namespace object

    (.env) root@m2382:~/ft# python3 scripts/buy_reasons.py -c user_data/configbt.json -s Tester -g0,1,2
    Traceback (most recent call last):
      File "scripts/buy_reasons.py", line 424, in <module>
        main()
      File "scripts/buy_reasons.py", line 270, in main
        if args.group is not None and args.indicators is not None:
    AttributeError: 'Namespace' object has no attribute 'indicators'
    

    I experienced this error

    opened by txtr99 0
  • tab spacing error

    tab spacing error

    (.env) root@m2382:~/ft# python3 scripts/buy_reasons.py -c user_data/configbt.json -s Tester -g0,1,2
      File "scripts/buy_reasons.py", line 275
        parallel = False
                       ^
    TabError: inconsistent use of tabs and spaces in indentation
    

    This error is coming up although I don't see anything wrong with line 275..

    opened by txtr99 1
Releases(v1.0)
Owner
Robert Davey
Robert Davey
Parse URLs for DOIs, PubMed identifiers, PMC identifiers, arXiv identifiers, etc.

citation-url Parse URLs for DOIs, PubMed identifiers, PMC identifiers, arXiv identifiers, etc. This module has a single parse() function that takes in

Charles Tapley Hoyt 2 Feb 12, 2022
Generates a random prnt.sc link and display image.

Generates a random prnt.sc link and display image.

Emirhan 3 Oct 8, 2021
This python program will display all SSID usernames and SSID passwords you once connected to your laptop

Windows-Wifi-password-extractor This python program will display all SSID usernames and SSID passwords you once connected to your laptop How to run th

Bhaskar Pal 3 Apr 26, 2022
Display your calendar on the wallpaper.

wallCal Have your calendar appear as the wallpaper. disclaimer Use at your own risk. Don't blame me if you miss a meeting :-) Some parts of the script

null 7 Jun 14, 2022
Helper script to bootstrap a Python environment with the tools required to build and install packages.

python-bootstrap Helper script to bootstrap a Python environment with the tools required to build and install packages. Usage $ python -m bootstrap.bu

Filipe Laíns 7 Oct 6, 2022
MicroMIUI - Script to optimize miui and not only

MicroMIUI - Script to optimize miui and not only

Groiznyi-Studio 1 Nov 2, 2021
Script to rename and resize folders of images

script to rename and resize folders of images

Tega Brain 2 Oct 29, 2021
An okayish python script to generate a random Euler circuit with given number of vertices and edges.

Euler-Circuit-Test-Case-Generator An okayish python script to generate a random Euler circuit with given number of vertices and edges. Executing the S

Alen Antony 1 Nov 13, 2021
A script copies movie and TV files to your GD drive, or create Hard Link in a seperate dir, in Emby-happy struct.

torcp A script copies movie and TV files to your GD drive, or create Hard Link in a seperate dir, in Emby-happy struct. Usage: python3 torcp.py -h Exa

ccf2012 105 Dec 22, 2022
This script allows you to retrieve all functions / variables names of a Python code, and the variables values.

Memory Extractor This script allows you to retrieve all functions / variables names of a Python code, and the variables values. How to use it ? The si

Venax 2 Dec 26, 2021
A Python script that parses and checks public proxies. Multithreading is supported.

A Python script that parses and checks public proxies. Multithreading is supported.

LevPrav 7 Nov 25, 2022
Script to decrypt / import chromium (edge/chrome) cookies

Cloonie Script to decrypt / import chromium (edge/chrome) cookies. Requirements Install the python dependencies via pip: pip install -r requirements.t

Lorenzo Bernardi 5 Sep 13, 2022
cpp20.py is a Python script to compile C++20 code using modules.

cpp20.py is a Python script to compile C++20 code using modules. It browses the source files to determine their dependencies. Then, it compiles then in order using the correct flags.

Julien VERNAY 6 Aug 26, 2022
Python script to launch burp scans automatically

SimpleAutoBurp Python script that takes a config.json file as config and uses Burp Suite Pro to scan a list of websites.

Adan Álvarez 26 Jul 18, 2022
Simple script to export contacts from telegram into vCard file

Telegram Contacts Exporter Simple script to export contacts from telegram into vCard file Getting Started Prerequisites You must to put your Telegram

Pere Antoni 1 Oct 17, 2021
aws ec2.py companion script to generate sshconfigs with auto bastion host discovery

ec2-bastion-sshconfig This script will interate over instances found by ec2.py and if those instances are not publically accessible it will search the

Steve Melo 1 Sep 11, 2022
python script to generate color coded resistor images

Resistor image generator I got nerdsniped into making this. It's not finished at all, and the code is messy. The end goal it generate a whole E-series

MichD 1 Nov 12, 2021
A python script to generate wallpaper

wallpaper eits Warning You need to set the path to Robot Mono font in the source code. (Settings are in the main function) Usage A script that given a

Henrique Tsuyoshi Yara 5 Dec 2, 2021
Python script to get some stats on nodes in a Blender material nodetree

Python script to get some stats on nodes in a Blender material nodetree. It counts the nodes, the node types and the max deep level for group nodes.

Alek Mugnozzo 2 Sep 3, 2022