avatarMichael Whittle

Free AI web copilot to create summaries, insights and extended knowledge, download it at here

9519

Abstract

"><b>config.json (version 2.x)</b></p><div id="1ec2"><pre>{ <span class="hljs-string">"binance"</span> : { <span class="hljs-string">"api_url"</span> : "<span class="hljs-type">https</span>://api.binance.com<span class="hljs-string">", "</span>api_key<span class="hljs-string">" : "</span><span class="hljs-number">0000000000000000000000000000000000000000000000000000000000000000</span><span class="hljs-string">", "</span>api_secret<span class="hljs-string">" : "</span><span class="hljs-number">0000000000000000000000000000000000000000000000000000000000000000</span><span class="hljs-string">", "</span>config<span class="hljs-string">" : { "</span>base_currency<span class="hljs-string">" : "</span>BTC<span class="hljs-string">", "</span>quote_currency<span class="hljs-string">" : "</span>USDT<span class="hljs-string">", "</span>granularity<span class="hljs-string">" : "</span><span class="hljs-number">1</span>h<span class="hljs-string">", "</span>live<span class="hljs-string">" : 1, "</span>verbose<span class="hljs-string">" : 0 }
}, "</span>coinbasepro<span class="hljs-string">" : { "</span>api_url<span class="hljs-string">" : "</span>https://api.pro.coinbase.com<span class="hljs-string">", "</span>api_key<span class="hljs-string">" : "</span><span class="hljs-number">00000000000000000000000000000000</span><span class="hljs-string">", "</span>api_secret<span class="hljs-string">" : "</span><span class="hljs-number">0000000000000000</span>/<span class="hljs-number">000000000000000000000000000000000000000000000000000000000000000000000</span><span class="hljs-string">", "</span>api_passphrase<span class="hljs-string">" : "</span><span class="hljs-number">00000000000</span><span class="hljs-string">", "</span>config<span class="hljs-string">" : { "</span>base_currency<span class="hljs-string">" : "</span>BTC<span class="hljs-string">", "</span>quote_currency<span class="hljs-string">" : "</span>GBP<span class="hljs-string">", "</span>granularity<span class="hljs-string">" : "</span><span class="hljs-number">3600</span><span class="hljs-string">", "</span>live<span class="hljs-string">" : 1, "</span>verbose<span class="hljs-string">" : 0 }
} }</span></pre></div><p id="d283">A few important points to note here.</p><ul><li>You don’t need to have both “coinbasepro” and “binance” configuration for the bot to work. You need at least one but can have both.</li><li>I used to have “cryptoMarket” and “fiatMarket” in the configuration. This was fine for Coinbase Pro and what I was using the bot for initially but it’s not technically correct. Usually trading pairs are between a base currency and quote currency which may be crypto to fiat or crypto to crypto.</li><li>I renamed “api_pass” to “api_passphrase” for “coinbasepro”.</li><li>Coinbase Pro has a numeric granularity whereas Binance as a string granularity. For example 1 hour for Coinbase Pro is “3600” but for Binance it is “1h”.</li><li>All the “config” in the config.json can actually be passed in with arguments as well. The “config” section is optional. If you omit it then you need to pass each one with an argument. I personally like to just start the bots without arguments and have all the settings reloaded but it’s up to you.</li></ul><p id="9579">Just an an example, in the config.json you can include “base_currency”, “quote_currency” and “granularity” but you could also start the bot like this which would do the same thing.</p><div id="119b"><pre><span class="hljs-comment">python3 pycryptobot</span> <span class="hljs-literal">--</span><span class="hljs-comment">market BTCUSDT</span> <span class="hljs-literal">--</span><span class="hljs-comment">granularity 1h</span></pre></div><h2 id="47f2">Arguments and Config</h2><p id="4fa8">I wanted to avoid all of you having to edit the code directly and wanted to make the majority of config and settings available via the config.json and arguments.</p><div id="e071"><pre><span class="hljs-attr">--market</span> <market> E<span class="hljs-selector-class">.g</span>. <span class="hljs-attr">--market</span> BTC-GBP, <span class="hljs-attr">--market</span> BTCUSDT</pre></div><div id="e3ec"><pre><span class="hljs-attr">--granularity</span> <granularity> E<span class="hljs-selector-class">.g</span>. <span class="hljs-attr">--granularity</span> <span class="hljs-number">3600</span>, <span class="hljs-attr">--granularity</span> <span class="hljs-number">1</span>h</pre></div><div id="f0ae"><pre>--verbose <<span class="hljs-type">int</span>> E.g. <span class="hljs-number">0</span> = verbose <span class="hljs-title function_">output</span> <span class="hljs-params">(<span class="hljs-keyword">default</span>)</span>, <span class="hljs-number">1</span> = minimal <span class="hljs-title function_">output</span> <span class="hljs-params">(my pref)</span></pre></div><div id="a831"><pre>--live <<span class="hljs-type">int</span>> E.g. <span class="hljs-number">0</span> = test <span class="hljs-title function_">mode</span> <span class="hljs-params">(<span class="hljs-keyword">default</span>)</span>, <span class="hljs-number">1</span> = live <span class="hljs-title function_">mode</span> <span class="hljs-params">(executes live trades)</span></pre></div><div id="fd37"><pre>--sim <fast|<span class="hljs-type">fast</span>-sample|<span class="hljs-type">slow</span>|<span class="hljs-type">slow</span>-sample></pre></div><div id="b00d"><pre>fast - iterates through <span class="hljs-keyword">the</span> <span class="hljs-keyword">last</span> <span class="hljs-number">300</span> intervals (probably hours) <span class="hljs-keyword">of</span> data simulating what <span class="hljs-keyword">the</span> bot would have done fast-sample - iterates through <span class="hljs-keyword">a</span> <span class="hljs-built_in">random</span> <span class="hljs-number">300</span> intervals <span class="hljs-keyword">of</span> data over <span class="hljs-keyword">the</span> <span class="hljs-keyword">last</span> <span class="hljs-number">5</span> years slow - same <span class="hljs-keyword">as</span> fast but iterates <span class="hljs-keyword">each</span> <span class="hljs-keyword">second</span> slow-sample - same <span class="hljs-keyword">as</span> fast but iterates <span class="hljs-keyword">each</span> <span class="hljs-keyword">second</span></pre></div><div id="d2b4"><pre><span class="hljs-attr">--sellupperpcnt</span> <int> E<span class="hljs-selector-class">.g</span>. <span class="hljs-number">5</span> = forced sell at <span class="hljs-number">5%</span> <span class="hljs-attribute">margin</span></pre></div><div id="d279"><pre><span class="hljs-attr">--selllowerpcnt</span> <int> E<span class="hljs-selector-class">.g</span>. -<span class="hljs-number">2</span> = forced sell at -<span class="hljs-number">2%</span> <span class="hljs-attribute">margin</span></pre></div><p id="2395">The “sellupperpcnt” and “selllowerpcnt” are optional but they are useful. I usually set my “selllowerpcnt” to -2 in most markets. In other markets I either have no upper limit or something suitable depending on the market. Maybe for Stellar I may have 8% but for Bitcoin maybe 3%. I think it’s better to lock in the profit more regularly but it’s just a personal preference.</p><h2 id="e4cc">Confirmation it works!</h2><p id="2612">This is a Coinbase Pro simulation for BTC-GBP using the 1 day charts.</p><div id="70c6"><pre><span class="hljs-section">pycryptobot % python3 pycryptobot.py --exchange coinbasepro --market BTC-GBP --granularity 86400 --verbose 0 --selllowerpcnt -2 --sim fast --------------------------------------------------------------------</span> <span class="hljs-section">| Python Crypto Bot | --------------------------------------------------------------------</span> | Bot Mode : TEST - test trades using dummy funds :) | <span class="hljs-section">| Bot Started : 2021-03-06 21:27:36.136885 | ====================================================================</span> <span class="hljs-section">| Sell Lower : -2.0% | ====================================================================</span> 2020-05-11 | BTC-GBP | 86400 | Close: 6970.13 | EMA12/26: 6970.13 = 6970.13 | MACD: 0.0 = 0.0 | WAIT 2020-05-12 | BTC-GBP | 86400 | Close: 7210.0 | <span class="hljs-strong">^ EMA12/26: 7007.03 > 6987.89 ^</span> | <span class="hljs-strong">^ MACD: 19.13 > 3.82 ^</span> | WAIT 2020-05-13 | BTC-GBP | 86400 | Close: 7630.0 | ^ EMA12/26: 7102.87 > 7035.46 ^ | ^ MACD: 67.41 > 16.54 ^ | WAIT <span class="hljs-bullet">*** </span>Candlestick Detected: Three White Soldiers ("Strong - Reversal - Bullish Pattern - Up")</pre></div><div id="4390"><pre><span class="hljs-section"><reduced output for example></span></pre></div><div id="4359"><pre><span class="hljs-number">2021</span><span class="hljs-number">-03</span><span class="hljs-number">-05</span> | <span class="hljs-type">BTC</span>-GBP (BULL) | <span class="hljs-type">86400</span> | <span class="hljs-type">Close</span>: <span class="hljs-number">35229.57</span> | <span class="hljs-type">^ EMA12</span>/<span class="hljs-number">26</span>: <span class="hljs-num

Options

ber">35078.86</span> > <span class="hljs-number">34069.19</span> ^ | <span class="hljs-type">v</span> MACD: <span class="hljs-number">1009.66</span> < <span class="hljs-number">1481.19</span> v | <span class="hljs-type">WAIT</span> | <span class="hljs-type">Last</span> Action: BUY | <span class="hljs-type">75</span><span class="hljs-number">.79</span>%

  • Candlestick Detected: Hammer (<span class="hljs-string">"Weak - Reversal - Bullish Signal - Up"</span>)</pre></div><div id="5531"><pre><span class="hljs-attribute">2021</span>-<span class="hljs-number">03</span>-<span class="hljs-number">06</span> | BTC-GBP (BULL) | <span class="hljs-number">86400</span> | Close: <span class="hljs-number">34999</span>.<span class="hljs-number">61</span> | ^ EMA12/<span class="hljs-number">26</span>: <span class="hljs-number">35066</span>.<span class="hljs-number">67</span> > <span class="hljs-number">34138</span>.<span class="hljs-number">11</span> ^ | v MACD: <span class="hljs-number">928</span>.<span class="hljs-number">55</span> < <span class="hljs-number">1370</span>.<span class="hljs-number">66</span> v | WAIT | Last Action: BUY | <span class="hljs-number">75</span>.<span class="hljs-number">63</span>%</pre></div><div id="ae6b"><pre>Simulation <span class="hljs-selector-tag">Summary</span></pre></div><div id="7459"><pre><span class="hljs-keyword">Buy </span><span class="hljs-built_in">Count</span> : <span class="hljs-number">2</span> Sell <span class="hljs-built_in">Count</span> : <span class="hljs-number">2</span></pre></div><div id="6189"><pre><span class="hljs-attribute">Margin</span> : <span class="hljs-number">60</span>.<span class="hljs-number">46</span>%</pre></div><div id="ad4c"><pre><span class="hljs-bullet">** </span>non-live simulation, assuming highest fees</pre></div><p id="e3c1">This is a Binance simulation for DOGEUSDT using 6 hour charts.</p><div id="1194"><pre>pycryptobot % python3 pycryptobot.py --exchange binance --market DOGEUSDT --granularity 6h --verbose 0 --selllowerpcnt -2 --sim fast

|<span class="hljs-string"> Python Crypto Bot </span>|

|<span class="hljs-string"> Bot Mode : TEST - test trades using dummy funds :) </span>| |<span class="hljs-string"> Bot Started : 2021-03-06 21:34:26.917574 </span>|

|<span class="hljs-string"> Sell Lower : -2.0% </span>|

2020-12-22 |<span class="hljs-string"> DOGEUSDT </span>|<span class="hljs-string"> 6h </span>|<span class="hljs-string"> Close: 0.0046182 </span>|<span class="hljs-string"> EMA12/26: 0.0046182 = 0.0046182 </span>|<span class="hljs-string"> MACD: 0.0000 = 0.0000 </span>|<span class="hljs-string"> WAIT 2020-12-22 06:00:00 </span>|<span class="hljs-string"> DOGEUSDT </span>|<span class="hljs-string"> 6h </span>|<span class="hljs-string"> Close: 0.0046399 </span>|<span class="hljs-string"> ^ EMA12/26: 0.00462153 > 0.0046198 ^ </span>|<span class="hljs-string"> ^ MACD: 0.0000 > 0.0000 ^ </span>|<span class="hljs-string"> WAIT 2020-12-22 12:00:00 </span>|<span class="hljs-string"> DOGEUSDT </span>|<span class="hljs-string"> 6h </span>|<span class="hljs-string"> Close: 0.0045713 </span>|<span class="hljs-string"> v EMA12/26: 0.0046138 < 0.00461621 v </span>|<span class="hljs-string"> v MACD: -0.0000 < -0.0000 v </span>|<span class="hljs-string"> WAIT 2020-12-22 18:00:00 </span>|<span class="hljs-string"> DOGEUSDT </span>|<span class="hljs-string"> 6h </span>|<span class="hljs-string"> Close: 0.0045159 </span>|<span class="hljs-string"> v EMA12/26: 0.00459874 < 0.00460878 v </span>|<span class="hljs-string"> v MACD: -0.0000 < -0.0000 v </span>|<span class="hljs-string"> WAIT 2020-12-23 </span>|<span class="hljs-string"> DOGEUSDT </span>|<span class="hljs-string"> 6h </span>|<span class="hljs-string"> Close: 0.0044539 </span>|<span class="hljs-string"> v EMA12/26: 0.00457646 < 0.00459731 v </span>|<span class="hljs-string"> v MACD: -0.0000 < -0.0000 v </span>|<span class="hljs-string"> WAIT 2020-12-23 06:00:00 </span>|<span class="hljs-string"> DOGEUSDT </span>|<span class="hljs-string"> 6h </span>|<span class="hljs-string"> Close: 0.0041677 </span>|<span class="hljs-string"> v EMA12/26: 0.00451357 < 0.00456548 v </span>|<span class="hljs-string"> v MACD: -0.0001 < -0.0000 v </span>|<span class="hljs-string"> WAIT 2020-12-23 12:00:00 </span>|<span class="hljs-string"> DOGEUSDT </span>|<span class="hljs-string"> 6h </span>|<span class="hljs-string"> Close: 0.00409749 </span>|<span class="hljs-string"> v EMA12/26: 0.00444956 < 0.00453082 v </span>|<span class="hljs-string"> v MACD: -0.0001 < -0.0000 v </span>|<span class="hljs-string"> WAIT</span></pre></div><div id="c705"><pre><span class="hljs-section"><reduced output for example></span></pre></div><div id="6383"><pre><span class="hljs-attribute">2021</span>-<span class="hljs-number">03</span>-<span class="hljs-number">06</span> <span class="hljs-number">12</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span> | DOGEUSDT (BULL) | <span class="hljs-number">6</span>h | Close: <span class="hljs-number">0</span>.<span class="hljs-number">05</span> | v EMA12/<span class="hljs-number">26</span>: <span class="hljs-number">0</span>.<span class="hljs-number">05</span> < <span class="hljs-number">0</span>.<span class="hljs-number">05</span> v | ^ MACD: -<span class="hljs-number">0</span>.<span class="hljs-number">01</span> > -<span class="hljs-number">0</span>.<span class="hljs-number">01</span> ^ | WAIT | Last Action: SELL <span class="hljs-attribute">2021</span>-<span class="hljs-number">03</span>-<span class="hljs-number">06</span> <span class="hljs-number">18</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span> | DOGEUSDT (BULL) | <span class="hljs-number">6</span>h | Close: <span class="hljs-number">0</span>.<span class="hljs-number">05</span> | ^ EMA12/<span class="hljs-number">26</span>: <span class="hljs-number">0</span>.<span class="hljs-number">05</span> > <span class="hljs-number">0</span>.<span class="hljs-number">05</span> ^ | ^ MACD: <span class="hljs-number">0</span>.<span class="hljs-number">0</span> > -<span class="hljs-number">0</span>.<span class="hljs-number">01</span> ^ | BUY | Last Action: SELL</pre></div><div id="e66e"><pre><span class="hljs-attribute">2021</span>-<span class="hljs-number">03</span>-<span class="hljs-number">06</span> <span class="hljs-number">18</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span> | DOGEUSDT <span class="hljs-number">6</span>h | Close: <span class="hljs-number">0</span>.<span class="hljs-number">05</span> | BUY <span class="hljs-attribute">Fibonacci</span> Retracement Levels: {'ratio0_5': <span class="hljs-number">0</span>.<span class="hljs-number">04</span>, 'ratio0_382': <span class="hljs-number">0</span>.<span class="hljs-number">05</span>} <span class="hljs-attribute">Support</span> level of <span class="hljs-number">0</span>.<span class="hljs-number">0506003</span> formed at <span class="hljs-number">2021</span>-<span class="hljs-number">02</span>-<span class="hljs-number">16</span> <span class="hljs-number">18</span>:<span class="hljs-number">00</span>:<span class="hljs-number">00</span></pre></div><div id="ff65"><pre>Simulation <span class="hljs-selector-tag">Summary</span></pre></div><div id="762f"><pre><span class="hljs-keyword">Buy </span><span class="hljs-built_in">Count</span> : <span class="hljs-number">3</span> Sell <span class="hljs-built_in">Count</span> : <span class="hljs-number">3</span></pre></div><div id="3987"><pre><span class="hljs-attribute">Margin</span> : <span class="hljs-number">39</span>.<span class="hljs-number">85</span>%</pre></div><div id="03cd"><pre><span class="hljs-bullet">** </span>non-live simulation, assuming highest fees</pre></div><p id="08d0">I get at least 2–5 emails a day from all of you asking questions or help with the bot. Feel free to reach out if you like, my email address is [email protected] and I will answer when I can. I think I may write a FAQ sometime with your questions and my answers as I think others will find them interesting.</p><p id="7b2c">Good luck :)</p><p id="53f8"><b>*** 09/2021 UPDATE ***</b></p><p id="349b">PyCryptoBot version 3 is here!</p><p id="02fa">If you want to catch up with the project I recommend the following my Medium publication, <a href="https://trading-data-analysis.pro/">Trading Data Analysis</a>.</p><h1 id="1323">Michael Whittle</h1><ul><li><b><i>If you enjoyed this, please <a href="https://whittle.medium.com/">follow me on Medium</a></i></b></li><li><b><i>For more interesting articles, please <a href="https://medium.com/trading-data-analysis">follow my publication</a></i></b></li><li><b><i>Interested in collaborating? <a href="https://www.linkedin.com/in/miwhittle/">Let’s connect on LinkedIn</a></i></b></li><li><b><i>Support me and other Medium writers <a href="https://whittle.medium.com/membership">by signing up here</a></i></b></li><li><b><i>Please don’t forget to clap for the article :) ← Thank you!</i></b></li></ul></article></body>

