Why I Built A Historical Cryptocurrency Trade Simulator (which you can use too)

Why I Built A Historical Cryptocurrency Trade Simulator (which you can use too)

I got into trade crypto about May 2017 after about a year of regular investing in a image of peer2peer ( P2P ) systems, commodities and stocks. My scheme was childlike — every month I would invest 20 % of my total income ( or adenine much as I could afford ) before tax into a range of investments, then regularly reinvest the dividends generated from interest into more investments . The first separate of this strategy came from a book called the The Richest man in Babylon, and second gear from general mod economic remember. The combination of the two proved quite effective and allowed me to diversify my portfolio and reduce risk over time. With the growing excitation around cryptocurrencies I thought I would give it a fit while leveraging the same scheme. Every calendar month I would invest about 5 % of my total 20 % into a range of cryptocurriencies — chiefly bitcoin, etherium, litecoin, dash and a few altcoins. Overall this performed well ( specially with the massive rise in value in the second half of 2017 ). however, recenly I could not help but think my simpleton scheme was not arsenic effecient as it could be.

Being the begin of 2018 I thought I would put my theory to the trial and try some different trade strategies on diachronic cryptocurrency data. I couldn ’ thyroxine find anything that truly suited my needs online, or did n’t seem to require a subscription to buy indeed I build something myself with python. The result of the undertaking is rotter repo you can try for yourself ( python 3 ) – hypertext transfer protocol : //github.com/Raudaschl/historical_crypto_trade_simulator

Steps

Requires pandas and python 3 Install Pandas

 blip install giant panda

Step 1

Download historical data python download.py To download the prices for different cryptocurrencies for the last 300 days as a csv file curtesy of the cryptocompare.com API. You can edit the coin types in the download.py file .

Step 2

Run the script python trader.py This will produce the pursuit outputs : Original Value — The current value of your investments assuming no trade strategy has been applied apart from holding onto your investments Original Dividends — The sum dividends based from your initial investments Final Dividends — The total dividends based on original and new investments Original Investments Value — The total value of your original investments after the strategy is applied New Investments Value — The total prize of new investments made based on your strategy Final Total Value — The sum value of your investments and any dividends taken

Step 3 — Customise

Set Orders bitCoinOrders array is filled with cyptocoin different orders — exercise :

 bitCoinOrders.append ( { “ coin ” : “ btc ”, “ buyPrice ” : 2690, “ coins ” : 0.0782, “ date ” : “ 2017–05–27 ” } ) 

coin : set the currency symbol ( needs to be one of the currencies downloaded before ) buyPrice : original buy price ( $ ) coins : number of coins bought go steady : date purchased Calculate Function Function The forecast function takes an array of orders and examines their value from the point of purchase. During this iteration I have set up trade scheme which aims to sell 40 % of the coins from a single order when that club has increased in value by 300 %. That 40 % is then reinvested by buying other cryptocurrencies which is in the dfAdditionalOrders array. If the value of the 40 % deal is less than $ 40 then I will sell all the coins outright and claim that amount for myself as dividends. Variables profitFactor — Set the % measure where you will take profit. Setting 3 for model will automatically trigger a sell at 300 % reinvest Percentage — the share of the full value of the order when the profit factor is reached to reinvest. minimumSellValue — Sell all coins of this particular rate when the value hits the profitFactor and the value of the reinvestment is less than this value. BuyWeightsBuild Function Function This function sets the coins to buy from the profits of any sell ( see above ). They exclude the coin that was originally sold so for exemplar if bitcoin turned a profit and was sold it would not buy more bitcoin with the profits. Variables

 buyWeights.append ( { “ coin ” : “ btc ”, “ weight ” : 0.25 } )

coin — the symbol of the currency you want to buy ( must be one of the currencies downloaded ) weight — this is an index to how a lot you want to buy of one currency compared to another. The full measure of all weights should add up to 1.

Conclusions

then there you have it. In my experiments I found I could only in truth increase my overall measure by less than 1 % over the last year so possibly the simple model is silent the best one for me. possibly you will have better luck. 💰 💸 Git Repo — hypertext transfer protocol : //github.com/Raudaschl/historical_crypto_trade_simulator postscript : I ’ molarity not a programmer, so please go easily on me with the code 😃

Leave a Comment

Your email address will not be published.