Success with PyCryptoBot
“Whooptydoo. But what does it all mean Basil?”
The crypto bot I developed is really going from strength to strength.

People thought I was “nuts” for giving my crypto bot away for free. My view at the time was that open sourcing it would create a much better product all round. To date I’ve had 10 developers contribute to the application and many people email me or “raise issues” in the repo with suggestions, feature requests for the roadmap, and some have helped fix issues. It’s just great to see the open source community in action.
Although under the Apache 2.0 License I’ve allowed other developers to use my code in their projects, many out of courtesy have let me know. It’s really interesting to know how my code has been adapted for other “spin offs”. I know of one cloud based solution that has been created and someone contacted me on LinkedIn to say they want to use similar logic in their horse racing betting app.
Your bot(s) can be configured in two main ways. Either by passing options via command line arguments or in a config.json file (you can also specify your own filename and location).
I’m going to explain all the options…
Specify the exchange you want to use. Either “coinbasepro”, “binance” or “dummy”. The default is “coinbasepro”.
--exchange <exchange>Specify the market you wish to trade.
--market <market># Coinbase Pro: <base currency>-<quote currency> E.g. BTC-GBP
# Binance: <base currency><quote currency> E.g. BTCGBPSpecify the granularity or graph intervals. Omitting the “granularity” will activate the “smart switching” feature discussed further down.
--granularity <granularity># Coinbase Pro: 60, 300, 900, 3600, 21600, 86400
# Binance: 1m, 5m, 15m, 1h, 6h, 1dIf you would like to the bot to save graph diagrams on a buy or sell you can enable it like this.
--graphs <1 or 0>One of the most important options is if you want the bot to run in live or test mode. The default is test mode. If you want to switch to live mode and your config.json is ready you can enable it like this.
--live <1 or 0>By default the bot will use technical analysis for buy and sell signals. This is normal for trading mechanics but it’s not full proof otherwise we would all be millionaires. On occasion there will be a small loss either by something unpredictable in the market or maybe the trade did not have enough momentum to cover the fees and make a profit. You are able to disable the selling at a loss like this. Although disabling sell at loss has its benefits of never making a loss the downside is that it may tie a trade up for a long time and you may miss out on future buys. I personally disable sell at loss but it’s really a personal preference.
--sellatloss <1 or 0>If you want to set a fixed margin to sell at you can do this.
--sellupperpcnt <float> E.g. --sellupperpcnt 5--selllowerpcnt <float> E.g. --selllowerpcnt "-1.5"A slight variation to the “selllowerpcnt” is “trailingstoploss”. It has the same concept as the “selllowerpcnt” but it is a moving target behind the high of the buy. For example if you have it set to -2 then if the price goes up to 10% and then drops to 8% it will sell because the price dropped 2% lower than the high.
--trailingstoploss <float> E.g. --trailingstoploss -2If you want to run non-live simulations on historical data you can do this.
--sim <fast | fast-sample | slow | slow-sample>“fast” will process the last 300 intervals (E.g. hours) as fast as it can go. “fast-sample” will process a random 300 intervals (E.g. days) as fast as it can go. “slow” and “slow-sample” is similar but every interval is one second.
If you want to specify a date to start the simulation sample from you can do this.
--simstartdate <date> E.g. --simstartdate 2021-01-15If you want to “smart switch” between the 1 hour and 15 minute graphs depending on market conditions you can do it in two ways. Either you can omit the “granularity” from the configuration or arguments or you can specify it manually.
--smartswitch <1 or 0>The default option now is non-verbose output. If you want more detailed output you can turn it on.
--verbose <1 or 0>By default the bot will look for a, “config.json” file in the project root for its configuration. You may want to point your bot configuration to file in another location. A typical use case or this is if you are running the bot as a Docker container.
--config <config.json> E.g. --config /tmp/btc-gbp.json
By default the log file created is, “pycryptobot.log”. You can also specify a different name and location like this.
--logfile <pycryptobot.log> E.g. --logfile /var/log/btc-gbp.logThe default behaviour is for the bot to buy with all quote currency funds it has access too and sell all base currency funds it has access too. If you are not running multiple exchange portfolios per bot you can specify a percentage of the funds to be used.
--buypercent <percent> E.g. --buypercent 50--sellpercent <percent> E.g. --sellpercent 50One option I use myself but optional for others is to sell when the price hits either a resistance level or upper Fibonacci band. This may cut the trade off early but the main purpose is locking in smaller profits more often. I personally go for 1–2% trades on large amounts frequently so this option works really well for me.
--sellatresistanceI’ve tried to develop the bot with the best options as default to make it easy to use for others. If you are more experienced you may want to alter the default behaviour. I’ve developed the bot so almost all options can be disabled if required.
The list of options you can disable is as follows:
--disablebullonly (disable only buying in bull market)--disablebuynearhigh (disable buy within 3 percent of high)--disablebuymacd (disable macd buy signal)--disablebuyobv (disable obv buy signal)--disablebuyelderray (disable elder ray buy signal)--disablefailsafefibonaccilow (disable failsafe sell on fibonacci lower band)--disablefailsafelowerpcnt (disable failsafe sell on ‘selllowerpcnt’)--disableprofitbankupperpcnt (disable profit bank on ‘sellupperpcnt')--disableprofitbankreversal (disable profit bank on strong candlestick reversal)--disabletelegram (disable telegram messages)--disablelog (disable logging)--disabletracker (disable tracker.csv)What does this look like in practice?
My Coinbase Pro config.json currently looks like this.
{
"coinbasepro" : {
"api_url" : "https://api.pro.coinbase.com",
"api_key" : "",
"api_secret" : "",
"api_passphrase" : "",
"config" : {
"base_currency" : "BTC",
"quote_currency" : "GBP",
"live" : 1,
"sellatloss" : 0,
"sellatresistance" : 1,
"disablebullonly" : 1,
"disablebuynearhigh" : 1,
"disablebuyobv" : 1,
"disablebuyelderray" : 1,
"disablelog" : 1,
"disabletracker" : 1
}
},
"telegram" : {
"token" : "",
"client_id" : ""
}
}Actually all my bots look like this with the “base_currency” relevant to the market the bot is trading.
An example of what a Binance config would look like.
{
"binance" : {
"api_url" : "https://api.binance.com",
"api_key" : "",
"api_secret" : "",
"config" : {
"base_currency" : "BTC",
"quote_currency" : "GBP",
"live" : 1,
"sellatloss" : 0,
"sellatresistance" : 1,
"disablebullonly" : 1,
"disablebuynearhigh" : 1,
"disablebuyobv" : 1,
"disablebuyelderray" : 1,
"disablelog" : 1,
"disabletracker" : 1
}
},
"telegram" : {
"token" : "",
"client_id" : ""
}
}You may or may not have Telegram configured. If you don’t, I highly recommend it. If you don’t then you can leave that part out.
*** 09/2021 UPDATE ***
PyCryptoBot version 3 is here!
*** 11/2021 UPDATE ***
There are many configurations people are running with the bot now depending on their risk appetite.
Example configurations:
- Tuned for bull market conditions (sells at small losses if required to maximise profits)
- Tuned for bear market conditions (does not sell at a loss but has the downside of potentially missing out on profitable trades or getting locked into the market for months during a market crash)
- Scalping configuration for not selling the full amount
- Mass bot configurations to buy and sell using a percentage of funds
- Custom technical indicator configurations
There are many more, but this gives you an idea.
I plan on writing an updated article to this one with the common configurations being used. I suggest following me and subscribing to the email list to be notified when it is published in the next few weeks.
Just a reminder, all my technical analysis and PyCryptoBot articles can be found in my Trading Data Analysis publication on Medium. If you would like to be kept up to date with further updates, I recommend following the publication.
I hope you found this article interesting and useful. If you would like to be kept informed, please don’t forget to follow me and sign up to my email notifications.
Michael Whittle
- If you enjoyed this, please follow me on Medium
- For more interesting articles, please follow my publication
- Interested in collaborating? Let’s connect on LinkedIn
- Support me and other Medium writers by signing up here
- Please don’t forget to clap for the article :) ← Thank you!