What’s new in PyCryptoBot 2?

Automated crypto trading on Coinbase Pro, Binance and Kucoin

For those unfamiliar with my project: https://github.com/whittlem/pycryptobot

The first version of the crypto trading bot using Coinbase Pro was very successful. For those who contributed by following me on Medium, applauding my articles, crypto donations and requesting paid-for features like adding the Binance exchange, it is very much appreciated. This project is completely free to use under the Apache 2.0 license but your contributions do make a difference to cover my time and effort.

The existing version (1.0.0) of the app in the “main” branch in my repo only supports Coinbase Pro. It works well in a bull market but was tested after Elon’s tweets last week which put the market into steep decline. I realised I needed to factor in code to make sure the bot does not attempt to trade in poor conditions. The new version (2.0.0) of the app in the “binance” branch in my repo supports both Coinbase Pro and Binance. It is also more resilient to poor market conditions and will only trade in a bull market. Although my 5 bots only traded twice in the last week of disaster it still made 6% on two trades which was okay considering the market conditions. Usually each bot makes around 5% every 1–3 days if not more.

I’m planning on merging the “binance” branch into “main” on the 1st of April 2021. I will create a release branch of the current version in case anyone has problems upgrading to Python 3.9.

I’m going to assume you read my previous article and have the existing version of the bot up and running.

