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
Report Bobcat Status to Google Sheets

bobcat-status-reporter Report Bobcat Status to Google Sheets Why? I recently relocated my miner from my root into the attic. Bobcat recommends operati

Jasmit Tarang 3 Sep 22, 2021
Cleaning-utils - a collection of small Python functions and classes which make cleaning pipelines shorter and easier

cleaning-utils [] [] [] cleaning-utils is a collection of small Python functions

4 Aug 31, 2022
This utility synchronises spelling dictionaries from various tools with each other.

This utility synchronises spelling dictionaries from various tools with each other. This way the words that have been trained on MS Office are also correctly checked in vim or Firefox. And vice versa

Patrice Neff 2 Feb 11, 2022
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

1 Dec 16, 2021
A python app which aggregates and splits costs from multiple public cloud providers into a csv

Cloud Billing This project aggregates the costs public cloud resources by accounts, services and tags by importing the invoices from public cloud prov

1 Oct 04, 2022
cssOrganizer - organize a css file by grouping them into categories

This python project was created to scan through a CSS file and produce a more organized CSS file by grouping related CSS Properties within selectors. Created in my spare time for fun and my own utili

Andrew Espindola 0 Aug 31, 2022
Application for easy configuration of swap file and swappiness priority in slackware and others linux distributions.

Swap File Program created with the objective of assisting in the configuration of swap file in Distributions such as Slackware. Required packages: pyt

Mauricio Ferrari 3 Aug 06, 2022
Implementing C++ Semantics in Python

Implementing C++ Semantics in Python

Tamir Bahar 7 May 18, 2022
Python bytecode manipulation and import process customization to do evil stuff with format strings. Nasty!

formathack Python bytecode manipulation and import process customization to do evil stuff with format strings. Nasty! This is an answer to a StackOver

Michiel Van den Berghe 5 Jan 18, 2022
Find unused resource keys in properties files in a Salesforce Commerce Cloud project and get rid of them.

Find Unused Resource Keys Find unused resource keys in properties files in a Salesforce Commerce Cloud project and get rid of them. It looks through a

Noël 5 Jan 08, 2022
Find version automatically based on git tags and commit messages.

GIT-CONVENTIONAL-VERSION Find version automatically based on git tags and commit messages. The tool is very specific in its function, so it is very fl

0 Nov 07, 2021
Simple python module to get the information regarding battery in python.

Battery Stats A python3 module created for easily reading the current parameters of Battery in realtime. It reads battery stats from /sys/class/power_

Shreyas Ashtamkar 5 Oct 21, 2022
Experimental python optimistic rollup fraud-proof generation

Macula Experimental python optimistic rollup fraud-proof generation tech by @protolambda. Working on a python version for brevity and simplicity. See

Diederik Loerakker 30 Sep 01, 2022
Color box that provides various colors‘ rgb decimal code.

colorbox Color box that provides various colors‘ rgb decimal code

1 Dec 07, 2021
Know your customer pipeline in apache air flow

KYC_pipline Know your customer pipeline in apache air flow For a successful pipeline run take these steps: Run you Airflow server Admin - connection

saeed 4 Aug 01, 2022
Backman is a random/fixed background image setter for wlroots based compositors

backman Backman is a random/fixed background image setter for wlroots based compositors Dependencies: The program depends on swaybg, python3-toml (or

Hemish 3 Mar 09, 2022
Generates a random prnt.sc link and display image.

Generates a random prnt.sc link and display image.

Emirhan 3 Oct 08, 2021
ULID implementation for Python

What is this? This is a port of the original JavaScript ULID implementation to Python. A ULID is a universally unique lexicographically sortable ident

Martin Domke 158 Jan 04, 2023
A simple dork generator written in python that outputs dorks with the domain extensions you enter

Dork Gen A simple dork generator written in python that outputs dorks with the domain extensions you enter in a ".txt file". Usage The code is pretty

Z3NToX 4 Oct 30, 2022
Tool for generating Memory.scan() compatible instruction search patterns

scanpat Tool for generating Frida Memory.scan() compatible instruction search patterns. Powered by r2. Examples $ ./scanpat.py arm.ks:64 'sub sp, sp,

Ole André Vadla Ravnås 13 Sep 19, 2022