BUG Fixed initial Date on Backtest

This commit is contained in:
Luis Fernando Molina committed 2019-08-16 17:49:51 +02:00
1 parent 5f6900ef3f
commit 2ebae6f1fb
2 files changed
+79 -63

No files matched your search

+61 -57
View File
@@ -1391,42 +1391,44 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) {
tradePositionSize = strategy.positionSize;
tradePositionRate = strategy.positionRate;
/* We see if we need to put the actual order at the exchange. */
if (interExecutionMemory.executionContext !== undefined) {
switch (interExecutionMemory.executionContext.status) {
case "Without a Position": { // We need to put the order because It was not put yet.
if (strategy.openStage !== undefined) {
if (strategy.openStage.openExecution !== undefined) {
putOpeningOrder()
return
/* Check that we are in LIVE MODE */
if (process.env.START_MODE === "live") {
/* We see if we need to put the actual order at the exchange. */
if (interExecutionMemory.executionContext !== undefined) {
switch (interExecutionMemory.executionContext.status) {
case "Without a Position": { // We need to put the order because It was not put yet.
if (strategy.openStage !== undefined) {
if (strategy.openStage.openExecution !== undefined) {
putOpeningOrder()
return
}
}
break
}
break
}
case "Position Closed": { // Waiting for a confirmation that the position was closed.
if (strategy.openStage !== undefined) {
if (strategy.openStage.openExecution !== undefined) {
putOpeningOrder()
return
case "Position Closed": { // Waiting for a confirmation that the position was closed.
if (strategy.openStage !== undefined) {
if (strategy.openStage.openExecution !== undefined) {
putOpeningOrder()
return
}
}
break
}
case "Taking Position": { // Waiting for a confirmation that the position was taken.
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] runSimulation -> loop -> takePositionNow -> Exiting code block because status is Taking Position."); }
break
}
case "In a Position": { // This should mean that we already put the order at the exchange.
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] runSimulation -> loop -> takePositionNow -> Exiting code block because status is In a Position."); }
break
}
break
}
case "Taking Position": { // Waiting for a confirmation that the position was taken.
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] runSimulation -> loop -> takePositionNow -> Exiting code block because status is Taking Position."); }
break
}
case "In a Position": { // This should mean that we already put the order at the exchange.
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] runSimulation -> loop -> takePositionNow -> Exiting code block because status is In a Position."); }
break
}
}
} else { // The context does not exist so it means we are not in a position.
if (strategy.openStage !== undefined) {
if (strategy.openStage.openExecution !== undefined) {
putOpeningOrder()
return
} else { // The context does not exist so it means we are not in a position.
if (strategy.openStage !== undefined) {
if (strategy.openStage.openExecution !== undefined) {
putOpeningOrder()
return
}
}
}
}
@@ -1613,36 +1615,38 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) {
/* Position size and rate */
let strategy = tradingSystem.strategies[currentStrategyIndex];
/* We see if we need to put the actual order at the exchange. */
if (interExecutionMemory.executionContext !== undefined) {
switch (interExecutionMemory.executionContext.status) {
case "Without a Position": { // No way to close anything at the exchange.
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] runSimulation -> loop -> Closing a Position -> Exiting code block because status is Without a Position."); }
break
}
case "In a Position": { // This should mean that we already put the order at the exchange.
if (strategy.closeStage !== undefined) {
if (strategy.closeStage.closeExecution !== undefined) {
putClosingOrder()
return
}
/* Check that we are in LIVE MODE */
if (process.env.START_MODE === "live") {
/* We see if we need to put the actual order at the exchange. */
if (interExecutionMemory.executionContext !== undefined) {
switch (interExecutionMemory.executionContext.status) {
case "Without a Position": { // No way to close anything at the exchange.
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] runSimulation -> loop -> Closing a Position -> Exiting code block because status is Without a Position."); }
break
}
break
}
case "Closing Position": { // Waiting for a confirmation that the position was taken.
if (strategy.closeStage !== undefined) {
if (strategy.closeStage.closeExecution !== undefined) {
putClosingOrder()
return
case "In a Position": { // This should mean that we already put the order at the exchange.
if (strategy.closeStage !== undefined) {
if (strategy.closeStage.closeExecution !== undefined) {
putClosingOrder()
return
}
}
break
}
case "Closing Position": { // Waiting for a confirmation that the position was taken.
if (strategy.closeStage !== undefined) {
if (strategy.closeStage.closeExecution !== undefined) {
putClosingOrder()
return
}
}
break
}
break
}
case "Position Closed": { //
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] runSimulation -> loop -> Closing a Position -> Exiting code block because status is Position Closed."); }
break
case "Position Closed": { //
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] runSimulation -> loop -> Closing a Position -> Exiting code block because status is Position Closed."); }
break
}
}
}
}
+18 -6
View File
@@ -238,15 +238,27 @@
if (processConfig.framework.name === "Multi-Period-Daily" || processConfig.framework.name === "Multi-Period-Market") {
processConfig.framework.startDate.resumeExecution = false;
if (processConfig.startMode.noTime !== undefined) {
if (processConfig.startMode.noTime.beginDatetime !== undefined) {
processConfig.framework.startDate.fixedDate = processConfig.startMode.noTime.beginDatetime;
processConfig.framework.startDate.resumeExecution = false;
if (processConfig.startMode.noTime.run === "true") {
if (processConfig.startMode.noTime.beginDatetime !== undefined) {
processConfig.framework.startDate.fixedDate = processConfig.startMode.noTime.beginDatetime;
processConfig.framework.startDate.resumeExecution = false;
}
}
}
if (processConfig.startMode.live !== undefined) {
if (processConfig.startMode.live.beginDatetime !== undefined) {
processConfig.framework.startDate.fixedDate = processConfig.startMode.live.beginDatetime;
processConfig.framework.startDate.resumeExecution = false;
if (processConfig.startMode.live.run === "true") {
if (processConfig.startMode.live.beginDatetime !== undefined) {
processConfig.framework.startDate.fixedDate = processConfig.startMode.live.beginDatetime;
processConfig.framework.startDate.resumeExecution = false;
}
}
}
if (processConfig.startMode.backtest !== undefined) {
if (processConfig.startMode.backtest.run === "true") {
if (processConfig.startMode.backtest.beginDatetime !== undefined) {
processConfig.framework.startDate.fixedDate = processConfig.startMode.backtest.beginDatetime;
processConfig.framework.startDate.resumeExecution = false;
}
}
}
}