Prerequisites

Make sure you have upgraded to Python 3.9.x

% python3 --version
Python 3.9.1

If not, this resource is really good to help with installing and upgrading depending on your platform.

In your existing bot directory change to the “binance” branch.

pycryptobot % git fetch
remote: Enumerating objects: 17, done.
remote: Counting objects: 100% (17/17), done.
remote: Compressing objects: 100% (7/7), done.
remote: Total 13 (delta 9), reused 10 (delta 6), pack-reused 0
Unpacking objects: 100% (13/13), done.
From https://github.com/whittlem/pycryptobot
   a01b480..d27bdde  binance    -> origin/binance
pycryptobot % git checkout binance
Switched to branch 'binance'
Your branch is behind 'origin/binance' by 4 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)
pycryptobot % git pull
Already up to date.
pycryptobot % git branch
* binance
  main

You will now want to install/update dependencies.

% python3 -m pip install -r requirements.txt

If you have go this far then you are good to go…

If for any reason you get stuck and want to revert you can do this.

% git checkout main
Switched to branch 'main'
Your branch is behind 'origin/main' by 10 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)
% git branch
  binance
* main
% git pull
Already up to date.

It’s also worth mentioning that if you have altered or changed my code in any way it may prevent you from doing this.

This is how you can revert to the original state.

