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) [email protected]:~/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) [email protected]:~/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
Hide new MacBook Pro notch with black wallpaper.

Hide new MacBook Pro notch with black wallpaper.

Wang Chao 1 Oct 27, 2021
Check username

Checker-Oukee Check username It checks the available usernames and creates a new account for them Doesn't need proxies Create a file with usernames an

4 Jun 05, 2022
Functional UUIDs for Python.

🏷️FUUID stands for Functional Universally Unique IDentifier. FUUIDs are compatible with regular UUIDs but are naturally ordered by generation time, collision-free and support succinct representations

Phil Demetriou 147 Oct 27, 2022
Basic loader is a small tool that will help you generating Cloudflare cookies

Basic Loader Cloudflare cookies loader This tool may help some people getting valide cloudflare cookies Installation 🔌 : pip install -r requirements.

IHateTomLrge 8 Mar 30, 2022
Check subdomains for Open S3 buckets

SuBuket v1.0 Check subdomains for Open S3 buckets Coded by kaiz3n Basically, this tool makes use of another tool (sublist3r) to fetch subdomains, and

kaiz3n 4 Dec 29, 2021
Python code to divide big numbers

divide-big-num Python code to divide big numbers

VuMinhNgoc 1 Oct 15, 2021
Tools for binary data on cassette

Micro Manchester Tape Storage Tools for storing binary data on cassette Includes: Python script for encoding Arduino sketch for decoding Eagle CAD fil

Zack Nelson 28 Dec 25, 2022
Abstraction of a Unit, includes convertions and basic operations.

Units Abstraction of a Unit, includes convertions and basic operations. ------ EXAMPLE : Free Fall (No air resistance) ------- from units_test import

1 Dec 23, 2021
Runes - Simple Cookies You Can Extend (similar to Macaroons)

Runes - Simple Cookies You Can Extend (similar to Macaroons) is a paper called "Macaroons: Cookies with Context

Rusty Russell 22 Dec 11, 2022
A Python package implementing various colour checker detection algorithms and related utilities.

A Python package implementing various colour checker detection algorithms and related utilities.

colour-science 147 Dec 29, 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
A Python library for reading, writing and visualizing the OMEGA Format

A Python library for reading, writing and visualizing the OMEGA Format, targeted towards storing reference and perception data in the automotive context on an object list basis with a focus on an urb

Institut für Kraftfahrzeuge, RWTH Aachen, ika 12 Sep 01, 2022
A Python package for floating-point binary fractions. Do math in base 2!

An implementation of a floating-point binary fractions class and module in Python. Work with binary fractions and binary floats with ease!

10 Oct 29, 2022
a simple function that randomly generates and applies console text colors

ChangeConsoleTextColour a simple function that randomly generates and applies console text colors This repository corresponds to my Python Functions f

Mariya 6 Sep 20, 2022
Astvuln is a simple AST scanner which recursively scans a directory, parses each file as AST and runs specified method.

Astvuln Astvuln is a simple AST scanner which recursively scans a directory, parses each file as AST and runs specified method. Some search methods ar

Bitstamp Security 7 May 29, 2022
Hot reloading for Python

Hot reloading for Python

Olivier Breuleux 769 Jan 03, 2023
Teleport Ur Logs with Love

Whatever you pipe into tull, will get a unique UUID and the data gets stored locally - accessible via a flask server with simple endpoints. You can use ngrok or localtunnel then to share it outside L

Lokendra Sharma 11 Jul 30, 2021
Password generator

Password generator technologies used What is? It is Password generator How to Download? Download on releases Clone repo git clone https://github.com/m

Miek 1 Nov 02, 2021
Pampy: The Pattern Matching for Python you always dreamed of.

Pampy: Pattern Matching for Python Pampy is pretty small (150 lines), reasonably fast, and often makes your code more readable and hence easier to rea

Claudio Santini 3.5k Jan 06, 2023
Automatic generator of readmes for git repositories (Includes file' listing)

Readme Generator We are bored of write the same things once and once again. We trust in the comments made inside of our files, and we decided to autom

Natalia Vera Duran 6 Jul 20, 2021