Freqtrade is a free and open source crypto trading bot written in Python

Freqtrade

Freqtrade CI Coverage Status Documentation Maintainability

Freqtrade is a free and open source crypto trading bot written in Python. It is designed to support all major exchanges and be controlled via Telegram. It contains backtesting, plotting and money management tools as well as strategy optimization by machine learning.

freqtrade

Disclaimer

This software is for educational purposes only. Do not risk money which you are afraid to lose. USE THE SOFTWARE AT YOUR OWN RISK. THE AUTHORS AND ALL AFFILIATES ASSUME NO RESPONSIBILITY FOR YOUR TRADING RESULTS.

Always start by running a trading bot in Dry-run and do not engage money before you understand how it works and what profit/loss you should expect.

We strongly recommend you to have coding and Python knowledge. Do not hesitate to read the source code and understand the mechanism of this bot.

Exchange marketplaces supported

Documentation

We invite you to read the bot documentation to ensure you understand how the bot is working.

Please find the complete documentation on our website.

Features

  • Based on Python 3.7+: For botting on any operating system - Windows, macOS and Linux.
  • Persistence: Persistence is achieved through sqlite.
  • Dry-run: Run the bot without paying money.
  • Backtesting: Run a simulation of your buy/sell strategy.
  • Strategy Optimization by machine learning: Use machine learning to optimize your buy/sell strategy parameters with real exchange data.
  • Edge position sizing Calculate your win rate, risk reward ratio, the best stoploss and adjust your position size before taking a position for each specific market. Learn more.
  • Whitelist crypto-currencies: Select which crypto-currency you want to trade or use dynamic whitelists.
  • Blacklist crypto-currencies: Select which crypto-currency you want to avoid.
  • Manageable via Telegram: Manage the bot with Telegram.
  • Display profit/loss in fiat: Display your profit/loss in 33 fiat.
  • Daily summary of profit/loss: Provide a daily summary of your profit/loss.
  • Performance status report: Provide a performance status of your current trades.

Quick start

Freqtrade provides a Linux/macOS script to install all dependencies and help you to configure the bot.

git clone -b develop https://github.com/freqtrade/freqtrade.git 
cd freqtrade
./setup.sh --install

For any other type of installation please refer to Installation doc.

Basic Usage

Bot commands

usage: freqtrade [-h] [-V]
                 {trade,create-userdir,new-config,new-hyperopt,new-strategy,download-data,convert-data,convert-trade-data,backtesting,edge,hyperopt,hyperopt-list,hyperopt-show,list-exchanges,list-hyperopts,list-markets,list-pairs,list-strategies,list-timeframes,show-trades,test-pairlist,plot-dataframe,plot-profit}
                 ...

Free, open source crypto trading bot

positional arguments:
  {trade,create-userdir,new-config,new-hyperopt,new-strategy,download-data,convert-data,convert-trade-data,backtesting,edge,hyperopt,hyperopt-list,hyperopt-show,list-exchanges,list-hyperopts,list-markets,list-pairs,list-strategies,list-timeframes,show-trades,test-pairlist,plot-dataframe,plot-profit}
    trade               Trade module.
    create-userdir      Create user-data directory.
    new-config          Create new config
    new-hyperopt        Create new hyperopt
    new-strategy        Create new strategy
    download-data       Download backtesting data.
    convert-data        Convert candle (OHLCV) data from one format to
                        another.
    convert-trade-data  Convert trade data from one format to another.
    backtesting         Backtesting module.
    edge                Edge module.
    hyperopt            Hyperopt module.
    hyperopt-list       List Hyperopt results
    hyperopt-show       Show details of Hyperopt results
    list-exchanges      Print available exchanges.
    list-hyperopts      Print available hyperopt classes.
    list-markets        Print markets on exchange.
    list-pairs          Print pairs on exchange.
    list-strategies     Print available strategies.
    list-timeframes     Print available timeframes for the exchange.
    show-trades         Show trades.
    test-pairlist       Test your pairlist configuration.
    plot-dataframe      Plot candles with indicators.
    plot-profit         Generate plot showing profits.

optional arguments:
  -h, --help            show this help message and exit
  -V, --version         show program's version number and exit

Telegram RPC commands

Telegram is not mandatory. However, this is a great way to control your bot. More details and the full command list on our documentation

  • /start: Starts the trader.
  • /stop: Stops the trader.
  • /stopbuy: Stop entering new trades.
  • /status |[table]: Lists all or specific open trades.
  • /profit: Lists cumulative profit from all finished trades
  • /forcesell |all: Instantly sells the given trade (Ignoring minimum_roi).
  • /performance: Show performance of each finished trade grouped by pair
  • /balance: Show account balance per currency.
  • /daily : Shows profit or loss per day, over the last n days.
  • /help: Show help message.
  • /version: Show version.

Development branches