pycryptobot % git checkout .
Updated 1 path from the index

You should not see any modified files.

% git status
On branch main
Your branch is behind 'origin/main' by 10 commits, and can be fast-forwarded.
  (use "git pull" to update your local branch)
nothing to commit, working tree clean

If you want to make absolutely sure you revert all changes you can do this.

pycryptobot % git reset --hard
HEAD is now at 19ea276 minor updates

If all else fails you could just make a backup of your config.json, delete the bot directory, and re-clone it as per my previous article, and put the config.json back.

I’m just covering all bases here but really you should just be able to change to the “binance” branch with no issue.

Configuration

I’ve tried to make sure the version 1 and 2 bots are backward compatible. The version 2 bot should still work fine with the version 1 config.json file format.

config.json (version 1.x)

{
    "api_url" : "https://api.pro.coinbase.com",
    "api_key" : "00000000000000000000000000000000",
    "api_secret" : "0000000000000000/000000000000000000000000000000000000000000000000000000000000000000000",
    "api_pass" : "00000000000"
}

You just replace the “api_key”, “api_secret” and “api_pass” with your Coinbase Pro keys which you probably have already done. This still works with version 2.

config.json (version 2.x)

{
    "binance" : {
        "api_url" : "https://api.binance.com",
        "api_key" : "0000000000000000000000000000000000000000000000000000000000000000",
        "api_secret" : "0000000000000000000000000000000000000000000000000000000000000000",
        "config" : {
            "base_currency" : "BTC",
            "quote_currency" : "USDT",
            "granularity" : "1h",
            "live" : 1,
            "verbose" : 0
        }        
    },
    "coinbasepro" : {
        "api_url" : "https://api.pro.coinbase.com",
        "api_key" : "00000000000000000000000000000000",
        "api_secret" : "0000000000000000/000000000000000000000000000000000000000000000000000000000000000000000",
        "api_passphrase" : "00000000000",
        "config" : {
            "base_currency" : "BTC",
            "quote_currency" : "GBP",
            "granularity" : "3600",
            "live" : 1,
            "verbose" : 0
        }    
    }
}

