Advertisement
Guest User

Untitled

a guest
Jun 13th, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 26.20 KB | None | 0 0
  1. ![awesome-robot-wallpaper.jpg](https://steemitimages.com/DQmT6Kf3DutQ3C9dZWLUfEKGdU3GqVFFj5b6PE7a2FxU6tH/awesome-robot-wallpaper.jpg)
  2. ##### Want to make your own BTC bot? I’ll walk you through the full setup, on to your first execution of an automated trade, and beyond.
  3.  
  4. ### Cryptocurrencies
  5. I should not need to tell you but, a couple months ago you could buy the cryptocurrency Etherium for $11, it rapidly went up to $43 (I bought in between those prices) and has now currently gone to over $335 as of June 2017. Those kinds of gains are nearly unbelievable to a traditional investor and yet these are across the board in this space.
  6. Excited yet? So here is a scenario:
  7.  
  8. So you made a ton of money on cryptocurrencies and have some concerns about shuffling it through your bank because of potential capital gains tax issues. There are places who have a solution for you if you want to be able to use this money for other investments. These places won’t make you photograph your license and send it in, just use an email and they provide you with a BTC deposit wallet, demo accounts, API’s, then when you are ready, you send money in and it’s ‘go time’, you can trade everything from treasury bonds to Forex using Cryptocurrencies as your base monetary instrument.
  9. But, you say, I am a coder who likes to automate things, surely we can fire up some BTCbot and we can have it just do the work for us, it will make us millions in our sleep, right?
  10.  
  11. — probably not.
  12.  
  13. ### My solution:
  14. I don’t want to write a bot and publish it with a single strategy and just say “here, use this”, I don’t think that is helpful to anyone, I would rather give you the tools and show you how to write strategies yourself, show you how to set up data collection for the strategies and how to implement them in a trading system and see the results.
  15.  
  16. > note: Also, I don’t want to create this in a new or arcane language, I want this written in PHP which the most number of people are familiar with and in a framework (Laravel) that is simple to use but powerful enough that you can create what you need. If you think PHP is just for web pages, read on, this should surprise you.
  17.  
  18. I like to build systems, I have been working on this post for a while and it represents a good deal of non-derivative custom work. If you have read some of my other tutorials you know that I like to write tutorials that “I wish that I had found instead of having to to write”, so you are in for a thorough read, with a lot of copy-paste style recipes.
  19. Let’s get started.
  20.  
  21. ### Steps we are going to take:
  22. * Get boilerplate/framework installed.
  23. * Walk through the core parts of the system, see what is where.
  24. * Install and configure software we need.
  25. * Account creation at the brokerages we will be using, setting up the API keys for the scripts.
  26. * Run tests and examples, lets get it ready.
  27. * Set up websocket streams to get data.
  28. * Finding strategies for our automated agents
  29. * Deep dive into Indicators and Candles available to us.
  30. *Coding up our first agent.
  31. * Testing the agent.
  32. * A few closing words about the risks you are taking.
  33.  
  34. ### Get boilerplate/framework installed (Bowhead)
  35. You can find the repository for the Bowhead boilerplate at it’s github repository home here.
  36. [joeldg/bowhead](https://github.com/joeldg/bowhead)
  37.  
  38.  
  39.  
  40. > note: You will need [composer](https://getcomposer.org/doc/00-intro.md) installed.
  41. > note2: If you are on a Mac, I would strongly suggest the following tools: [iTerm2](https://www.iterm2.com/) with the [screen](https://ss64.com/osx/screen.html) command, [Sequel Pro](https://www.sequelpro.com/) and of course [PHPStorm](https://www.jetbrains.com/phpstorm/)
  42.  
  43. ###Bring the project in locally with:
  44. ````
  45. git clone https://github.com/joeldg/bowhead.git
  46. cd bowhead
  47. composer update
  48. cp .env-example .env
  49.  
  50. # now to the other required software
  51. # If you are on a Mac (this is very roughly)
  52. brew install redis
  53. brew install mysql
  54. brew install php7.1
  55. curl -O http://pear.php.net/go-pear.phar
  56. sudo php -d detect_unicode=0 go-pear.phar
  57. sudo pecl install trader
  58. mkfifo quotes
  59.  
  60. # on ubuntu something like this needs to be done
  61. sudo add-apt-repository ppa:ondrej/php
  62. sudo apt-get update
  63. sudo apt-get install php7.1 php7.1-opcache php7.1-sqlite3 php7.1-readline php7.1-mysql php7.1-mcrypt php7.1-mbstring php7.1-json php7.1-intl php7.1-gd php7.1-curl php7.1-bz2 php7.1-bcmath php7.1-cli php7.1-zip
  64. sudo apt-get install redis-server
  65. sudo apt-get install mysql-server
  66. sudo apt-get install screen autoconf automake libtool m4 pkg-config
  67. sudo apt-get install php-pear unzip ImageMagick-devel python-pip supervisor
  68. curl -O http://pear.php.net/go-pear.phar
  69. sudo php -d detect_unicode=0 go-pear.phar
  70. sudo pecl install trader
  71. mkfifo quotes
  72. ````
  73. ### Let’s go over the core parts of the system
  74. Fire up PHPStorm or your favorite editor and load up the project. This system is using the Laravel PHP framework, don’t worry you don’t need to be familiar with Laravel here, you can learn that on your own time if you want. The primary parts we are concerned with are located in:
  75. #### app/Console/Commands/
  76. which is where all our console commands are located
  77. ````
  78. BitfinexWebsocketCommand.php - Stream market data from Bitfinex
  79. CoinbaseWebsocketCommand.php - Stream market data from GDAX
  80. ExampleForexStrategyCommand.php - Forex example strategy
  81. ExampleStrategyCommand.php - Our example of a strategy
  82. ExampleUsageCommand.php - Basic usage examples
  83. GetHistoricalCommand.php - Pull in historic data from broker
  84. OandaStreamCommand.php - Stream market data from Oanda
  85. ````
  86. #### app/Util/
  87. which is all the utility classes that are available
  88. ````
  89. Bitfinex.php - Bitfinex API wrapper
  90. BrokersUtil.php - Utilities for various brokers
  91. [Candles.php](https://github.com/joeldg/bowhead/blob/master/app/Util/Candles.php) - All 60 TALib candle methods wrapped
  92. Coinbase.php - GDAX API wrapper
  93. Console.php - Console color, tables and progress
  94. [Indicators.php](https://github.com/joeldg/bowhead/blob/master/app/Util/Indicators.php) - 21 TALib indicators and moving averages.
  95. Oanda.php - Oanda API wrapper
  96. OneBroker.php - 1Broker API wrapper
  97. Other.php - possible indicators, not implemented yet
  98. testStrategy.php - Here is your test strategy
  99. Whaleclub.php - Whaleclub API wrapper
  100. ````
  101. #### app/Scripts
  102. which has a couple extras and some testing data, these scripts are SKLearn price forecasting scripts taken from a study on beer consumption I thought was really useful, these might be used for market price predictions.
  103. ````
  104. close_prediction.py - SKLearn script to predict a closing price
  105. ohlc-btc.csv - Sample CSV data, if needed
  106. open_prediction.py - SKLearn script to predict an opening price
  107. a python script in the root dir called ‘streaming.py’ which is part of the Oanda streaming command.
  108. the .env-example file which will need your API keys and be moved to .env
  109. ````
  110.  
  111. Now, in a terminal in this directory type
  112. `php artisan`
  113. You should see something like the following, the part you are interested in is below.![Screen Shot 2017-06-11 at 1.08.02 AM.png](https://steemitimages.com/DQmRoAZVBrXUajSfAcC7xwuAy1PSJbmKSYhyYLFXKK1wDKV/Screen%20Shot%202017-06-11%20at%201.08.02%20AM.png)
  114.  
  115.  
  116. ### Redis and MySql
  117. If you followed the directions above you should have [Redis](https://redis.io/) installed as well as [MySql](https://www.mysql.com/) and a few other things.
  118. Redis really does not need any tweaking out of the box, just don’t open up ports for it to the outside if you have it on a cloud instance, you don’t want people messing with your systems.
  119. MySQL will need a database and a few tables, create your database, I call mine ‘bowhead’ but you if you want to change this or need to have prefixed database names then you can change the options in the .env file, here are the defaults in the .env file.
  120.  
  121. ```
  122. DB_CONNECTION=mysql
  123. DB_HOST=localhost
  124. DB_PORT=3306
  125. DB_DATABASE=bowhead
  126. DB_USERNAME=root
  127. DB_PASSWORD=password
  128. ```
  129.  
  130. Once you are satisfied and can connect to your database, then from the terminal you will want to load up our testing data with. Change this command as per your modifications to the .env params above.
  131.  
  132. `mysql -u root -p bowhead < app\Script\DBdump.sql`
  133.  
  134. Open up the database in Sequel Pro and you will the sample data in the bowhead_ohlc (open, high, low, close) table.
  135.  
  136. ### API accounts we need in order to set up automated trading.
  137. > Note: Where possible I have set up bonuses for you on these links, all sites below offer free accounts which do not require ‘verification’ and do not require a deposit.
  138.  
  139. 1) [Whaleclub](https://whaleclub.co/join/tn6uE) the main site we want to trade on for this tutorial. They key their market data off of the Bitfinex websocket and match with Oanda streaming data for Forex. This site allows you to trade many instruments and commodities with BTC at up to 20x leverage, Forex up to 222x as well as providing BTC-based binary options. They have a simple easy to understand interface and excellent API. The API key is found by clicking on your name in the upper-right, and clicking on API. (use DEMO API key to start)
  140.  
  141. 2) [1Broker](https://1broker.com/?r=21434) the secondary site we want to trade on, they are similar to other BTC-based market makers and have a ‘trader follow’ system as well that is fairly interesting, particularly to get people following ‘you’. API key is found on the right, just under the email icon, there is a small box with what looks like sliders on it, then click on Access & API Management.
  142.  
  143. 3) [Oanda](https://www.oanda.com/) is where we get our streaming Forex data, you need an account. API access is found [here](https://www.oanda.com/demo-account/tpa/personal_token).
  144.  
  145. 4) [Coinbase/GDAX](https://www.coinbase.com/join/51950ca286c21b84dd000021) what used to be called ‘Coinbase Exchange’ is now called GDAX, I have been automated trading there since they first opened. API key is found at far upper-right then click on API and create your keys.
  146.  
  147. 5) [Bitfinex](https://www.bitfinex.com/) you need an account here with an API key so we can get Cryptocurrency quotes. API keys are found under ‘Account’ then click on API.
  148.  
  149. 6) [Poloniex](https://poloniex.com/) is like Bitfinex but supports many alt-coins. API keys are found here.
  150.  
  151. 7) [TradingView](http://tradingview.go2cloud.org/SHpx) not mandatory, but you will want an account there because all the indicators bowhead uses can be viewed on charts to help you build your strategies.
  152.  
  153. The reasoning behind this combination is that the Whaleclub and 1Broker API’s are rate limited, WC only allows 60 requests per minute, if we want to make sure we have streaming real-time data to work with we need to stream from a BTC brokerage. Same with Forex.
  154.  
  155. Definitely look around on these sites and see what they have to offer, I’ve been around the block with a lot of brokers and market maker sites and for BTC, these are all good as of June 2017. For Forex, Oanda is great, but for the purposes here of trading using BTC we just need their streaming Forex data.
  156.  
  157. Once you get the API keys for these sites, you will want to put them in your .env file in the root bowhead directory. This file is added to the .gitignore so if you like to keep your code in github, then you will be fine.
  158.  
  159. > NOTE: Start off by using DEMO/TEST API keys, DO NOT use real money API keys with untested trading scripts.
  160.  
  161. ### Let’s test that we are set up right.
  162.  
  163. bowhead has a testing script to verify that everything is set up correctly and that you have the right API keys, PHP version and the Trader extension is correctly installed.
  164.  
  165. `php artisan bowhead:example_usage`
  166.  
  167. This script will stop on any issues that you may have and provide commands to run to fix the issue or links to get API keys you will need.
  168.  
  169. ### Let’s get data flowing in
  170. We have two things we need to do for data here so we can create an automated trading system that can trade both Crypto and Forex pairs. We will be using this data to trade on BTC market maker sites in real time.
  171.  
  172. * Get streaming Forex data coming into our database from Oanda.
  173. * Get streaming Cryptocurrency data coming into our database from Bitfinex
  174.  
  175. > Note: You should have the screen command installed on either your mac or the cloud instance you are using. Screen is a terminal tool for detaching windows and keeping them running in the background. You can detach a screen, log off and come back and reattach to it from another location at another time.
  176.  
  177. ```
  178. ~$ screen python streaming.py
  179. *press {control+a+d} to detach*
  180. ~$ screen php artisan bowhead:oanda_stream
  181. *press {control+a+d} to detach*
  182. ```
  183. ![Screen Shot 2017-06-11 at 3.46.42 PM.png](https://steemitimages.com/DQmaKQ68yxCnrWKh1op18hmUJHVT1zhWp2VDM9kybuE6Wo6/Screen%20Shot%202017-06-11%20at%203.46.42%20PM.png)
  184. This is what the Forex streamer looks like if you turn the echo back on.
  185.  
  186. Now if the Forex markets are open (U.S.A Eastern time, Sunday 5:00pm to Friday 4pm) you will start to see data flowing into the bowhead_ohlc table for the currency pairs that are traded on Whaleclub. The list is in streaming.py and can be modified there. The following pairs are all streaming into your database in real time now. USD_JPY, EUR_USD, AUD_USD, EUR_GBP, USD_CAD, USD_CHF, USD_MXN, USD_TRY, USD_CNH, NZD_USD
  187.  
  188. Now we have regular Forex data, lets add in the BTC/USD currency pair.
  189.  
  190. ```
  191. ~$ screen php artisan bowhead:websocket_bitfinex
  192. *press {control+a+d} to detach*
  193. ```
  194.  
  195. Crypto markets are open 24/7 and you should begin to see current data flowing in immediately.
  196. To see these running processes and reattach to them use `screen -list` and `screen -r`
  197. ```
  198. ~$ screen -list
  199. There are screens on:
  200. 4604.ttys005.Joels-MacBook-Pro-2 (Detached)
  201. 4636.ttys005.Joels-MacBook-Pro-2 (Detached)
  202. 4652.ttys005.Joels-MacBook-Pro-2 (Detached)
  203. 3 Sockets in /var/folders/bq/79z2kd916hbd39n5bckb5_s00000gn/T/.screen.
  204. ```
  205.  
  206. The numbers on the left are the screen ID’s so in this instance you can reattach to the latest (Bitfinex) screen by using the following command.
  207. ```
  208. ~$ screen -r 4604
  209. ```
  210.  
  211. Your number will be different, screen assigns numbers based on PID.
  212.  
  213. We are only using screen for the purposes of this tutorial on a local machine, for a server environment we put these on supervisord to make sure they are always running on our server and if they die, then they are restarted.
  214. This is the supervisord conf I use for this, you may need to change the directory for your user.
  215.  
  216. ````
  217. #~$ more /etc/supervisor/conf.d/crypt.conf
  218. [program:oanda]
  219. command=/usr/bin/python streaming.py
  220. user=ubuntu
  221. directory=/home/ubuntu/bowhead
  222. startretries=3
  223. stopwaitsecs=10
  224. autostart=true
  225. [program:o_stream]
  226. command=/usr/bin/php artisan bowhead:oanda_stream
  227. user=ubuntu
  228. directory=/home/ubuntu/bowhead
  229. startretries=3
  230. stopwaitsecs=10
  231. autostart=true
  232. [program:wsbitfinex]
  233. command=/usr/bin/php artisan bowhead:websocket_bitfinex
  234. directory=/home/ubuntu/bowhead
  235. startretries=3
  236. stopwaitsecs=10
  237. autostart=true
  238. ````
  239.  
  240. You can see what these look like in Supervisor with
  241.  
  242. ```
  243. ~$ sudo supervisorctl
  244. o_stream RUNNING pid 31644, uptime 1 day, 22:15:24
  245. oanda RUNNING pid 31645, uptime 1 day, 22:15:24
  246. wsbitfinex RUNNING pid 31646, uptime 1 day, 22:15:24
  247. supervisor> help
  248. default commands (type help <topic>):
  249. =====================================
  250. add exit open reload restart start tail
  251. avail fg pid remove shutdown status update
  252. clear maintail quit reread signal stop version
  253. supervisor>
  254. ```
  255.  
  256. > note: Currently bowhead only supports BTC/USD from Bitfinex, I will be adding ETH and LTC in future revisions. You can create an ETH version of this if you want by copying and modifying the BitfinexWebsockCommand.php file to use ETHUSD and renaming the class. You will need to add any new commands class to the $commands array in app/Console/Kernel.php
  257.  
  258. ### Finding strategies
  259. So, we have our boilerplate/framework set up. We have accounts and we have data flowing into our database. we also have our indicator/signals and candles working. Lets jump in and see how to create a very simple strategy.
  260.  
  261. Now that we see how we can use this, we need strategies and we need to know how to find more strategies. and Quantopian is a great resource for strategies.
  262.  
  263. for instance, two that I was recently looking at Stocks On The Move and Trading on multiple TA-Lib signals are both interesting, however saying we use TALib methods in bowhead, lets go with the later, additionally this will only be for BTC as Oanda does not return Volume with forex pairs.
  264.  
  265. You will notice that this strategy uses three signals to determining if a stock (or in our case a pair) is overbought (sell) or underbought (buy).
  266.  
  267. * Money flow index (mfi)
  268. * Commodity channel index (cci)
  269. * Chande momentum oscillator (cmo)
  270.  
  271. This is a simple technicals strategy where if all three of these indicators agree then we go the direction they say to go. Here is the core part of the strategy in code.
  272. ````
  273. $indicators = new \Bowhead\Util\Indicators();
  274. $recentData = $util->getRecentData('BTC/USD');
  275. $cci = $indicators->cci($instrument, $recentData);
  276. $cmo = $indicators->cmo($instrument, $recentData);
  277. $mfi = $indicators->mfi($instrument, $recentData);
  278.  
  279. /** instrument is overbought, we will short */
  280. if ($cci == -1 && $cmo == -1 && $mfi == -1) {
  281. $overbought = 1;
  282. }
  283. /** It is underbought, we will go LONG */
  284. if ($cci == 1 && $cmo == 1 && $mfi == 1) {
  285. $underbought = 1;
  286. }
  287. ````
  288.  
  289. Don’t worry about putting this anywhere, this strategy is included in bowhead as a console command
  290. php artisan bowhead:example_strategy
  291.  
  292. > NOTE: __DO NOT__ RUN THIS ON YOUR LIVE ACCOUNT UNTIL YOU HAVE TESTED IT, USE YOUR DEMO API KEY TO START.
  293.  
  294. The output will look like this![Screen Shot 2017-06-11 at 1.02.00 PM.png](https://steemitimages.com/DQmaiRkzDwbqj43LHrteYtZUU1L2JJCpzyeRRrszDuv2p11/Screen%20Shot%202017-06-11%20at%201.02.00%20PM.png)
  295.  
  296.  
  297. If you would like to see what these look like on a chart, then head over to TradingView and add the indicators, TradingView idea stream is another great place to find strategies and see what other people are doing and you can view the strategies in the source code section of of TradingView.
  298.  
  299. ### Bowhead Indicators and Candles
  300. I provide two classes in bowhead for checking signals on data, Candles and Indicators. Each class has a ‘all’ method which will run all the methods in it’s parent class over the data you provide.
  301.  
  302. To keep things as __simple as possible without sacrifice of functionality__ all methods in both of these libraries provide a return as -1, 0 or 1. Where ‘1’ will always be the buy or ‘bullish’ side and ‘-1’ will always be the sell or ‘bearish’ side, where applicable. There are a couple which return -100 and 100 as returns, please read the comments above each method and in each class for more info about abnormal return values as there are links to explain what they do and why we use them as well as what they represent and how you can use them in your scripts.
  303.  
  304. [Candles.php](https://github.com/joeldg/bowhead/blob/master/app/Util/Candles.php) — The Candles class allCandles() method will check for the presence of 60 specific candles across your dataset. It returns a complex array which will even provide the data point location of the candle and data points around the candle. For purposes of automated scripting, the [‘current’] array in the return is the candles that are currently active.
  305.  
  306. [Indicators.php](https://github.com/joeldg/bowhead/blob/master/app/Util/Indicators.php) —Provides multiple indicators over a dataset, these are all the common technical indicators such as Bollinger bands, RSI and many types of moving averages. These include overlap studies, momentum indicators, volume indicators and volatility indicators. There are no cycle indicators yet. The core methodss are ‘adx’, ’aroonosc’, ’cmo’, ’sar’, ’cci’, ’mfi’, ’obv’, ’stoch’, ’rsi’, ’macd’, ’bollingerBands’, ’atr’ with MA methods of ‘sma’, ’ema’, ’wma’, ’dema’, ’tema’, ’trima’, ’kama’, ’mama’ and ’t3' which can be combined using macdext() fairly dynamically.
  307.  
  308. > SMA methods are typically called by themselves as they cannot respond with a buy or sell signal
  309.  
  310. These two sets of indicators and candles can be combined in many different ways that have been noted in the comments at the top of each class. Combining MA cross overs with Bearish/Bullish candle patterns (which would not be apparent to a moving average) you can pinpoint your entries and exits much better.
  311.  
  312. Packaging these trader methods in this way provides a lot of flexibility to you to be able to use them very easily and as you notice above, translating a strategy is very simple when you have only buy(1)/hold(0)/sell(-1) signals.
  313.  
  314. ### Code it up
  315.  
  316. So, lets do another quick script that will showcase what we do, this time lets do a Forex bot that trades all the pairs on WC, and it will use the following technical strategy.
  317.  
  318. * Average directional movement index (ADX) is a trend indicator that typically returns a number from 0–100, under 20 it indicates a weak trend, over 50 it indicates a strong trend. Bowhead returns a -1 for under 20 and a 1 for over 50;
  319.  
  320. * Two simple moving averages, on period 6 and period 40. Period 6 SMA will follow the price very closely and just smooth out any spikes. An SMA 40 is a much more smoothed average which will cross the period 6 at various points when movements start taking place. The ADX is a check that we are indeed in a trend and not in a ranging (sideways)market.
  321.  
  322. * When ADX registers a trend (over 50), and our SMA(40) down-crosses the SMA(6) we can buy as the trend is now moving up.
  323.  
  324. * When ADX registers a trend and our SMA (40) up-crosses the SMA(6) we can sell as the trend is now moving down.
  325.  
  326. Here is what this looks like on TradingView, orange in the bottom is the ADX, the green line is the SMA(6) and the blue line is the SMA(40). You can see where you would most likely ‘want’ to do your trades and ‘low and behold’, we have some line crossings at or near those exact places.![Screen Shot 2017-06-11 at 2.17.14 PM.png](https://steemitimages.com/DQmdXs4Lg65R1Hx2DVYEhBXcroKBJqvLHmPnTB5iXPSbP2p/Screen%20Shot%202017-06-11%20at%202.17.14%20PM.png)
  327.  
  328. Seems kind of complicated? Not when you are working in bowhead. The main thing is we need to get the data off the stack for checking previous and current values, that way you can tell when a moving average has crossed another moving average.
  329.  
  330. ````
  331. $recentData = $util->getRecentData($instrument);
  332.  
  333. $adx = $indicators->adx($instrument, $recentData);
  334. $_sma6 = trader_sma($recentData['close'], 6);
  335. $sma6 = array_pop($_sma6);
  336. $prior_sma6 = array_pop($_sma6);
  337. $_sma40 = trader_sma($recentData['close'], 40);
  338. $sma40 = array_pop($_sma40);
  339. $prior_sma40 = array_pop($_sma40);
  340. /** have the lines crossed? */
  341. $down_cross = (($prior_sma6 <= $sma40 && $sma6 > $sma40) ? 1 : 0);
  342. $up_cross = (($prior_sma40 <= $sma6 && $sma40 > $sma6) ? 1 : 0);
  343. Now you can just
  344. if ($adx == 1 && $down_cross) {
  345. $buy = 1;
  346. }
  347. if ($adx == 1 && $up_cross) {
  348. $sell = 1;
  349. }
  350. ````
  351.  
  352. ### Testing it
  353. Okay, so I provided this as the following file, ADX will spit errors (-9) without at least 21 data points, so keep that in mind.
  354. ```
  355. app/Console/Commands/ExampleForexStrategyCommand.php
  356. ~$ php artisan bowhead:example_forex_strategy
  357. ```
  358. This is what it looks like.![Screen Shot 2017-06-11 at 1.02.00 PM.png](https://steemitimages.com/DQmaiRkzDwbqj43LHrteYtZUU1L2JJCpzyeRRrszDuv2p11/Screen%20Shot%202017-06-11%20at%201.02.00%20PM.png)
  359.  
  360.  
  361. ### Closing words and a note about risk
  362. So now you can find strategies and quickly build your own scripts to trade cryptocurrencies via technical indicators and candle patterns. The sky is the limit.
  363.  
  364. Because this is within the Laravel framework, you can create web pages to manage your automated trading, easily create strategies using web-based tools. You can use the queues and jobs system to have strategy ‘workers’ (I will be adding this as I update it), broadcasts and so on. Laravel is a great framework.
  365.  
  366. Now to talk about risk.
  367.  
  368. #### I would like to point out that there is SUBSTANTIAL risk involved in cryptocurrency trading and you need to make sure you are in demo mode when testing and working out your strategies. This is of paramount importance as I would hate to hear of someone who lost any amount of money because of this.
  369.  
  370. Myself I am fairly risk tolerant and sometimes it pays off. I use Bowhead to do WC ‘Turbo’ trading (which is Forex Binary options), these are a ‘guess’ if the price will be up or be down in 1 minute and 5 minute contracts. If you guess right then win up to 75% return, if you guess wrong then you lose your entire bet. There are some Forex strategies specifically for Turbo trading that I have had some good luck with. However be aware that most require you are in a trending market. So an indicator like ADX on a longer period is not a bad choice.
  371.  
  372. Here is an example of one strategy that was working.
  373. ![Screen Shot 2017-06-07 at 6.41.23 PM.png](https://steemitimages.com/DQmdKjxYgD3qGRuCYoKbGTMGqGCAGhz6jt76WAwH8ecU6cg/Screen%20Shot%202017-06-07%20at%206.41.23%20PM.png)een%20Shot%202017-06-08%20at%209.15.56%20PM.png)
  374.  
  375. ### Final note
  376. Part 2 will go over making your bot talk to all the exchanges and even attempt to discern price discrepancies, building real-time GDAX straddle-bot using about five Forex strategies and even setting up Bowhead as an API.
  377.  
  378. If you notice any errors here or have any issues with the code, please let me know, make a comment here or open an issue in the github repository and I will address it.
  379.  
  380. — Keep in mind that this project is under active development.
  381.  
  382. Thanks and enjoy.
  383.  
  384. Joel De Gan
  385.  
  386. ### Get social:
  387. If you enjoyed this article, recommend by clicking on that heart icon on the left of this text, and feel free to share it, I work hard on these and feel they are useful
  388.  
  389. You can also upvote this article on Reddit in r/Bitcoin at this link. https://redd.it/6gpiy6
  390.  
  391. And of course HN https://news.ycombinator.com/item?id=14538377
  392.  
  393. This article originally was posted to Medium under the title "[Let's write a cryptocurrency bot (part 1)](https://medium.com/@joeldg/an-advanced-tutorial-a-new-crypto-currency-trading-bot-boilerplate-framework-e777733607ae)"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement