-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathreadme.html
More file actions
1 lines (1 loc) · 13.8 KB
/
Copy pathreadme.html
File metadata and controls
1 lines (1 loc) · 13.8 KB
1
<html><head><meta content="text/html; charset=UTF-8" http-equiv="content-type"><style type="text/css">ol{margin:0;padding:0}table td,table th{padding:0}.c4{color:#000000;font-weight:400;text-decoration:none;vertical-align:baseline;font-size:15pt;font-family:"Arial";font-style:normal}.c1{padding-top:0pt;padding-bottom:0pt;line-height:1.15;orphans:2;widows:2;text-align:left;height:11pt}.c3{color:#000000;font-weight:700;text-decoration:none;vertical-align:baseline;font-size:11pt;font-family:"Arial";font-style:normal}.c0{color:#000000;font-weight:400;text-decoration:none;vertical-align:baseline;font-size:11pt;font-family:"Arial";font-style:normal}.c10{color:#000000;text-decoration:none;vertical-align:baseline;font-size:12pt;font-family:"Arial";font-style:normal}.c8{color:#000000;text-decoration:none;vertical-align:baseline;font-size:15pt;font-family:"Arial";font-style:normal}.c7{color:#000000;text-decoration:none;vertical-align:baseline;font-size:13pt;font-family:"Arial";font-style:normal}.c2{padding-top:0pt;padding-bottom:0pt;line-height:1.15;orphans:2;widows:2;text-align:left}.c6{background-color:#ffffff;max-width:451.4pt;padding:72pt 72pt 72pt 72pt}.c5{font-weight:700}.c9{font-size:15pt}.title{padding-top:0pt;color:#000000;font-size:26pt;padding-bottom:3pt;font-family:"Arial";line-height:1.15;page-break-after:avoid;orphans:2;widows:2;text-align:left}.subtitle{padding-top:0pt;color:#666666;font-size:15pt;padding-bottom:16pt;font-family:"Arial";line-height:1.15;page-break-after:avoid;orphans:2;widows:2;text-align:left}li{color:#000000;font-size:11pt;font-family:"Arial"}p{margin:0;color:#000000;font-size:11pt;font-family:"Arial"}h1{padding-top:20pt;color:#000000;font-size:20pt;padding-bottom:6pt;font-family:"Arial";line-height:1.15;page-break-after:avoid;orphans:2;widows:2;text-align:left}h2{padding-top:18pt;color:#000000;font-size:16pt;padding-bottom:6pt;font-family:"Arial";line-height:1.15;page-break-after:avoid;orphans:2;widows:2;text-align:left}h3{padding-top:16pt;color:#434343;font-size:14pt;padding-bottom:4pt;font-family:"Arial";line-height:1.15;page-break-after:avoid;orphans:2;widows:2;text-align:left}h4{padding-top:14pt;color:#666666;font-size:12pt;padding-bottom:4pt;font-family:"Arial";line-height:1.15;page-break-after:avoid;orphans:2;widows:2;text-align:left}h5{padding-top:12pt;color:#666666;font-size:11pt;padding-bottom:4pt;font-family:"Arial";line-height:1.15;page-break-after:avoid;orphans:2;widows:2;text-align:left}h6{padding-top:12pt;color:#666666;font-size:11pt;padding-bottom:4pt;font-family:"Arial";line-height:1.15;page-break-after:avoid;font-style:italic;orphans:2;widows:2;text-align:left}</style></head><body class="c6"><p class="c2"><span class="c0">This is a very early and experimental version of a DCA backtesting script.</span></p><p class="c2"><span class="c5">You should use this software for testing purposes only! (LOL)</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c0">The idea behind it is that anyone with basic Python knowledge should be able to make their own backtests with the goal to find the best settings for each market conditions.</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c0">Many thanks first of all to TradeAlt and the fantastic community on his discord.</span></p><p class="c2"><span class="c0">TA Community Discord: https://discord.com/invite/tradealts </span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c0">Many thanks also to Sellium, Ribsy and all the other "config creators".</span></p><p class="c2"><span class="c0">Sellium has shared a list of the most popular configs here:</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c0">https://docs.google.com/spreadsheets/d/1cQ68_Sl70SRFRMeGu0zgBhTCuQvSf6ENi_obLhr7kpw</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c0">You should download the latest version as csv file to the configs folder and name it bot_configs.csv</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c5 c9">bot_config.py</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c0">This script reads the bot_config.csv and provides the data in a form we can work with.</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c3">getAllConfigs()</span></p><p class="c2"><span class="c0">provides an array of all configs.. each element has the class bot_config as defined in bot_config.py.</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c3">getSingleConfig('ta_standard')</span></p><p class="c2"><span class="c0">provides one config. you can loop over getAllConfigs() and print 'config_name' to get the valid names.</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c3">getMax(config)</span></p><p class="c2"><span class="c0">calculates max_safety_order_price_deviation and max_amount_for_bot_usage for a given config.</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c3">config.to_json()</span></p><p class="c2"><span class="c0">provides the config in a readable json format - if you can read json ;-)</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span>for you </span><span class="c5">own settings</span><span> you could either add them to the bot_config.csv or use the class </span><span class="c3">my_own_config</span></p><p class="c2"><span class="c0">the my_own_config is added to the array provided by getAllConfigs()</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c5 c8">fetch_data.py</span></p><p class="c2"><span class="c0">This script fetches the price_data (1minute candles - ohlc) from binance and stores it into textfiles into the folder data. e.g. data/SOLUSDT.txt</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c0">I normally use mongodb / mongoengine to store data but in this case storing the data in txt-files was a lot faster then using mongodb.</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c5">initialStartDate</span><span class="c0"> = date(2022,4,1).strftime("%s")+'000'</span></p><p class="c2"><span class="c0">this is the oldest date from which we want pricedata from. changing the initialStartDate after fetching data doesnt work, you definitely have to redownload everything by setting latest_data = 0 (see also below)</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c3">pairs =['SOLUSDT','LUNAUSDT','AVAXUSDT','ADAUSDT','ATOMUSDT']</span></p><p class="c2"><span class="c0">the pairs we like to have data for.</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c5 c10">PLEASE USE THIS WITH CAUTION. IF YOU TRY TO PULL DATA FOR 100 COINS SINCE 2017 THEN YOU COULD HIT THE BINANCE API LIMIT</span></p><p class="c1"><span class="c5 c7"></span></p><p class="c2"><span class="c0">I have not tested with other pairs then USDT. I think it should work fine will all USD pairs so also BUSD should work.I think that BTC / ETH pairs will not work. (have not tested this!)</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c3">updatePriceData('SOLUSDT')</span></p><p class="c2"><span class="c0">fetch the latest data for a given pair.</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c3">updateAllData()</span></p><p class="c2"><span class="c0">fetches the latest data for all symbols defined in pairs.</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c5">checkCache('SOLUSDT')</span></p><p class="c2"><span class="c0">check if data is already available to make sure we only download new data.</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span>If you want to </span><span class="c5">redownload the data</span><span> then you could either </span><span class="c5">delete the txt-files</span><span> in the data folder or set the variable l</span><span class="c5">atest_data = 0</span><span> in the </span><span class="c5">downloadPriceData</span><span class="c0"> function...</span></p><p class="c1"><span class="c0"></span></p><p class="c1"><span class="c0"></span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c8 c5">backtest.py</span></p><p class="c2"><span class="c3">THIS IS THE TRICKY PART. A SMALL ERROR IN OUR startBacktest FUNCTION AND THE RESULTS ARE USELESS.</span></p><p class="c1"><span class="c3"></span></p><p class="c2"><span>The results I was getting from my own backtesting are looking reasonable. I have compared the deals I am running live with the backtesting data and the safety_orders filled / bot_volume looks almost the same. sometimes with one safety_order more or less. the profit / loss looks ok.. sometimes it is very exact and then it is a few % difference. </span><span class="c5">Nevertheless, I must currently assume that the code contains errors and the results are therefore inaccurate.</span><span class="c0"> especially because the results are different from the ones posted by snurg (thanks for all your efforts and the analysis you have shared!)</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c3">PLEASE KEEP IN MIND THAT THIS IS A EARLY VERSION OF THE SCRIPT!!!</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c3">BASICALLY, YOU SHOULD TEST EACH CONFIGURATION FOR SEVERAL WEEKS IN 3COMMAS PAPER TRADING MODE. THE IDEA OF THIS SCRIPT IS TO FIND THE CONFIGURATIONS THAT ARE WORTH LOOKING AT MORE CLOSELY.</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c3">startBacktest(config,pair,startDate='',endDate='')</span></p><p class="c2"><span class="c0">config must be a single config (bot_config class) we are getting from getSingleConfig('SOLUSDT') </span></p><p class="c2"><span class="c0">pair is a single pair e.g. 'SOLUSDT'</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c3">startDate = date(2022,4,1).strftime("%Y-%m-%d %H:%M:%S")</span></p><p class="c2"><span>This</span><span class="c0"> date can be different from the initialStartDate we used to fetch our data.</span></p><p class="c2"><span class="c0">so we can download all data from the last 6 months but we start our backtest 3 months ago.. or 3 days.. </span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c3">endDate = date(2022,4,30).strftime("%Y-%m-%d %H:%M:%S")</span></p><p class="c2"><span class="c0">the date at which the backtest should end. by default the test runs as long as data is available.</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c3">You will find examples for the testing of single config / multi configs and multiple pairs in the test scripts within this folder.</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span>The function </span><span class="c5">startBacktest</span><span class="c0"> returns an json_array with the results.</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c0">config_name = the name of the config like 'ta_standard'</span></p><p class="c2"><span class="c0">pair = the pair we tested like 'SOLUSDT'</span></p><p class="c2"><span class="c0">bot_total_volume = the total volume currently assumed by the bot (deal volume)</span></p><p class="c2"><span class="c0">bot_current_profit = the profit or loss of the current deal.. (should be deal_current_profit.. will fix this later..)</span></p><p class="c2"><span class="c0">bot_current_profit_percent = profit of current deal in percent (..)</span></p><p class="c2"><span class="c0">avaiable_capital = the capital that is not invested at the moment.</span></p><p class="c2"><span class="c0">total_capital = this is the bot_volume + avaiable_capital</span></p><p class="c2"><span class="c0">total_deals = the number of deals closed</span></p><p class="c2"><span class="c0">highest_so = the highest safety order that got filled</span></p><p class="c2"><span class="c0">avg_so = the average amount of safety orders that got filled</span></p><p class="c2"><span class="c0">backtest_start = the start date you submitted in the function startBacktest</span></p><p class="c2"><span class="c0">backtest_end = the end date you submitted in the function startBacktest</span></p><p class="c2"><span class="c0">max_amount_for_bot_usage = the max amount the bot can use from our config</span></p><p class="c2"><span class="c0">max_safety_order_price_deviation = the deviation of the bot like 60%</span></p><p class="c2"><span class="c0">profit = the total profit / loss of the bot</span></p><p class="c2"><span class="c0">profit_percent = the total profit / loss in percent</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c8 c5">ROADMAP</span></p><p class="c2"><span>don't</span><span class="c0"> expect an update on the scripts every day.. But I am happy if someone is sharing some improvements or a bugfix in case you find anything.</span></p><p class="c1"><span class="c0"></span></p><p class="c2"><span class="c0">cheers and happy backtesting..</span></p><p class="c2"><span class="c0">dd</span></p><p class="c1"><span class="c0"></span></p></body></html>