The project is currently setup in two main branches:

  • develop - This branch has often new features, but might also contain breaking changes. We try hard to keep this branch as stable as possible.
  • stable - This branch contains the latest stable release. This branch is generally well tested.
  • feat/* - These are feature branches, which are being worked on heavily. Please don't use these unless you want to test a specific feature.

Support

Help / Discord / Slack

For any questions not covered by the documentation or for further information about the bot, or to simply engage with like-minded individuals, we encourage you to join our slack channel.

Please check out our discord server.

You can also join our Slack channel.

Bugs / Issues

If you discover a bug in the bot, please search our issue tracker first. If it hasn't been reported, please create a new issue and ensure you follow the template guide so that our team can assist you as quickly as possible.

Feature Requests

Have you a great idea to improve the bot you want to share? Please, first search if this feature was not already discussed. If it hasn't been requested, please create a new request and ensure you follow the template guide so that it does not get lost in the bug reports.

Pull Requests

Feel like our bot is missing a feature? We welcome your pull requests!

Please read our Contributing document to understand the requirements before sending your pull-requests.

Coding is not a necessity to contribute - maybe start with improving our documentation? Issues labeled good first issue can be good first contributions, and will help get you familiar with the codebase.

Note before starting any major new feature work, please open an issue describing what you are planning to do or talk to us on discord or Slack. This will ensure that interested parties can give valuable feedback on the feature, and let others know that you are working on it.

Important: Always create your PR against the develop branch, not stable.

Requirements

Up-to-date clock

The clock must be accurate, synchronized to a NTP server very frequently to avoid problems with communication to the exchanges.

Min hardware required

To run this bot we recommend you a cloud instance with a minimum of:

  • Minimal (advised) system requirements: 2GB RAM, 1GB disk space, 2vCPU

Software requirements

Comments
  • Bot couldn't sell because of insufficient fund

    Bot couldn't sell because of insufficient fund

    I was synced to HEAD yesterday (but I had the same issue some time ago).

    I had an order that the bot couldn't sell because of insufficient fund. I think it's because either the bot did wrong calculation of the amount or the exchange is doing some funny stuff.

    Logs when the order was fulfilled:

    2018-11-29 03:05:08,831 - freqtrade.freqtradebot - INFO - Found open order for Trade(id=xx, pair=BCHSV/USDT, amount=xxx, open_rate=99.10000000, open_since=just now)
    2018-11-29 03:05:09,740 - freqtrade.freqtradebot - WARNING - amount xxx does not match amount xxx
    2018-11-29 03:05:09,740 - freqtrade.freqtradebot - WARNING - could not update trade amount: Half bought? Amounts don't match
    2018-11-29 03:05:09,740 - freqtrade.persistence - INFO - Updating trade (id=xx) ...
    2018-11-29 03:05:09,741 - freqtrade.persistence - INFO - LIMIT_BUY has been fulfilled for Trade(id=xx, pair=BCHSV/USDT, amount=xxx, open_rate=99.10000000, open_since=just now).
    

    Logs when the bot was trying to sell:

    2018-11-29 03:09:29,427 - freqtrade.freqtradebot - INFO - checking sell
    2018-11-29 03:09:29,910 - freqtrade.freqtradebot - WARNING - Unable to sell trade: Insufficient funds to create limit sell order on market BCHSV/USDT.Tried to sell amount xx at rate 100.02 (total xx).Message: binance {"code":-2010,"msg":"Account has insufficient balance for requested action."}
    

    The code that is throwing the error, any reason that instead of using the latest amount getting from exchange, we still choose to use the one saved when buying? https://github.com/freqtrade/freqtrade/blob/200484ab8ba85308e6e759bbec613dcba0e83d37/freqtrade/freqtradebot.py#L603

  • Edge Positioning

    Edge Positioning

    Summary

    Currently FT analyzes pairs in whitelist randomly (or by order in config.json) and takes a position as soon as it finds a buy signal with a fixed stake_amount. a better approach would be:

    • Calculating the chance of winning for each pair and sorting whitelist accordingly.
    • Adjusting the position size according to risk/reward.

    This PR addresses the above issues by adding a package called "Edge". Edge will run a process every X minutes (default 30 min) using the mainloop to go through all pairs in order to:

    • Calculate WinRate and Expected Risk Reward ratio for a range of stoplosses.
    • Finding the best WinRate/Expected Risk Reward ratio for a pair. finding the best stoploss value.
    • Forcing the stoploss value (calculated above) into the strategy.

    The process uses the backtesting download script to fetch historical data. and cache a matrix of [pair, stoploss, win_rate, expected_risk_reward, required_risk_reward]. an example of the cached matrix:

    | pair | stoploss | winrate | risk_reward_ratio | required_risk_reward | |-----|----------|---------|------------------|---------------------- | | NEO/BTC | -0.04 |0.666667 | 3.071181 | 0.500000 | |STEEM/BTC | -0.02 | 0.500000 | 2.399500 | 1.000000 | |DASH/BTC | -0.01 | 0.625000 | 1.181620 | 0.600000 | | BNB/BTC | -0.08 | 0.625000 | 1.128478 | 0.600000| | CMT/BTC | -0.05 | 0.583333 | 0.952720 | 0.714286| | XEM/BTC | -0.03 | 0.500000 | 1.194416 | 1.000000 |

    WinRate is the number of winning trades divided by number of trades (e.x. if 4 trades out of 10 are profitable then the winrate is 40%).

    Risk Reward Ratio is the ratio between your loss and your take profit. as an example lets say you take a position with an entry price of 100$. you put your stoploss at 90$ (i.e. 10%) and your take profit (sell point) is 120$. your risk reward would be 2 (your profit would be two times your loss).

    While going through historical data we are only interested in finding two and only two things:

    • Amount/Number of losses if the stoploss hit.
    • Amount/Number of profits if sell signal is triggered.

    TODO list before merging the PR:

    • [X] Fixing .travis script which breaks tests currently.
    • [X] Fixing already broken tests.
    • [X] Finding an alternative for py_find_1st, otherwise try to make its installation clean.
    • [X] Finding a proper way to sort the matrix according to WinRate and RRR.
    • [X] Make backslap function more readable
    • [X] Writing tests
    • [X] Writing documentation

    Will replace #1147 and #1114

  • Avoid look-ahead in backtesting

    Avoid look-ahead in backtesting

    Use buy/sell signal from previous candle, not current to avoid seeing to the future. Quick improvement to one issue mentioned in https://github.com/freqtrade/freqtrade/issues/746

    I will update/fix tests only if we decide to go with this change.

  • (sqlite3.OperationalError) database is locked

    (sqlite3.OperationalError) database is locked

    I was fiddling with the web ui (only viewing: reloading at the order tab: no actual trading or changes) and the 'regular' software crashed at that moment while it was trying to order something (it went through at the exchange but not at the database).

    freqtrade/freqtradebot.py", line 625, in execute_buy
        Trade.session.flush()
      File "<string>", line 2, in flush
    sqlalchemy/orm/session.py", line 3233, in flush
        self._flush(objects)
    sqlalchemy/orm/session.py", line 3373, in _flush
        transaction.rollback(_capture_exception=True)
    sqlalchemy/util/langhelpers.py", line 70, in __exit__
        compat.raise_(
    sqlalchemy/util/compat.py", line 198, in raise_
        raise exception
    sqlalchemy/orm/session.py", line 3369, in _flush
        transaction.commit()
    sqlalchemy/orm/session.py", line 836, in commit
        trans.commit()
    sqlalchemy/engine/base.py", line 2257, in commit
        self._do_commit()
    sqlalchemy/engine/base.py", line 2421, in _do_commit
        self._connection_commit_impl()
    sqlalchemy/engine/base.py", line 2392, in _connection_commit_impl
        self.connection._commit_impl()
    sqlalchemy/engine/base.py", line 930, in _commit_impl
        self._handle_dbapi_exception(e, None, None, None, None)
    sqlalchemy/engine/base.py", line 1929, in _handle_dbapi_exception
        util.raise_(
    sqlalchemy/util/compat.py", line 198, in raise_
        raise exception
    sqlalchemy/engine/base.py", line 928, in _commit_impl
        self.engine.dialect.do_commit(self.connection)
    sqlalchemy/engine/default.py", line 634, in do_commit
        dbapi_connection.commit()
    sqlalchemy.exc.OperationalError: (sqlite3.OperationalError) database is locked
    (Background on this error at: http://sqlalche.me/e/14/e3q8)
    freqtrade.commands.trade_commands - INFO - worker found ... calling exit
    
  • ModuleNotFoundError: No module named 'freqtrade'

    ModuleNotFoundError: No module named 'freqtrade'

    hi sorry the bot gives me an error Error : Traceback (most recent call last): File "./freqtrade/main.py", line 11, in from freqtrade import OperationalException ModuleNotFoundError: No module named 'freqtrade'

  • No option to short, Limits bot to 50% potential, increased risk during bear as counter trend trading

    No option to short, Limits bot to 50% potential, increased risk during bear as counter trend trading

    Crypto markets experience both bull and bear periods mid / long term and up/down price movement intraday.

    A lack of capability to trade short during bear periods limits strategies to trading against the trend which is hard work and carries in increased risk.

    To be able to flip a position from long to short when day trading doubles to entry points opportunities.

    By way of examples:

    1. Longterm low risk trade: A simple long term trend trade on hr4 would make 150% on 1 short/bear flip from Feb to April, and 60% on the following bull.
    2. Day trading example: Indicators flip to short at 7600, but no means to short BTC on the drop.
    screen shot 2018-06-10 at 9 08 06 am 2) screen shot 2018-06-10 at 9 10 36 am
  • Hyperopts

    Hyperopts

    An error warning comes up when trying

    python3 freqtrade -c config.json hyperopt --customhyperopt HyperOpts -e 5000 --print-all

    /Users/nsm/.env/lib/python3.7/site-packages/sklearn/externals/joblib/__init__.py:15: DeprecationWarning: sklearn.externals.joblib is deprecated in 0.21 and will be removed in 0.23. Please import this functionality directly from joblib, which can be installed with: pip install joblib. If this warning is raised when loading pickled models, you may need to re-serialize those models with scikit-learn 0.21+.
      warnings.warn(msg, category=DeprecationWarning)
    Traceback (most recent call last):
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 193, in _run_module_as_main
        "__main__", mod_spec)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/runpy.py", line 85, in _run_code
        exec(code, run_globals)
      File "freqtrade/__main__.py", line 15, in <module>
        main.main(sys.argv[1:])
      File "/Users/nsm/freqtrade/freqtrade/main.py", line 34, in main
        args.func(args)
      File "/Users/nsm/freqtrade/freqtrade/optimize/hyperopt.py", line 362, in start
        config = setup_configuration(args)
      File "/Users/nsm/freqtrade/freqtrade/optimize/hyperopt.py", line 338, in setup_configuration
        config = configuration.load_config()
      File "/Users/nsm/freqtrade/freqtrade/configuration.py", line 78, in load_config
        config = deep_merge_dicts(self._load_config_file(path), config)
      File "/Users/nsm/freqtrade/freqtrade/configuration.py", line 117, in _load_config_file
        conf = json.load(file)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 296, in load
        parse_constant=parse_constant, object_pairs_hook=object_pairs_hook, **kw)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/__init__.py", line 348, in loads
        return _default_decoder.decode(s)
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 337, in decode
        obj, end = self.raw_decode(s, idx=_w(s, 0).end())
      File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/json/decoder.py", line 353, in raw_decode
        obj, end = self.scan_once(s, idx)
    json.decoder.JSONDecodeError: Expecting ',' delimiter: line 175 column 13 (char 4125)
    
    
  • Buy Signal not meet criteria after updating to 2021.1 release due to pandas upgrade

    Buy Signal not meet criteria after updating to 2021.1 release due to pandas upgrade

    Hi,

    After updating bot to 2021.1 version, a strategy that worked well before , right now is not working properly, throwing buy signals that doesn't meet criteria.

    After install bot began to buy pairs and this was not the normal behaviour of this strategy.

    Buy signal is using qtpylib and Bollinger bands and seems that is not calculating this indicator properly.

    Has been an update of this library in last release?

    Thanks for your support.

  • Missed or badly triggered computed Actions: BUY and SELL. Significant Difference Between Backtest and LIVE.

    Missed or badly triggered computed Actions: BUY and SELL. Significant Difference Between Backtest and LIVE.

    ## Step 2: Describe your environment

    • Python Version: Python 3.6.4
    • Branch: Develop
    • Last Commit ID: b0536db (git log --format="%H" -n 1)

    ## Step 3: Describe the problem: Hi everyone, I decided to finaly create an issue because i'm struggling with a problem since a few weeks: There is an important difference between the signal that are computed on Backtest and the reality of actions in Live. After a few observation I can tell that this is not related to a normal lag due to the network. The behavior seems to occur when a trigger is slightly triggered. Exemple: Sell When "Close Under Open Of Previous Candle" dataframe['close'] < dataframe['open'].shift() Theoricaly Failing case 0.00005155 < 0.00005156 (Those values are too close, the condition is not fullfilled) Theoricaly Working case 0.00005155 < 0.00005160 (the gap between the two value is large enought, the condition is fullfilled)

    Steps to reproduce:

    1. Use 1 minute Time frame
    2. launch freqtrade on live with a strategy that use directly price or averages to trigger BUY or SELL actions
    3. Wait for a price movement that "slightly" correspond to the signal (BUY or SELL)
    4. The signal is not triggered or is badly triggered .
    5. When a few moment later there is a bigger price move that trigger the signal more Frankly, the signal is triggered.

    Observed Results:

    • What happened? The signal is not triggered sometimes, when there is a small gap between compared values that are used to take the descision
    • What did you expect to happen? The signal should be triggered in live more or less at the same moment that is computed on the backtest (less than 1min drift tolerated on live)

    Relevant code exceptions or logs:

    orders-missed-issue orders-missed-issue-computed-on-backtest-poa Note: On plot-dataframe I modified the code to display only the SELLs that are consecutive to BUYs, to have more clarity.

    Suspected cause

    Loss of prescision due to python floating point: the problem with that theory is that I don't understand why the backtest is working as expected. The problem should be also present in that case...

    What I tried to fix that issue

    1- Convert all collumns related to triggers to Decimal 2- Rise Ta-lib prescision (https://github.com/mrjbq7/ta-lib/issues/151)

    The issue is still present.

    Thank you for your help. Regards, Axel

  • HyperOpt Memory Leak - `TerminatedWorkerError` with exit code `SIGKILL(-9), ERROR 1`

    HyperOpt Memory Leak - `TerminatedWorkerError` with exit code `SIGKILL(-9), ERROR 1`

    Describe your environment

    • Operating system: Manjaro Linux x86_64 (Kernel: 5.10.32-1-MANJARO, Plasma: 5.21.4)
    • Python Version: Python 3.9.4
    • CCXT version: ccxt==1.49.30
    • Freqtrade Version: freqtrade develop-32577cc0, freqtrade docker-32577cc0 & freqtrade docker-99e1ef9b
    • MoniGoMani Version: v0.9.1 & v0.9.0

    Describe the problem:

    Since I was migrating towards the new custom_sell() function I updated my Freqtrade to pull in the changes needed.
    After that I started experiencing my machine freezing up during HyperOpting.
    At first I thought it would be due to my new code, so I switched back to my original MGM v0.9.1 to make sure the issue wouldn't be due to that, but still my machine froze up.
    Thus I pulled the v0.9.0 release of MGM (which definitely was working before) and tried again and once more I experienced my system freezing up.

    Steps to reproduce:

    1. Download MoniGoMani v0.9.0 or v0.9.1
    2. Fire up a HyperOpt with: freqtrade hyperopt -c ./user_data/config-btc.json -c ./user_data/config-private.json --hyperopt-loss WinRatioAndProfitRatioLoss --spaces all -s MoniGoManiHyperStrategy -e 1000 --timerange 20210101-20210316
    3. Open up a RAM monitoring tool like Bashtop for example

    Observed Results:

    • Avg duration is way higher then what it used to be for MGM v0.9.0
    • Profit is way lower then what it used to be for MGM v0.9.0
    • RAM & Swap usage keep increasing till it runs out completely resulting in the system freezing and sometimes a TerminatedWorkerError with exit code SIGKILL(-9), ERROR 1 being thrown before fully freezing up the system.

    Relevant code exceptions or logs

    This has already been reproduced by a few other MoniGoMani users, I appended their screenshots when it occurred below, it's always the same stacktrace in the error, but worth to take notice of their versions in use.

    My own machine - Freqtrade freqtrade develop-32577cc0 & MoniGoMani v0.9.0:
    This is far from normal for this version of MGM with the default StaticPairList containing only 15 pairs.
    I recall when I was testing a top 50 volume StaticPairList on this version in the past that the system used maximum 18Gb of RAM back then.
    While I didn't measure it for the default (15) StaticPairList back then, I'm 100% sure that it was using way lower then 18Gb for it.
    But as you can see, a few minutes before my system froze up it was using 21.5Gb for the default (15) StaticPairList on the latest freqtrade develop-32577cc0.
    When my system froze up 100% RAM & 100% Swap was in use.
    FreqtradeMemoryLeak2021-05-06_16-46

    carti's machine - Freqtrade freqtrade docker-32577cc0 & MoniGoMani v0.9.1:
    FreqtradeMemoryLeak_carti_MGMv0 9 1

    M0H4M3D's machine - Freqtrade freqtrade docker-32577cc0 & MoniGoMani v0.9.1:
    FreqtradeMemoryLeak_M0H4M3D_MGMv0 9 1

    M0H4M3D's machine - Freqtrade freqtrade docker-32577cc0 & MoniGoMani v0.9.0:
    FreqtradeMemoryLeak_M0H4M3D_MGMv0 9 0

    3ylo's machine - Freqtrade freqtrade docker-99e1ef9b & MoniGoMani v0.9.1:
    FreqtradeMemoryLeak_3ylo_MGMv0 9 1

  • Freqtrade causing my VPS to crash

    Freqtrade causing my VPS to crash

    Everytime I run freqtrade on my VPS (EC2 server) it works for an hour or two. Then it causes my VPS to crash and stop working. I honestly do not know what to do.

    I am using Ubuntu 18.04 and my VPS has 1 CPU.

  • Bump uvicorn from 0.17.6 to 0.18.1

    Bump uvicorn from 0.17.6 to 0.18.1

    Bumps uvicorn from 0.17.6 to 0.18.1.

    Release notes

    Sourced from uvicorn's releases.

    Version 0.18.1

    Fixed

    • Use DEFAULT_MAX_INCOMPLETE_EVENT_SIZE as default to h11_max_incomplete_event_size on the CLI (#1534) 23/06/22

    Full Changelog: https://github.com/encode/uvicorn/compare/0.18.0...0.18.1

    Version 0.18.0

    Added

    • The reload flag prioritizes watchfiles instead of the deprecated watchgod (#1437) 18/06/22
    • Annotate uvicorn.run() function (#1423) 10/05/22
    • Allow configuring max_incomplete_event_size for h11 implementation (#1514) 22/06/22

    Removed

    • Remove asgiref dependency (#1532) 22/06/22

    Fixed

    • Turn raw_path into bytes on both websockets implementations (#1487) 16/05/22
    • Revert log exception traceback in case of invalid HTTP request (#1518) 14/06/22
    • Set asyncio.WindowsSelectorEventLoopPolicy() when using multiple workers to avoid "WinError 87" (#1454) 22/06/22

    Full Changelog: https://github.com/encode/uvicorn/compare/0.17.6...0.18.0

    Changelog

    Sourced from uvicorn's changelog.

    0.18.1 - 2022-06-23

    Fixed

    • Use `DEFAULT_MAX_INCOMPLETE_EVENT_SIZE` as default to `h11_max_incomplete_event_size` on the CLI (#1534) 23/06/22

    0.18.0 - 2022-06-23

    Added

    • The reload flag prioritizes watchfiles instead of the deprecated watchgod (#1437) 18/06/22
    • Annotate uvicorn.run() function (#1423) 10/05/22
    • Allow configuring max_incomplete_event_size for h11 implementation (#1514) 22/06/22

    Removed

    • Remove asgiref dependency (#1532) 22/06/22

    Fixed

    • Turn raw_path into bytes on both websockets implementations (#1487) 16/05/22
    • Revert log exception traceback in case of invalid HTTP request (#1518) 14/06/22
    • Set asyncio.WindowsSelectorEventLoopPolicy() when using multiple workers to avoid "WinError 87" (#1454) 22/06/22
    Commits
    • 11d28e2 Version 0.18.1 (#1535)
    • ab7ebfb Use DEFAULT_MAX_INCOMPLETE_EVENT_SIZE as default to `h11_max_incomplete_eve...
    • 5ee093b Version 0.18.0 (#1524)
    • b22c950 Remove asgiref dependency (#1532)
    • 99ead36 Fix OSError: [WinError 87] The parameter is incorrect (#1454)
    • 81d647b Allow configuring max_incomplete_event_size for h11 implementation (#1514)
    • 39621c2 Document how to run uvicorn programatically (#1525)
    • b1a4582 Switch from watchgod to watchfiles (#1437)
    • 9c57549 make test_http.get_connected_protocol a plain function and other post #1155 c...
    • d2b14ee Replace pytest-asyncio marker by anyio (#1155)
    • Additional commits viewable in compare view

    Dependabot compatibility score

    Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


    Dependabot commands and options

    You can trigger Dependabot actions by commenting on this PR:

    • @dependabot rebase will rebase this PR
    • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
    • @dependabot merge will merge this PR after your CI passes on it
    • @dependabot squash and merge will squash and merge this PR after your CI passes on it
    • @dependabot cancel merge will cancel a previously requested merge and block automerging
    • @dependabot reopen will reopen this PR if it is closed
    • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
    • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
    • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • DRYRUN: Buy price higher than market price

    DRYRUN: Buy price higher than market price

    Describe your environment

    • Operating system: macOS Big Sur 11.2.3
    • Python Version: 3.9.7 (python -V)
    • CCXT version: ccxt==1.88.15 (pip freeze | grep ccxt)
    • Freqtrade Version: develop-53e5483 (freqtrade -V or docker-compose run --rm freqtrade -V for Freqtrade running in docker)

    Note: All issues other than enhancement requests will be closed without further comment if the above template is deleted or not filled out.

    Describe the problem:

    In DRYRUN the buy price is higher than what is shown as the price in the Binance charts for ARPA/USDT pair.

    Steps to reproduce:

    1. Please the the database order below. I checked UTC time zones as well and they are the same.
    2. PAIR: ARPA/USDT
    3. UTC Time of BUY: 2022-06-24 06:01:37.000000
    4. BUY PRICE SHOWN IN DB: 0.04621
    5. Actual high of candle observed on Binance: 0.04431
    6. Variation: +4.2%

    Observed Results:

    • The price of the buy is higher than the price. The volume for the
    • The buy price shown in the database to be the same as the market price at the time of order

    Relevant code exceptions or logs

    Order Table row:

    511 | 97 | buy | ARPA/USDT | 0 | dry_run_buy_1656050497.648718 | closed | ARPA/USDT | limit | buy | 0.04621 | 0.04621 | 39346.0 | 39346.0 | 0.0 | 1818.17866 |   | 2022-06-24 06:01:37.000000 | 2022-06-24 06:01:58.086488 | 2022-06-24 06:01:58.086491

  • How to use informative pairs in both hyperopt and backtest

    How to use informative pairs in both hyperopt and backtest

    • Operating system: Windows, Python venv
    • Python Version: 3.9.10
    • CCXT version: 1.79.81
    • Freqtrade Version: freqtrade develop (not the latest version)

    I need to use informative pairs, elaborate it and then pass it to every single dataframe inside populate_indicators. If I use bot_loop_start it doesn't work in hyperopt (the attribute for the dataframe doesn't exist) and in backtest is having problem merging the two dataframes in populate_indicators. At the moment I made it works by using a function mc_informative_pairs and calling it from populate_indicators but this reload all the informative data every ticker, and I want to avoid it.

    class NF_Strategy_B1(IStrategy):
        can_short = False
        exit_profit_only=False
        startup_candle_count = 100
        enter_params={'space':'buy','optimize':'True'}
        ent_csrrsi_enabled = BooleanParameter(default=True, optimize=False, space='buy')
        ent_csr_smooth = IntParameter(2, 20, default=5, **enter_params)
        ent_rsi_smooth = IntParameter(2, 20, default=5, **enter_params)
        ent_csr_ind = DecimalParameter(-5, 5, default=0, **enter_params)
        ent_rsi_ind = DecimalParameter(-5, 5, default=0, **enter_params)
        mc_ent_twroc_enabled = BooleanParameter(default=True, **enter_params)
        mc_ent_twroc_smooth = IntParameter(2, 20, default=2, **enter_params)
        mc_ent_twroc_slope_ind = DecimalParameter(-1.7, 1.7, default=0, **enter_params)
        exit_params={'space':'sell','optimize':'True'}
        ext_csrrsi_enabled = BooleanParameter(default=True, optimize=False, space='sell')
        ext_csr_smooth = IntParameter(2, 20, default=5, **exit_params)
        ext_rsi_smooth = IntParameter(2, 20, default=5, **exit_params)
        ext_csr_ind = DecimalParameter(-5, 5, default=0, **exit_params)
        ext_rsi_ind = DecimalParameter(-5, 5, default=0, **exit_params)
        mc_ext_twroc_enabled = BooleanParameter(default=True, optimize=False, space='sell')
        mc_ext_twroc_smooth = IntParameter(2, 20, default=2, **exit_params)
        mc_ext_twroc_slope_ind = DecimalParameter(-1.7, 1.7, default=0, **exit_params)
    
        def informative_pairs(self):
            # def list of symbols
            self.mc_symbols = ["BTC", "ETH", "SHIB", "ADA", "MLN"]
            self.mc_tf = "1m"
            stake = "USDT"
            informative_pairs = [(f'{symbol}/{stake}', self.mc_tf) for symbol in self.mc_symbols]
            return informative_pairs
    
        def bot_loop_start(self, **kwargs) -> None:
            self.mc_dataframe = self.mc_informative_pairs()
    
        def mc_informative_pairs(self) -> pd.DataFrame:
            mc_df = None
            dataframe = None
            for pair in self.informative_pairs():
                dummy = self.dp.get_pair_dataframe(*pair)
                if mc_df is None:
                    mc_df = pd.DataFrame(dummy['date'], columns={'date'})
                mc_df[f"ind_close_{pair[0]}"] = normalize(dummy["close"])
                mc_df[f"ind_vol_{pair[0]}"] = normalize(dummy["volume"])
    
            if dataframe is None:
                dataframe = pd.DataFrame(dummy['date'], columns={'date'})
            del dummy
    
            dataframe['mc_close'] = mc_df.filter(regex="ind_close.*", axis=1).mean(axis=1)
            dataframe['mc_volume'] = mc_df.filter(regex="ind_vol.*", axis=1).mean(axis=1)
            del mc_df
            return dataframe
    
        def populate_indicators(self, dataframe: pd.DataFrame, metadata: dict) -> pd.DataFrame:
            # timeframe = 1
    
            if self.ent_csrrsi_enabled.value:
                dataframe['csr'] = (
                    TA.RSI(slope(dataframe['close'], smooth=self.ent_csr_smooth.value),timeperiod=self.ent_csr_smooth.value)/50)-1
                dataframe['rsi'] = (
                    TA.RSI(dataframe['close'],timeperiod=self.ent_rsi_smooth.value)/50)-1
    
            if self.ext_csrrsi_enabled.value:
                dataframe['csr'] = (
                    TA.RSI(slope(dataframe['close'], smooth=self.ext_csr_smooth.value),timeperiod=self.ext_csr_smooth.value)/50)-1
                dataframe['rsi'] = (
                    TA.RSI(dataframe['close'],timeperiod=self.ext_rsi_smooth.value)/50)-1
    
            mc_dataframe = self.mc_informative_pairs()
            dataframe = merge_informative_pair(dataframe, mc_dataframe, self.timeframe, self.mc_tf, ffill=True)
            dataframe.rename(columns={f'mc_close_{self.mc_tf}':'mc_close', f'mc_vol_{self.mc_tf}':'mc_vol'}, inplace=True)
    
            ### ENTER PART
            dataframe['mc_ent_twroc'], dataframe['mc_ent_twroc_slope'] = (
                Custom.twroc(dataframe['mc_close'], sma_smooth=self.mc_ent_twroc_smooth.value))
    
            ### EXIT PART
            dataframe['mc_ext_twroc'], dataframe['mc_ext_twroc_slope'] = (
                Custom.twroc(dataframe['mc_close'], sma_smooth=self.mc_ext_twroc_smooth.value))
    
            return dataframe
    
        def populate_entry_trend(self, dataframe: pd.DataFrame, metadata: dict) -> pd.DataFrame:
    
            conditions = []
            if self.ent_csrrsi_enabled.value:
                conditions.append(
                    dataframe['csr'] < self.ent_csr_ind.value)
                conditions.append(
                    dataframe['rsi'] < self.ent_rsi_ind.value)
            # protection
            if self.mc_ent_twroc_enabled.value:
                conditions.append(
                        dataframe['mc_ent_twroc_slope'] > self.mc_ent_twroc_slope_ind.value
                    )
            if conditions:       # test conditions
                dataframe.loc[
                    reduce(lambda x, y: x & y, conditions),
                    ['enter_long', 'enter_tag']] = (1, 'csrrsi')
    
            return dataframe
    
        def populate_exit_trend(self, dataframe: pd.DataFrame, metadata: dict) -> pd.DataFrame:
            conditions = []
            if self.ext_csrrsi_enabled.value:
                conditions.append(
                    dataframe['csr'] > self.ext_csr_ind.value)
                conditions.append(
                    dataframe['rsi'] > self.ext_rsi_ind.value)
            if conditions:
                dataframe.loc[
                    reduce(lambda x, y: x & y, conditions),
                ['exit_long', 'exit_tag']] = (1, 'csrrsi')
    
            conditions = []
            if self.mc_ext_twroc_enabled.value:
                    conditions.append(
                            dataframe['mc_ext_twroc_slope'] > self.mc_mc_ext_twroc_slope_ind.value)
            if conditions:
                dataframe.loc[
                    reduce(lambda x, y: x & y, conditions),
                ['exit_long', 'exit_tag']] = (1, 'mc_twroc_prot')
    
            return dataframe
    

    error in hyperopt:

    2022-06-26 11:46:22,858 - freqtrade.optimize.hyperopt - INFO - Dataload complete. Calculating indicators
    2022-06-26 11:46:22,868 - freqtrade - ERROR - Fatal exception!
    Traceback (most recent call last):
      File "C:\freqtrade\.env\lib\site-packages\freqtrade-develop-py3.9.egg\freqtrade\main.py", line 37, in main
        return_code = args['func'](args)
      File "C:\freqtrade\.env\lib\site-packages\freqtrade-develop-py3.9.egg\freqtrade\commands\optimize_commands.py", line 107, in start_hyperopt
        hyperopt.start()
      File "C:\freqtrade\.env\lib\site-packages\freqtrade-develop-py3.9.egg\freqtrade\optimize\hyperopt.py", line 419, in start
        self.prepare_hyperopt_data()
      File "C:\freqtrade\.env\lib\site-packages\freqtrade-develop-py3.9.egg\freqtrade\optimize\hyperopt.py", line 400, in prepare_hyperopt_data
        preprocessed = self.backtesting.strategy.advise_all_indicators(data)
      File "C:\freqtrade\.env\lib\site-packages\freqtrade-develop-py3.9.egg\freqtrade\strategy\interface.py", line 1075, in advise_all_indicators
        return {pair: self.advise_indicators(pair_data.copy(), {'pair': pair}).copy()
      File "C:\freqtrade\.env\lib\site-packages\freqtrade-develop-py3.9.egg\freqtrade\strategy\interface.py", line 1075, in <dictcomp>
        return {pair: self.advise_indicators(pair_data.copy(), {'pair': pair}).copy()
      File "C:\freqtrade\.env\lib\site-packages\freqtrade-develop-py3.9.egg\freqtrade\strategy\interface.py", line 1098, in advise_indicators
        return self.populate_indicators(dataframe, metadata)
      File "C:\freqtrade\user_data\strategies\nf_strategy_B1.py", line 146, in populate_indicators
        dataframe = merge_informative_pair(dataframe, self.mc_dataframe, self.timeframe, self.mc_tf, ffill=True)
    AttributeError: 'NF_Strategy_B1' object has no attribute 'mc_dataframe'
    

    error in backtest:

    2022-06-26 11:51:43,852 - freqtrade.optimize.backtesting - INFO - Dataload complete. Calculating indicators
    2022-06-26 11:51:43,858 - freqtrade.optimize.backtesting - INFO - Running backtesting for Strategy NF_Strategy_B1
    2022-06-26 11:51:47,628 - freqtrade - ERROR - Fatal exception!
    Traceback (most recent call last):
      File "C:\freqtrade\.env\lib\site-packages\pandas\core\indexes\base.py", line 3621, in get_loc
        return self._engine.get_loc(casted_key)
      File "pandas\_libs\index.pyx", line 136, in pandas._libs.index.IndexEngine.get_loc
      File "pandas\_libs\index.pyx", line 163, in pandas._libs.index.IndexEngine.get_loc
      File "pandas\_libs\hashtable_class_helper.pxi", line 5198, in pandas._libs.hashtable.PyObjectHashTable.get_item
      File "pandas\_libs\hashtable_class_helper.pxi", line 5206, in pandas._libs.hashtable.PyObjectHashTable.get_item
    KeyError: 'date'
    
    The above exception was the direct cause of the following exception:
    
    Traceback (most recent call last):
      File "C:\freqtrade\.env\lib\site-packages\freqtrade-develop-py3.9.egg\freqtrade\main.py", line 37, in main
        return_code = args['func'](args)
      File "C:\freqtrade\.env\lib\site-packages\freqtrade-develop-py3.9.egg\freqtrade\commands\optimize_commands.py", line 58, in start_backtesting
        backtesting.start()
      File "C:\freqtrade\.env\lib\site-packages\freqtrade-develop-py3.9.egg\freqtrade\optimize\backtesting.py", line 1120, in start
        min_date, max_date = self.backtest_one_strategy(strat, data, timerange)
      File "C:\freqtrade\.env\lib\site-packages\freqtrade-develop-py3.9.egg\freqtrade\optimize\backtesting.py", line 1041, in backtest_one_strategy
        preprocessed = self.strategy.advise_all_indicators(data)
      File "C:\freqtrade\.env\lib\site-packages\freqtrade-develop-py3.9.egg\freqtrade\strategy\interface.py", line 1075, in advise_all_indicators
        return {pair: self.advise_indicators(pair_data.copy(), {'pair': pair}).copy()
      File "C:\freqtrade\.env\lib\site-packages\freqtrade-develop-py3.9.egg\freqtrade\strategy\interface.py", line 1075, in <dictcomp>
        return {pair: self.advise_indicators(pair_data.copy(), {'pair': pair}).copy()
      File "C:\freqtrade\.env\lib\site-packages\freqtrade-develop-py3.9.egg\freqtrade\strategy\interface.py", line 1098, in advise_indicators
        return self.populate_indicators(dataframe, metadata)
      File "C:\freqtrade\user_data\strategies\nf_strategy_B1.py", line 146, in populate_indicators
        dataframe = merge_informative_pair(dataframe, self.mc_dataframe, self.timeframe, self.mc_tf, ffill=True)
      File "C:\freqtrade\.env\lib\site-packages\freqtrade-develop-py3.9.egg\freqtrade\strategy\strategy_helper.py", line 39, in merge_informative_pair
        informative['date_merge'] = informative[date_column]
      File "C:\freqtrade\.env\lib\site-packages\pandas\core\frame.py", line 3505, in __getitem__
        indexer = self.columns.get_loc(key)
      File "C:\freqtrade\.env\lib\site-packages\pandas\core\indexes\base.py", line 3623, in get_loc
        raise KeyError(key) from err
    KeyError: 'date'
    

    How can I make it works? Is there something I'm missing?

  • Add dry/live indicator and average entry/exit price to telegram notifications

    Add dry/live indicator and average entry/exit price to telegram notifications

    Describe the enhancement

    @froggleston and I were talking a bit and we noticed that there are two issues in the freqtrade discord that may hurt new users:

    1. people fabricating results by deleting bad trades from their databases
    2. people purporting dry runs as live runs

    This false information may lead to two problems:

    1. it may demoralize new/old users who are honest and trying their best
    2. worse: it may lead new users to purchase bad strategies from the users who are falsifying results. Ultimately getting scammed and feeling resentment toward the FT community.

    In an attempt to clarify result sharing on discord, I think it would be nice to have additional information indicating if the results are live or dry, the slippage that occurred for that particular entry/exit, and the number of deleted trades in the DB. This will not completely solve the issue but it will help the discord community identify those who are falsifying information.

    Do y'all think this would help? Or is it a waste of space and will just clutter the telegram messages? I want to hear your thoughts.

  • Freqtrade Amount is not equal to exchange's Amount

    Freqtrade Amount is not equal to exchange's Amount

    Describe your environment

    • Operating system: Linux
    • Python Version: _____ (python -V)
    • CCXT version: _____ (pip freeze | grep ccxt)
    • Freqtrade Version: docker-b2968df5 (freqtrade -V or docker-compose run --rm freqtrade -V for Freqtrade running in docker)

    Your question

    Ask the question you have not been able to find an answer in the Documentation

    I tried searching the docs and asking Discord but I didn't really get any answers.

    I'm not sure if this is intended but the Amount in Freqtrade is not the same as in the Exchange.

    Why? How is it being broken down in Freqtrade if it's intentional?

    Example:

    In exchange: LIT Amount: 9.49050000

    In Freqtrade: LIT Amount: 9.34078323

Manuskript is an open-source tool for writers.
Manuskript is an open-source tool for writers.

Manuskript is an open-source tool for writers. Manuskript runs on GNU/Linux, Mac OS X, and Windows.

Jun 29, 2022
Python books free to read online or download
Python books free to read online or download

Python books free to read online or download

Jul 1, 2022
There is a new admin bot by @sinan-m-116 .

find me on telegram! deploy me on heroku, use below button: If you can't have a config.py file (EG on heroku), it is also possible to use environment

Nov 9, 2021
A high-level app and dashboarding solution for Python
A high-level app and dashboarding solution for Python

Panel provides tools for easily composing widgets, plots, tables, and other viewable objects and controls into custom analysis tools, apps, and dashboards.

Jun 29, 2022
PyMMO is a Python-based MMO game framework using sockets and PyGame.
PyMMO is a Python-based MMO game framework using sockets and PyGame.

PyMMO is a Python framework/template of a MMO game built using PyGame on top of Python's built-in socket module.

Jun 25, 2022
Firebase Admin Console is a centralized platform for easy viewing and maintenance of Firestore database, the back-end API is a Python Flask app.

Firebase Admin Console is a centralized platform for easy viewing and maintenance of Firestore database, the back-end API is a Python Flask app. A starting template for developers to customize, build, and even deploy the desired admin console for their DB.

Jan 31, 2022
Django application and library for importing and exporting data with admin integration.
Django application and library for importing and exporting data with admin integration.

django-import-export django-import-export is a Django application and library for importing and exporting data with included admin integration. Featur

Jun 29, 2022
Collection of admin fields and decorators to help to create computed or custom fields more friendly and easy way
Collection of admin fields and decorators to help to create computed or custom fields more friendly and easy way

django-admin-easy Collection of admin fields, decorators and mixin to help to create computed or custom fields more friendly and easy way Installation

Jun 25, 2022
BitcartCC is a platform for merchants, users and developers which offers easy setup and use.
BitcartCC is a platform for merchants, users and developers which offers easy setup and use.

BitcartCC is a platform for merchants, users and developers which offers easy setup and use.

Jun 27, 2022
A Django app that creates automatic web UIs for Python scripts.
A Django app that creates automatic web UIs for Python scripts.

Wooey is a simple web interface to run command line Python scripts. Think of it as an easy way to get your scripts up on the web for routine data anal

Jul 6, 2022
Python code for "Machine learning: a probabilistic perspective" (2nd edition)
Python code for

Python code for "Machine learning: a probabilistic perspective" (2nd edition)

Jul 1, 2022
A python application for manipulating pandas data frames from the comfort of your web browser
A python application for manipulating pandas data frames from the comfort of your web browser

A python application for manipulating pandas data frames from the comfort of your web browser. Data flows are represented as a Directed Acyclic Graph, and nodes can be ran individually as the user sees fit.

Mar 23, 2022
A modern Python package manager with PEP 582 support.
A modern Python package manager with PEP 582 support.

A modern Python package manager with PEP 582 support.

Jun 27, 2022
Ajenti Core and stock plugins
Ajenti Core and stock plugins

Ajenti is a Linux & BSD modular server admin panel. Ajenti 2 provides a new interface and a better architecture, developed with Python3 and AngularJS.

Jul 6, 2022
Simple and extensible administrative interface framework for Flask

Flask-Admin The project was recently moved into its own organization. Please update your references to [email protected]:flask-admin/flask-admin.git. Int

Jun 30, 2022
Real-time monitor and web admin for Celery distributed task queue

Flower Flower is a web based tool for monitoring and administrating Celery clusters. Features Real-time monitoring using Celery Events Task progress a

Jul 3, 2022
Simple and extensible administrative interface framework for Flask

Flask-Admin The project was recently moved into its own organization. Please update your references to [email protected]:flask-admin/flask-admin.git. Int

Feb 7, 2021
FastAPI Admin Dashboard based on FastAPI and Tortoise ORM.
FastAPI Admin Dashboard based on FastAPI and Tortoise ORM.

FastAPI ADMIN 中文文档 Introduction FastAPI-Admin is a admin dashboard based on fastapi and tortoise-orm. FastAPI-Admin provide crud feature out-of-the-bo

Jul 1, 2022
Nginx UI allows you to access and modify the nginx configurations files without cli.
Nginx UI allows you to access and modify the nginx configurations files without cli.

nginx ui Table of Contents nginx ui Introduction Setup Example Docker UI Authentication Configure the auth file Configure nginx Introduction We use ng

Jun 27, 2022