A few important points to note here.

  • You don’t need to have both “coinbasepro” and “binance” configuration for the bot to work. You need at least one but can have both.
  • I used to have “cryptoMarket” and “fiatMarket” in the configuration. This was fine for Coinbase Pro and what I was using the bot for initially but it’s not technically correct. Usually trading pairs are between a base currency and quote currency which may be crypto to fiat or crypto to crypto.
  • I renamed “api_pass” to “api_passphrase” for “coinbasepro”.
  • Coinbase Pro has a numeric granularity whereas Binance as a string granularity. For example 1 hour for Coinbase Pro is “3600” but for Binance it is “1h”.
  • All the “config” in the config.json can actually be passed in with arguments as well. The “config” section is optional. If you omit it then you need to pass each one with an argument. I personally like to just start the bots without arguments and have all the settings reloaded but it’s up to you.

Just an an example, in the config.json you can include “base_currency”, “quote_currency” and “granularity” but you could also start the bot like this which would do the same thing.

python3 pycryptobot --market BTCUSDT --granularity 1h

Arguments and Config

I wanted to avoid all of you having to edit the code directly and wanted to make the majority of config and settings available via the config.json and arguments.

--market <market>
E.g. --market BTC-GBP, --market BTCUSDT
--granularity <granularity>
E.g. --granularity 3600, --granularity 1h
--verbose <int>
E.g. 0 = verbose output (default), 1 = minimal output (my pref)
--live <int>
E.g. 0 = test mode (default), 1 = live mode (executes live trades)
--sim <fast|fast-sample|slow|slow-sample>
fast - iterates through the last 300 intervals (probably hours) of data simulating what the bot would have done
fast-sample - iterates through a random 300 intervals of data over the last 5 years
slow - same as fast but iterates each second
slow-sample - same as fast but iterates each second
--sellupperpcnt <int>
E.g. 5 = forced sell at 5% margin
--selllowerpcnt <int>
E.g. -2 = forced sell at -2% margin

The “sellupperpcnt” and “selllowerpcnt” are optional but they are useful. I usually set my “selllowerpcnt” to -2 in most markets. In other markets I either have no upper limit or something suitable depending on the market. Maybe for Stellar I may have 8% but for Bitcoin maybe 3%. I think it’s better to lock in the profit more regularly but it’s just a personal preference.

Confirmation it works!

This is a Coinbase Pro simulation for BTC-GBP using the 1 day charts.

pycryptobot % python3 pycryptobot.py --exchange coinbasepro --market BTC-GBP --granularity 86400 --verbose 0 --selllowerpcnt -2 --sim fast
--------------------------------------------------------------------
|                       Python Crypto Bot                          |
--------------------------------------------------------------------
|          Bot Mode : TEST - test trades using dummy funds :)      |
|       Bot Started : 2021-03-06 21:27:36.136885                   |
====================================================================
|        Sell Lower : -2.0%                                        |
====================================================================
2020-05-11 | BTC-GBP | 86400 | Close: 6970.13 | EMA12/26: 6970.13 = 6970.13 | MACD: 0.0 = 0.0 | WAIT 
2020-05-12 | BTC-GBP | 86400 | Close: 7210.0 | *^ EMA12/26: 7007.03 > 6987.89 ^* | *^ MACD: 19.13 > 3.82 ^* | WAIT 
2020-05-13 | BTC-GBP | 86400 | Close: 7630.0 | ^ EMA12/26: 7102.87 > 7035.46 ^ | ^ MACD: 67.41 > 16.54 ^ | WAIT 
*** Candlestick Detected: Three White Soldiers ("Strong - Reversal - Bullish Pattern - Up")
<reduced output for example>
2021-03-05 | BTC-GBP (BULL) | 86400 | Close: 35229.57 | ^ EMA12/26: 35078.86 > 34069.19 ^ | v MACD: 1009.66 < 1481.19 v | WAIT | Last Action: BUY | 75.79%
* Candlestick Detected: Hammer ("Weak - Reversal - Bullish Signal - Up")
2021-03-06 | BTC-GBP (BULL) | 86400 | Close: 34999.61 | ^ EMA12/26: 35066.67 > 34138.11 ^ | v MACD: 928.55 < 1370.66 v | WAIT | Last Action: BUY | 75.63%
Simulation Summary
Buy Count : 2
  Sell Count : 2
