{"data":{"site":{"siteMetadata":{"title":"IJHDev Blog","author":"Ian Hayward"}},"markdownRemark":{"id":"c77e4bdd-87a3-5ff7-9f5d-0beaae17756f","html":"<p>A guide on making a simple bot that can trade while you focus on the hard stuff</p>\n<!-- end -->\n<h3>The Bot</h3>\n<p><img src=\"./images/bot.jpeg\" alt=\"Bot\"></p>\n<p>The bot we are going to be setting up today is called <a href=\"https://github.com/freqtrade/freqtrade\" target=\"_blank\">Freqtrade</a>.  It’s a very easy to set up bot that can be controlled via <a href=\"https://telegram.org/\" target=\"_blank\">Telegram</a>\n. As we are not going to be using the codebase on our machine, the only file you need from their GitHub is <a href=\"https://github.com/freqtrade/freqtrade/blob/develop/config.json.example\" target=\"_blank\">this json file</a>.  If you copy the lines of this file and paste them into a text editor (I recommend <a href=\"https://www.sublimetext.com/\" target=\"_blank\">Sublime text</a>)  and save the file as config.json.</p>\n<p>Now lets have a look at the config file, the first important part is these two lines</p>\n<ul>\n<li>“max_open_trades”: 3, </li>\n<li>“stake_amount”: 0.05,</li>\n</ul>\n<p>These lines are where you setup how much the bot is going to be using to make it’s trades, so in this example it’s making 3 trades of 0.05 BTC so in total 0.15 BTC needs to be in the account for it to trade effectively. You can change both numbers up or down as much as you like, just make sure you have at least the amount of funds inside for it to make the trades. Remember the more you put in the bigger the reward but the bigger the risk.</p>\n<p>The next section is about setup strategy. The  best thing to do here is leave it alone for your first couple of weeks, the bot learns as it trades (real transactions only) so let it go for a bit before changing something. If you do want to tweak rules later <a href=\"https://freqtrade.io/en/latest/\" target=\"_blank\">Freqtrades documentation is here</a></p>\n<h3>The Exchange</h3>\n<p><img src=\"./images/exchange.jpeg\" alt=\"Exchange\"></p>\n<p>The next important bit is the exchange, for this we are going to be using <a href=\"https://www.binance.com/?ref=27977821\" target=\"_blank\">Binance</a> so sign up or in here <a href=\"https://www.binance.com/?ref=27977821\" target=\"_blank\">https://www.binance.com/?ref=27977821</a> to continue. Once signed in, go to your account and press the API settings button. Name your new API ‘my trading bot’ or something to that effect so you know what the keys relate to. <a href=\"https://www.binance.com/?ref=27977821\" target=\"_blank\">Binance</a> will then take you through a series of steps on setting this up, the important thing to remember is that both <strong>Read Info</strong> and <strong>Enable Trading</strong> are checked and <strong>Enable Withdrawals</strong> is unchecked. Once it give you the keys, copy them both and keep them somewhere safe! You will never see the secret key again and will have to redo this part of the process again if you lose it. Now go back to your config.json file and change the following:</p>\n<ul>\n<li>name needs changing from “bittrex” to “binance”</li>\n<li>replace “your_exchange_key” with your API Key from Binance</li>\n<li>replace “your_exchange_secret” with your Secret Key from Binance</li>\n</ul>\n<p>Before we leave this section, now is a good time to put your BTC your trading with into <a href=\"https://www.binance.com/?ref=27977821\" target=\"_blank\">Binance</a> we talked about further up the guide, it is recommended to put a little more than the planned amount in to allow for the bot to make a couple early mistakes while it learns and improves. </p>\n<p>The next section is the pair_whitelist and pair_blacklist\nThe whitelist is all the currency’s you want the bot to be watching, I would recommend going for 10 to begin with. As for the blacklist, we only need to have BNB/BTC in there as the bot gets confused with <a href=\"https://www.binance.com/?ref=27977821\" target=\"_blank\">Binance</a> using BNB to discount fee’s</p>\n<h3>The Communication</h3>\n<p><img src=\"./images/communication.jpeg\" alt=\"Communication\"></p>\n<p>The next important section of the config file for now is the <a href=\"https://telegram.org/\" target=\"_blank\">Telegram</a> section. This will allow you to get updates from your bot and send it commands like stop/start etc. Firstly on <a href=\"https://telegram.org/\" target=\"_blank\">Telegram</a>, message <strong>@BotFather</strong> with /start followed by /newbot and follow it’s instructions to get your new bot. Copy the HTTP API token it gives you and paste it to replace “your_telegram_token”. Next message <strong>@get_id_bot</strong> with /start and it will give you your chat ID copy it and paste it to replace “your_telegram_chat_id”. This means that your bot will only reply to your ID and ignore any other.</p>\n<h3>The Server</h3>\n<p><img src=\"./images/server.jpeg\" alt=\"Server\"></p>\n<p>With that all done, the final step is to set this all up, <a href=\"https://www.vultr.com/?ref=8109640-4F\" target=\"_blank\">Vultr</a> is a server hosting which this referral code <a href=\"https://www.vultr.com/?ref=8109640-4F\" target=\"_blank\">https://www.vultr.com/?ref=8109640-4F</a> it gives you $50 free credit, the server we well be setting up is only $5 a month so that’s 10 months of free trading! Once you sign up and follow the instructions <a href=\"https://www.vultr.com/?ref=8109640-4F\" target=\"_blank\">Vultr</a> gives, it’s time to set up the server. Press Deploy new server and select <a href=\"https://www.vultr.com/?ref=8109640-4F\" target=\"_blank\">Vultr</a> Cloud Computing, choose the region you would prefer, select Ubuntu as the OS and 16.04 x64 as the version, selected the $5 25GB SSD as your server size. Once that’s all selected click deploy now and wait for <a href=\"https://www.vultr.com/?ref=8109640-4F\" target=\"_blank\">Vultr</a> so set it all up for you, this will take a few mins. Once it’s finished click on the server name and click on the view console icon at the top left and log in. There is going to be a series of commands here to get things setup so just type them in one at a time.</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">apt-get</span> update\n<span class=\"token function\">apt-get</span> <span class=\"token function\">install</span> docker-ce\nsystemctl <span class=\"token function\">enable</span> docker\ndocker pull freqtradeorg/freqtrade:develop\ndocker tag freqtradeorg/freqtrade:develop freqtrade\ndocker build -t freqtrade <span class=\"token keyword\">.</span>\ndocker build -f ./Dockerfile.develop -t freqtrade-dev <span class=\"token keyword\">.</span>\n<span class=\"token function\">mkdir</span> ~/.freqtrade\n<span class=\"token function\">cd</span> ~/.freqtrade\n<span class=\"token function\">mkdir</span> user_data</code></pre></div>\n<p>Once that step is done we need to transfer the config file to the new folder. There is a few different ways to do this, the simplest for most users is to ssh move the file. To do this, open up a command line terminal, navigate to the folder you saved the config.json file and get the ip address of your Vultr server ready and enter the flooring</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\"><span class=\"token function\">scp</span> config.json root@<span class=\"token punctuation\">[</span>enter\\_your\\_ip\\_here<span class=\"token punctuation\">]</span>:/root/.freqtrade\n<span class=\"token function\">touch</span> tradesv3.sqlite\n<span class=\"token function\">scp</span> tradesv3.sqlite root@<span class=\"token punctuation\">[</span>enter\\_your\\_ip\\_here<span class=\"token punctuation\">]</span>:/root/.freqtrade</code></pre></div>\n<h3>The Big Finale</h3>\n<p><img src=\"./images/Finale.jpeg\" alt=\"Finale\"></p>\n<p>Finally go back to your Vultr terminal, it’s time for everything to come together. Run the following command</p>\n<div class=\"gatsby-highlight\" data-language=\"bash\"><pre class=\"language-bash\"><code class=\"language-bash\">docker run -d --name freqtrade -v /etc/localtime:/etc/localtime:ro \n-v ~/.freqtrade/config.json:/freqtrade/config.json \n-v ~/.freqtrade/user_data/:/freqtrade/user_data \n-v ~/.freqtrade/tradesv3.sqlite:/freqtrade/tradesv3.sqlite \nfreqtrade --db-url sqlite:///tradesv3.sqlite</code></pre></div>\n<p>If everything was done right, you should get a message on Telegram that your bot has started. Now it will start scanning the selected currencies for movements and buy and sell as appropriate.</p>\n<p>Congrats on your new bot!</p>","frontmatter":{"title":"Making a simple crypto trade bot","date":"May 26, 2019","featuredImage":{"childImageSharp":{"sizes":{"base64":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAIABQDASIAAhEBAxEB/8QAFwABAAMAAAAAAAAAAAAAAAAAAAEDBf/EABQBAQAAAAAAAAAAAAAAAAAAAAD/2gAMAwEAAhADEAAAAdSAqB//xAAXEAEAAwAAAAAAAAAAAAAAAAABABAR/9oACAEBAAEFAmnZ/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAwEBPwE//8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPwE//8QAHhAAAQEJAAAAAAAAAAAAAAAAABEBAjFBQlFhkaH/2gAIAQEABj8Ct0xuYxFhS8f/xAAaEAADAQEBAQAAAAAAAAAAAAABESEAQTFR/9oACAEBAAE/IYJKRlqPRzCEKNyMgtfgW//aAAwDAQACAAMAAAAQcA//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAEDAQE/ED//xAAUEQEAAAAAAAAAAAAAAAAAAAAQ/9oACAECAQE/ED//xAAcEAEAAgMAAwAAAAAAAAAAAAABEUEAITFRgbH/2gAIAQEAAT8QEAkdMRu6n5kUWJ2sqdj5aw6TigB6zvP/2Q==","aspectRatio":2.4518388791593697,"src":"/static/simplebot-04af69521f9190b864115bb22aac72be-6b3a1.jpg","srcSet":"/static/simplebot-04af69521f9190b864115bb22aac72be-182ff.jpg 213w,\n/static/simplebot-04af69521f9190b864115bb22aac72be-7f5c7.jpg 425w,\n/static/simplebot-04af69521f9190b864115bb22aac72be-6b3a1.jpg 850w,\n/static/simplebot-04af69521f9190b864115bb22aac72be-45cc1.jpg 1275w,\n/static/simplebot-04af69521f9190b864115bb22aac72be-055dc.jpg 1400w","sizes":"(max-width: 850px) 100vw, 850px"}}}}}},"pageContext":{"slug":"/simple-trade-bot/","previous":{"fields":{"slug":"/mobile-ci-cd/"},"excerpt":"A guide on minimizing faff and getting a scalable team moving faster\n","frontmatter":{"title":"CI/CD for Mobile Development","date":"April 13, 2019","featuredImage":{"childImageSharp":{"sizes":{"base64":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAIABQDASIAAhEBAxEB/8QAFgABAQEAAAAAAAAAAAAAAAAAAAMF/8QAFgEBAQEAAAAAAAAAAAAAAAAAAAEC/9oADAMBAAIQAxAAAAHSuERNf//EABkQAAIDAQAAAAAAAAAAAAAAAAECAAMREv/aAAgBAQABBQLt1OtgNgn/xAAVEQEBAAAAAAAAAAAAAAAAAAAAEf/aAAgBAwEBPwFX/8QAFBEBAAAAAAAAAAAAAAAAAAAAEP/aAAgBAgEBPwE//8QAGhABAAEFAAAAAAAAAAAAAAAAASEAECJBYf/aAAgBAQAGPwLLbFkl7X//xAAZEAEAAwEBAAAAAAAAAAAAAAABABEhQVH/2gAIAQEAAT8hpQDkjkxil+kuQEcxpP/aAAwDAQACAAMAAAAQhB//xAAXEQADAQAAAAAAAAAAAAAAAAAAARFB/9oACAEDAQE/EKO8R//EABcRAQADAAAAAAAAAAAAAAAAAAABESH/2gAIAQIBAT8QnVP/xAAbEAACAgMBAAAAAAAAAAAAAAABEQAhMWGhgf/aAAgBAQABPxAhXy4QUU152EgAWw29Opl0hWQDfRP/2Q==","aspectRatio":2.4518388791593697,"src":"/static/ci-cd-mobile-f7ae9e71e6aa0f4626be37bbda772b59-6b3a1.jpg","srcSet":"/static/ci-cd-mobile-f7ae9e71e6aa0f4626be37bbda772b59-182ff.jpg 213w,\n/static/ci-cd-mobile-f7ae9e71e6aa0f4626be37bbda772b59-7f5c7.jpg 425w,\n/static/ci-cd-mobile-f7ae9e71e6aa0f4626be37bbda772b59-6b3a1.jpg 850w,\n/static/ci-cd-mobile-f7ae9e71e6aa0f4626be37bbda772b59-45cc1.jpg 1275w,\n/static/ci-cd-mobile-f7ae9e71e6aa0f4626be37bbda772b59-055dc.jpg 1400w","sizes":"(max-width: 850px) 100vw, 850px"}}}}},"next":{"fields":{"slug":"/middlewear-go/"},"excerpt":"How to teach yourself a new language and the advantages of a middleware API (TurtleWare 2.0 pt1)\n","frontmatter":{"title":"Making a middleware API layer in GO","date":"September 21, 2019","featuredImage":{"childImageSharp":{"sizes":{"base64":"data:image/jpeg;base64,/9j/2wBDABALDA4MChAODQ4SERATGCgaGBYWGDEjJR0oOjM9PDkzODdASFxOQERXRTc4UG1RV19iZ2hnPk1xeXBkeFxlZ2P/2wBDARESEhgVGC8aGi9jQjhCY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2NjY2P/wgARCAAIABQDASIAAhEBAxEB/8QAFwABAAMAAAAAAAAAAAAAAAAAAAIDBP/EABYBAQEBAAAAAAAAAAAAAAAAAAEAAv/aAAwDAQACEAMQAAAB0VgyFn//xAAaEAACAgMAAAAAAAAAAAAAAAABAgAEEhMU/9oACAEBAAEFAnsHHaUPRP/EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQMBAT8BP//EABQRAQAAAAAAAAAAAAAAAAAAABD/2gAIAQIBAT8BP//EABsQAAEEAwAAAAAAAAAAAAAAAAEAAhARISJR/9oACAEBAAY/AjRyhs432P/EABsQAAICAwEAAAAAAAAAAAAAAAABESFBUWFx/9oACAEBAAE/IVqrBlqW2zPT0f/aAAwDAQACAAMAAAAQg/8A/8QAFhEAAwAAAAAAAAAAAAAAAAAAARAx/9oACAEDAQE/EBF//8QAFhEAAwAAAAAAAAAAAAAAAAAAARAx/9oACAECAQE/EDV//8QAGhAAAgMBAQAAAAAAAAAAAAAAAREAITFh0f/aAAgBAQABPxC80C0RJTUo6BYGFGKYeZDf3P/Z","aspectRatio":2.4518388791593697,"src":"/static/gopherbig-1a7217f26b87bff249249410e928e717-6b3a1.jpg","srcSet":"/static/gopherbig-1a7217f26b87bff249249410e928e717-182ff.jpg 213w,\n/static/gopherbig-1a7217f26b87bff249249410e928e717-7f5c7.jpg 425w,\n/static/gopherbig-1a7217f26b87bff249249410e928e717-6b3a1.jpg 850w,\n/static/gopherbig-1a7217f26b87bff249249410e928e717-45cc1.jpg 1275w,\n/static/gopherbig-1a7217f26b87bff249249410e928e717-055dc.jpg 1400w","sizes":"(max-width: 850px) 100vw, 850px"}}}}}}}