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
Software to help automate collecting crowdsourced annotations using Mechanical Turk.

Video Crowdsourcing Software to help automate collecting crowdsourced annotations using Mechanical Turk. The goal of this project is to enable crowdso

Mike Peven 1 Oct 25, 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
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
The git for the Python Story Utility Package library.

SUP The git for the Python Story Utility Package library. Installation: Install SUP by simply running pip install psup in your terminal. Check out our

Enoki 6 Nov 27, 2022
Modest utility collection for development with AIOHTTP framework.

aiohttp-things Modest utility collection for development with AIOHTTP framework. Documentation https://aiohttp-things.readthedocs.io Installation Inst

Ruslan Ilyasovich Gilfanov 0 Dec 11, 2022
[P]ython [w]rited [B]inary [C]onverter

pwbinaryc [P]ython [w]rited [Binary] [C]onverter You have rights to: Modify the code and use it private (friends are allowed too) Make a page and redi

0 Jun 21, 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 06, 2022
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 02, 2021
Cardano Stakepools: Check for scheduled blocks in current epoch.

ReLeaderLogs For Cardano Stakepool Operators: Lightweight Scheduled Blocks Checker for Current Epoch. No cardano-node Required, data is taken from blo

SNAKE (Cardano Stakepool) 2 Oct 19, 2021
Search, generate & deliver Msfvenom payloads in an quick and easy way

Goal Search, generate & deliver payloads in an quick and easy way Be as simple as possible BUT with all msfvenom payloads. Ever lost time searching th

2 Mar 03, 2022
Minimal Windows system information tool written in Python

wfetch wfetch is a Minimal Windows system information tool written in Python (Only works on Windows) Installation First of all have python installed.

zJairO 3 Jan 24, 2022
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 tool to move and rename Nvidia Share recordings to a more sensible format.

A simple tool to move and rename Nvidia Share recordings to a more sensible format.

Jasper Rebane 8 Dec 23, 2022
A fancy and practical functional tools

Funcy A collection of fancy functional tools focused on practicality. Inspired by clojure, underscore and my own abstractions. Keep reading to get an

Alexander Schepanovski 2.9k Jan 07, 2023
This is a tool to calculate a resulting color of the alpha blending process.

blec: alpha blending calculator This is a tool to calculate a resulting color of the alpha blending process. A gamma correction is enabled and the def

Igor Mikushkin 12 Sep 07, 2022
Python Random Number Genrator

This Genrates Random Numbers. This Random Number Generator was made using python. This software uses Time and Random extension. Download the EXE file and run it to get your answer.

Krish Sethi 2 Feb 03, 2022
An OData v4 query parser and transpiler for Python

odata-query is a library that parses OData v4 filter strings, and can convert them to other forms such as Django Queries, SQLAlchemy Queries, or just plain SQL.

Gorilla 39 Jan 05, 2023
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
Pass arguments by reference—in Python!

byref Pass arguments by reference—in Python! byrefis a decorator that allows Python functions to declare reference parameters, with similar semantics

9 Feb 10, 2022
A BlackJack simulator in Python to simulate thousands or millions of hands using different strategies.

BlackJack Simulator (in Python) A BlackJack simulator to play any number of hands using different strategies The Rules To keep the code relatively sim

Hamid 4 Jun 24, 2022