From 70e736df2475d61a8a266c41196f9c922892f0ee Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Wed, 25 Apr 2018 20:10:18 +0200 Subject: [PATCH] Backtesst Running --- .vs/AAMariam-Trading-Bot/v15/.suo | Bin 36864 -> 35328 bytes Trading-Process/User.Bot.js | 68 +++++++----------------------- this.bot.config.json | 8 +++- 3 files changed, 23 insertions(+), 53 deletions(-) diff --git a/.vs/AAMariam-Trading-Bot/v15/.suo b/.vs/AAMariam-Trading-Bot/v15/.suo index 7ce79d905cb95fb1620894c34a3e470f58890cdd..dcd3e3031e27e510cbafa3c45e7a1ebe740e5484 100644 GIT binary patch delta 3325 zcmds3ZERCj7{2H3wzS*b=*As%pNvAc!phcebL^v|w_8!>U>`CZ=){c;5wmP$Z71QY z*AXMeiR``_6Gfw#7=Mrm)FAvoibFJn=!`#13=#E*F~*>nVJt-E`__ABGXohj^25_S zeZS7V=bZOE?>Sd_gI8YU4|-VgvAR+|P5yD+u@5eN!3sEzlZ#*{-w0zCH&fu6F>EYG zCvSkANjr@_sJ17;^(0$36;%;oLKqQNL>9t~nAF;Q)N?gEFTtOWx)*U1`^`)6FGSsf zNYP?8Ew&t`UDFFu7IEBi&VkBOM5z|g2VJb$E|hLWHDa_aSMZ>OaY2$AP|-V+OpkZ? zMdka_#$RIZQXb0CHIqEd$rcvHpDyUkMwy17H`1B~O<#txMAPdvNqs1*nFv}l+0-Z> z)aEAmoT!hsNqrPsf_e_30wE#dowdJmv?)*bASw|n5LJj81a+xJS*PhMQOcU`L%9Iq z*X+Nt@e{i_+ExtCvTMKH4_TZm|EzoXmmj=eJOLpB0dkIIVOP^I@RGh zG`@mZUXzIq0IEMd#2gUHpJYW4TDWh{2nHxN>Gi`{Y8@zY(Ab2IZFr!_7fe(%RQ&q0 zW@6?LPo6(A&(Cn@=upsKz+?zze`;p9+R4NngXb0uXX z8sxwRpYQ8{sJk)=Pbx_7aI^P-*}d@g!fYt$=+aQAN{;^*Gt|Nc1EZry&j|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ndUl!qkmjD0& diff --git a/Trading-Process/User.Bot.js b/Trading-Process/User.Bot.js index 874620b1c..2ecad633f 100644 --- a/Trading-Process/User.Bot.js +++ b/Trading-Process/User.Bot.js @@ -138,7 +138,7 @@ the +50% of current exchange rate. Next Bot execution will move it strategically. */ - let rate = currentRate * 1.50; + let rate = currentRate; /* The rules of the this first competition states that the bot will have the following initial balance in USDT and BTC to trade with. @@ -154,6 +154,8 @@ Here is this bot example, we are going to sell all AmountB at once. You can do this or whatever you think is better. */ + let balance = assistant.getBalance(); + AmountA = AmountB * rate; assistant.putPosition("sell", rate, AmountA, AmountB, callBack); @@ -187,66 +189,28 @@ if (LOG_INFO === true) { logger.write("[INFO] start -> decideAboutSellPosition -> Entering function."); } - /* - - Here is where you decide what to do with your current sell position. Option are: - - 1. Do not touch it. - 2. Move it to another position by changing the rate. - a. Up - b. Down - 3. Cancell it. (not yet implemented at the platform.) - - You can use here the information provided, analize it however you want and finally make a decition. - - */ + let balance = assistant.getBalance(); - let candleArray; - let candle; - let weight; + let rate = assistant.getMarketRate(); - /* - - Keeping in mind this is an example of traing bot, we are going to put some logic here that in the end will move the current position - up or down. It will move it down if the bot feels it is time to sell, and up if it feels that selling is not a good idea. - - To achieve a final rate to move the current position at the exchange, we are going to go through the available candles and patterns - and each one is going to make a micro-move, and at the end we will have a final rate to send a move command to the exchange. - - We will use a weight to give more or less importance to different Time Periods. - - ------ - NOTE: The code below is an example and you should replace it by your own logic. This is the key of your intervention here. - ------ - */ + let amountA; + let amountB; - let diff; - let variationPercentage; - let timePeriodName; + if (balance.assetA > 0) { - let targetRate = pPosition.rate; + amountA = balance.assetA; + amountB = amountA / rate; - let weightArray = [1 / (24 * 60), 1 / (12 * 60), 1 / (8 * 60), 1 / (6 * 60), 1 / (4 * 60), 1 / (3 * 60), 1 / (2 * 60), 1 / (1 * 60)]; + assistant.putPosition("buy", rate, amountA, amountB, callBack); - for (i = 0; i < global.marketFilesPeriods.length; i++) { + } else { - weight = weightArray[i]; + amountB = balance.assetB; + amountA = amountB * rate; - timePeriodName = global.marketFilesPeriods[i][1]; + assistant.putPosition("sell", rate, amountA, amountB, callBack); - candleArray = platform.datasource.candlesMap.get(timePeriodName); - candle = candleArray[candleArray.length - 1]; // The last candle of the 10 candles array. - - diff = candle.close - candle.open; - variationPercentage = diff * 100 / candle.open; // This is the % of how much the rate increased or decreced from open to close. - - targetRate = targetRate + targetRate * variationPercentage / 100 * weight; - - } - - /* Finally we move the order position to where we have just estimated is a better place. */ - - assistant.movePosition(pPosition, targetRate, callBack); + } } catch (err) { logger.write("[ERROR] start -> decideAboutSellPosition -> err = " + err.message); diff --git a/this.bot.config.json b/this.bot.config.json index 35559de9a..0ebff4f82 100644 --- a/this.bot.config.json +++ b/this.bot.config.json @@ -26,11 +26,17 @@ "month": "" }, "noTime": { - "run": "true" + "run": "false" }, "fixedInterval": { "run": "false", "interval": 0 + }, + "timePeriod": { + "run": "true", + "beginDatetime": "2018-01-06T16:01:23.485Z", + "endDatetime": "2018-01-06T16:15:23.485Z", + "waitTime": 1000 } }, "normalWaitTime": 60000,