Margin : 60.46%
** non-live simulation, assuming highest fees

This is a Binance simulation for DOGEUSDT using 6 hour charts.

pycryptobot % python3 pycryptobot.py --exchange binance --market DOGEUSDT --granularity 6h --verbose 0 --selllowerpcnt -2 --sim fast
--------------------------------------------------------------------
|                         Python Crypto Bot                        |
--------------------------------------------------------------------
|          Bot Mode : TEST - test trades using dummy funds :)      |
|       Bot Started : 2021-03-06 21:34:26.917574                   |
====================================================================
|        Sell Lower : -2.0%                                        |
====================================================================
2020-12-22 | DOGEUSDT | 6h | Close: 0.0046182 | EMA12/26: 0.0046182 = 0.0046182 | MACD: 0.0000 = 0.0000 | WAIT 
2020-12-22 06:00:00 | DOGEUSDT | 6h | Close: 0.0046399 | *^ EMA12/26: 0.00462153 > 0.0046198 ^* | *^ MACD: 0.0000 > 0.0000 ^* | WAIT 
2020-12-22 12:00:00 | DOGEUSDT | 6h | Close: 0.0045713 | *v EMA12/26: 0.0046138 < 0.00461621 v* | *v MACD: -0.0000 < -0.0000 v* | WAIT 
2020-12-22 18:00:00 | DOGEUSDT | 6h | Close: 0.0045159 | v EMA12/26: 0.00459874 < 0.00460878 v | v MACD: -0.0000 < -0.0000 v | WAIT 
2020-12-23 | DOGEUSDT | 6h | Close: 0.0044539 | v EMA12/26: 0.00457646 < 0.00459731 v | v MACD: -0.0000 < -0.0000 v | WAIT 
2020-12-23 06:00:00 | DOGEUSDT | 6h | Close: 0.0041677 | v EMA12/26: 0.00451357 < 0.00456548 v | v MACD: -0.0001 < -0.0000 v | WAIT 
2020-12-23 12:00:00 | DOGEUSDT | 6h | Close: 0.00409749 | v EMA12/26: 0.00444956 < 0.00453082 v | v MACD: -0.0001 < -0.0000 v | WAIT
<reduced output for example>
2021-03-06 12:00:00 | DOGEUSDT (BULL) | 6h | Close: 0.05 | v EMA12/26: 0.05 < 0.05 v | ^ MACD: -0.01 > -0.01 ^ | WAIT | Last Action: SELL
2021-03-06 18:00:00 | DOGEUSDT (BULL) | 6h | Close: 0.05 | *^ EMA12/26: 0.05 > 0.05 ^* | ^ MACD: 0.0 > -0.01 ^ | BUY | Last Action: SELL
2021-03-06 18:00:00 | DOGEUSDT 6h | Close: 0.05 | BUY
 Fibonacci Retracement Levels: {'ratio0_5': 0.04, 'ratio0_382': 0.05}
 Support level of 0.0506003 formed at 2021-02-16 18:00:00
Simulation Summary
Buy Count : 3
  Sell Count : 3
Margin : 39.85%
** non-live simulation, assuming highest fees

I get at least 2–5 emails a day from all of you asking questions or help with the bot. Feel free to reach out if you like, my email address is [email protected] and I will answer when I can. I think I may write a FAQ sometime with your questions and my answers as I think others will find them interesting.

Good luck :)

*** 09/2021 UPDATE ***

PyCryptoBot version 3 is here!

If you want to catch up with the project I recommend the following my Medium publication, Trading Data Analysis.

Michael Whittle

Trading Bot
Python
Bitcoin
Automated Trading
Cryptocurrency
Recommended from ReadMedium