BUG FIXED: Initial STOP and TAKE PROFIT not correctly set
This commit is contained in:
1 parent
0a88958b2e
commit
976a849f54
2 files changed
+76
-67
No files matched your search
+68
-63
@@ -84,7 +84,7 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) {
|
||||
|
||||
/* Stop Loss Management */
|
||||
|
||||
let stopLossPercentage = 1.5;
|
||||
let stopLossPercentage = 50;
|
||||
let previousStopLoss = 0;
|
||||
let stopLoss = 0;
|
||||
let stopLossDecay = 0;
|
||||
@@ -637,47 +637,48 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) {
|
||||
|
||||
checkStopLoss();
|
||||
|
||||
function checkStopLoss() {
|
||||
}
|
||||
|
||||
let strategy = simulationLogic.strategies[strategyNumber - 1];
|
||||
function checkStopLoss() {
|
||||
|
||||
let phase = strategy.stopLoss.phases[stopLossPhase - 1];
|
||||
let strategy = simulationLogic.strategies[strategyNumber - 1];
|
||||
|
||||
try {
|
||||
eval(phase.code); // Here is where we apply the formula given for the stop loss for this phase.
|
||||
} catch (err) {
|
||||
/*
|
||||
If the code produces an exception, we are covered.
|
||||
*/
|
||||
let phase = strategy.stopLoss.phases[stopLossPhase - 1];
|
||||
|
||||
try {
|
||||
eval(phase.code); // Here is where we apply the formula given for the stop loss for this phase.
|
||||
} catch (err) {
|
||||
/*
|
||||
If the code produces an exception, we are covered.
|
||||
*/
|
||||
}
|
||||
|
||||
if (newStopLoss < previousStopLoss) {
|
||||
stopLoss = newStopLoss;
|
||||
} else {
|
||||
stopLoss = previousStopLoss;
|
||||
}
|
||||
|
||||
for (let k = 0; k < phase.situations.length; k++) {
|
||||
|
||||
let situation = phase.situations[k];
|
||||
let passed = true;
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
|
||||
let condition = situation.conditions[m];
|
||||
let key = strategy.name + '-' + phase.name + '-' + situation.name + '-' + condition.name
|
||||
|
||||
let value = conditions.get(key).value;
|
||||
|
||||
if (value === false) { passed = false; }
|
||||
}
|
||||
|
||||
if (newStopLoss < previousStopLoss) {
|
||||
stopLoss = newStopLoss;
|
||||
} else {
|
||||
stopLoss = previousStopLoss;
|
||||
}
|
||||
if (passed) {
|
||||
|
||||
for (let k = 0; k < phase.situations.length; k++) {
|
||||
stopLossPhase++;
|
||||
|
||||
let situation = phase.situations[k];
|
||||
let passed = true;
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
|
||||
let condition = situation.conditions[m];
|
||||
let key = strategy.name + '-' + phase.name + '-' + situation.name + '-' + condition.name
|
||||
|
||||
let value = conditions.get(key).value;
|
||||
|
||||
if (value === false) { passed = false; }
|
||||
}
|
||||
|
||||
if (passed) {
|
||||
|
||||
stopLossPhase++;
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -688,41 +689,42 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) {
|
||||
|
||||
checkBuyOrder();
|
||||
|
||||
function checkBuyOrder() {
|
||||
}
|
||||
|
||||
let strategy = simulationLogic.strategies[strategyNumber - 1];
|
||||
function checkBuyOrder() {
|
||||
|
||||
let phase = strategy.buyOrder.phases[buyOrderPhase - 1];
|
||||
let strategy = simulationLogic.strategies[strategyNumber - 1];
|
||||
|
||||
try {
|
||||
eval(phase.code); // Here is where we apply the formula given for the buy order at this phase.
|
||||
} catch (err) {
|
||||
/*
|
||||
If the code produces an exception, we are covered.
|
||||
*/
|
||||
let phase = strategy.buyOrder.phases[buyOrderPhase - 1];
|
||||
|
||||
try {
|
||||
eval(phase.code); // Here is where we apply the formula given for the buy order at this phase.
|
||||
} catch (err) {
|
||||
/*
|
||||
If the code produces an exception, we are covered.
|
||||
*/
|
||||
}
|
||||
|
||||
for (let k = 0; k < phase.situations.length; k++) {
|
||||
|
||||
let situation = phase.situations[k];
|
||||
let passed = true;
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
|
||||
let condition = situation.conditions[m];
|
||||
let key = strategy.name + '-' + phase.name + '-' + situation.name + '-' + condition.name
|
||||
|
||||
let value = conditions.get(key).value;
|
||||
|
||||
if (value === false) { passed = false; }
|
||||
}
|
||||
|
||||
for (let k = 0; k < phase.situations.length; k++) {
|
||||
if (passed) {
|
||||
|
||||
let situation = phase.situations[k];
|
||||
let passed = true;
|
||||
buyOrderPhase++;
|
||||
|
||||
for (let m = 0; m < situation.conditions.length; m++) {
|
||||
|
||||
let condition = situation.conditions[m];
|
||||
let key = strategy.name + '-' + phase.name + '-' + situation.name + '-' + condition.name
|
||||
|
||||
let value = conditions.get(key).value;
|
||||
|
||||
if (value === false) { passed = false; }
|
||||
}
|
||||
|
||||
if (passed) {
|
||||
|
||||
buyOrderPhase++;
|
||||
|
||||
return;
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -739,6 +741,9 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) {
|
||||
|
||||
stopLossDecay = 0;
|
||||
|
||||
checkStopLoss();
|
||||
checkBuyOrder();
|
||||
|
||||
previousBalanceAssetA = balanceAssetA;
|
||||
lastProfit = 0;
|
||||
lastProfitPercent = 0;
|
||||
|
||||
@@ -302,7 +302,8 @@
|
||||
"devTeam": "AAMasters",
|
||||
"codeName": "PlottersTradingSimulation",
|
||||
"moduleName": "TradingSimulation"
|
||||
}
|
||||
},
|
||||
"relatedToTradingEngine": true
|
||||
},
|
||||
{
|
||||
"codeName": "Simulation-Conditions",
|
||||
@@ -341,7 +342,8 @@
|
||||
"devTeam": "AAMasters",
|
||||
"codeName": "PlottersTradingSimulation",
|
||||
"moduleName": "Conditions"
|
||||
}
|
||||
},
|
||||
"relatedToTradingEngine": true
|
||||
},
|
||||
{
|
||||
"codeName": "Simulation-Strategies",
|
||||
@@ -380,7 +382,8 @@
|
||||
"devTeam": "AAMasters",
|
||||
"codeName": "PlottersTradingSimulation",
|
||||
"moduleName": "Strategies"
|
||||
}
|
||||
},
|
||||
"relatedToTradingEngine": true
|
||||
},
|
||||
{
|
||||
"codeName": "Simulation-Trades",
|
||||
@@ -419,7 +422,8 @@
|
||||
"devTeam": "AAMasters",
|
||||
"codeName": "PlottersTradingSimulation",
|
||||
"moduleName": "Trades"
|
||||
}
|
||||
},
|
||||
"relatedToTradingEngine": true
|
||||
}
|
||||
]
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user