Base asset from reference parent

This commit is contained in:
Luis Fernando Molina committed 2020-01-06 13:47:10 +01:00
1 parent dad19f8278
commit c1c732e4bf
2 files changed
+132 -119

No files matched your search

+68 -58
View File
@@ -278,37 +278,42 @@
/* Base Asset and Initial Balances. */
{
if (tradingSystem.parameters.baseAsset !== undefined) {
let code = tradingSystem.parameters.baseAsset.code
if (tradingSystem.parameters.baseAsset.referenceParent !== undefined) {
if (tradingSystem.parameters.baseAsset.referenceParent.referenceParent !== undefined) {
if (code.name !== undefined) {
bot.VALUES_TO_USE.baseAsset = code.name;
}
let code = tradingSystem.parameters.baseAsset.referenceParent.referenceParent.code
if (bot.VALUES_TO_USE.baseAsset === 'BTC') {
if (code.initialBalance !== undefined) {
bot.VALUES_TO_USE.initialBalanceA = code.initialBalance;
bot.VALUES_TO_USE.initialBalanceB = 0
}
if (code.minimumBalance !== undefined) {
bot.VALUES_TO_USE.minimumBalanceA = code.minimumBalance;
bot.VALUES_TO_USE.minimumBalanceB = 0
}
if (code.maximumBalance !== undefined) {
bot.VALUES_TO_USE.maximumBalanceA = code.maximumBalance;
bot.VALUES_TO_USE.maximumBalanceB = 0
}
} else {
if (code.initialBalance !== undefined) {
bot.VALUES_TO_USE.initialBalanceB = code.initialBalance;
bot.VALUES_TO_USE.initialBalanceA = 0
}
if (code.minimumBalance !== undefined) {
bot.VALUES_TO_USE.minimumBalanceB = code.minimumBalance;
bot.VALUES_TO_USE.minimumBalanceA = 0
}
if (code.maximumBalance !== undefined) {
bot.VALUES_TO_USE.maximumBalanceB = code.maximumBalance;
bot.VALUES_TO_USE.maximumBalanceA = 0
if (code.codeName !== undefined) {
bot.VALUES_TO_USE.baseAsset = code.codeName;
}
if (bot.VALUES_TO_USE.baseAsset === 'BTC') {
if (code.initialBalance !== undefined) {
bot.VALUES_TO_USE.initialBalanceA = code.initialBalance;
bot.VALUES_TO_USE.initialBalanceB = 0
}
if (code.minimumBalance !== undefined) {
bot.VALUES_TO_USE.minimumBalanceA = code.minimumBalance;
bot.VALUES_TO_USE.minimumBalanceB = 0
}
if (code.maximumBalance !== undefined) {
bot.VALUES_TO_USE.maximumBalanceA = code.maximumBalance;
bot.VALUES_TO_USE.maximumBalanceB = 0
}
} else {
if (code.initialBalance !== undefined) {
bot.VALUES_TO_USE.initialBalanceB = code.initialBalance;
bot.VALUES_TO_USE.initialBalanceA = 0
}
if (code.minimumBalance !== undefined) {
bot.VALUES_TO_USE.minimumBalanceB = code.minimumBalance;
bot.VALUES_TO_USE.minimumBalanceA = 0
}
if (code.maximumBalance !== undefined) {
bot.VALUES_TO_USE.maximumBalanceB = code.maximumBalance;
bot.VALUES_TO_USE.maximumBalanceA = 0
}
}
}
}
}
@@ -374,37 +379,42 @@
/* Base Asset and Initial Balances. */
{
if (bot.SESSION.parameters.baseAsset !== undefined) {
let code = bot.SESSION.parameters.baseAsset.code
if (tradingSystem.parameters.baseAsset.referenceParent !== undefined) {
if (tradingSystem.parameters.baseAsset.referenceParent.referenceParent !== undefined) {
if (code.name !== undefined) {
bot.VALUES_TO_USE.baseAsset = code.name;
}
let code = tradingSystem.parameters.baseAsset.referenceParent.referenceParent.code
if (bot.VALUES_TO_USE.baseAsset === 'BTC') {
if (code.initialBalance !== undefined) {
bot.VALUES_TO_USE.initialBalanceA = code.initialBalance;
bot.VALUES_TO_USE.initialBalanceB = 0
}
if (code.minimumBalance !== undefined) {
bot.VALUES_TO_USE.minimumBalanceA = code.minimumBalance;
bot.VALUES_TO_USE.minimumBalanceB = 0
}
if (code.maximumBalance !== undefined) {
bot.VALUES_TO_USE.maximumBalanceA = code.maximumBalance;
bot.VALUES_TO_USE.maximumBalanceB = 0
}
} else {
if (code.initialBalance !== undefined) {
bot.VALUES_TO_USE.initialBalanceB = code.initialBalance;
bot.VALUES_TO_USE.initialBalanceA = 0
}
if (code.minimumBalance !== undefined) {
bot.VALUES_TO_USE.minimumBalanceB = code.minimumBalance;
bot.VALUES_TO_USE.minimumBalanceA = 0
}
if (code.maximumBalance !== undefined) {
bot.VALUES_TO_USE.maximumBalanceB = code.maximumBalance;
bot.VALUES_TO_USE.maximumBalanceA = 0
if (code.codeName !== undefined) {
bot.VALUES_TO_USE.baseAsset = code.codeName;
}
if (bot.VALUES_TO_USE.baseAsset === 'BTC') {
if (code.initialBalance !== undefined) {
bot.VALUES_TO_USE.initialBalanceA = code.initialBalance;
bot.VALUES_TO_USE.initialBalanceB = 0
}
if (code.minimumBalance !== undefined) {
bot.VALUES_TO_USE.minimumBalanceA = code.minimumBalance;
bot.VALUES_TO_USE.minimumBalanceB = 0
}
if (code.maximumBalance !== undefined) {
bot.VALUES_TO_USE.maximumBalanceA = code.maximumBalance;
bot.VALUES_TO_USE.maximumBalanceB = 0
}
} else {
if (code.initialBalance !== undefined) {
bot.VALUES_TO_USE.initialBalanceB = code.initialBalance;
bot.VALUES_TO_USE.initialBalanceA = 0
}
if (code.minimumBalance !== undefined) {
bot.VALUES_TO_USE.minimumBalanceB = code.minimumBalance;
bot.VALUES_TO_USE.minimumBalanceA = 0
}
if (code.maximumBalance !== undefined) {
bot.VALUES_TO_USE.maximumBalanceB = code.maximumBalance;
bot.VALUES_TO_USE.maximumBalanceA = 0
}
}
}
}
}
+64 -61
View File
@@ -44,7 +44,6 @@
callBackFunction) {
try {
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] runSimulation -> Entering function."); }
let processingDailyFiles
if (timeFrame > global.dailyFilePeriods[0][0]) {
@@ -1361,45 +1360,47 @@
}
}
let phase = parentNode.stopLoss.phases[p];
if (parentNode !== undefined) {
let phase = parentNode.stopLoss.phases[p];
let nextPhaseEvent = phase.nextPhaseEvent;
if (nextPhaseEvent !== undefined) {
let nextPhaseEvent = phase.nextPhaseEvent;
if (nextPhaseEvent !== undefined) {
for (let k = 0; k < nextPhaseEvent.situations.length; k++) {
for (let k = 0; k < nextPhaseEvent.situations.length; k++) {
let situation = nextPhaseEvent.situations[k];
let passed = true;
let situation = nextPhaseEvent.situations[k];
let passed = true;
for (let m = 0; m < situation.conditions.length; m++) {
for (let m = 0; m < situation.conditions.length; m++) {
let condition = situation.conditions[m];
let key = j + '-' + stageKey + initialDefinitionKey + '-' + 'stopLoss' + '-' + p + '-' + k + '-' + m;
let condition = situation.conditions[m];
let key = j + '-' + stageKey + initialDefinitionKey + '-' + 'stopLoss' + '-' + p + '-' + k + '-' + m;
let value = false
if (conditions.get(key) !== undefined) {
value = conditions.get(key).value;
}
if (value === false) { passed = false; }
}
if (passed) {
stopLossPhase++;
stopLossStage = 'Manage Stage'
if (takeProfitPhase > 0) { strategyStage = 'Manage Stage' }
if (processingDailyFiles) {
if (positionedAtYesterday) {
yesterday.stopLossPhase = stopLossPhase;
yesterday.stopLossStage = stopLossStage;
yesterday.strategyStage = strategyStage;
let value = false
if (conditions.get(key) !== undefined) {
value = conditions.get(key).value;
}
if (value === false) { passed = false; }
}
checkAnnouncements(nextPhaseEvent)
return;
if (passed) {
stopLossPhase++;
stopLossStage = 'Manage Stage'
if (takeProfitPhase > 0) { strategyStage = 'Manage Stage' }
if (processingDailyFiles) {
if (positionedAtYesterday) {
yesterday.stopLossPhase = stopLossPhase;
yesterday.stopLossStage = stopLossStage;
yesterday.strategyStage = strategyStage;
}
}
checkAnnouncements(nextPhaseEvent)
return;
}
}
}
}
@@ -1490,45 +1491,47 @@
}
}
let phase = parentNode.takeProfit.phases[p];
if (parentNode !== undefined) {
let phase = parentNode.takeProfit.phases[p];
let nextPhaseEvent = phase.nextPhaseEvent;
if (nextPhaseEvent !== undefined) {
let nextPhaseEvent = phase.nextPhaseEvent;
if (nextPhaseEvent !== undefined) {
for (let k = 0; k < nextPhaseEvent.situations.length; k++) {
for (let k = 0; k < nextPhaseEvent.situations.length; k++) {
let situation = nextPhaseEvent.situations[k];
let passed = true;
let situation = nextPhaseEvent.situations[k];
let passed = true;
for (let m = 0; m < situation.conditions.length; m++) {
for (let m = 0; m < situation.conditions.length; m++) {
let condition = situation.conditions[m];
let key = j + '-' + stageKey + initialDefinitionKey + '-' + 'takeProfit' + '-' + p + '-' + k + '-' + m;
let condition = situation.conditions[m];
let key = j + '-' + stageKey + initialDefinitionKey + '-' + 'takeProfit' + '-' + p + '-' + k + '-' + m;
let value = false
if (conditions.get(key) !== undefined) {
value = conditions.get(key).value;
}
if (value === false) { passed = false; }
}
if (passed) {
takeProfitPhase++;
takeProfitStage = 'Manage Stage'
if (stopLossPhase > 0) { strategyStage = 'Manage Stage' }
if (processingDailyFiles) {
if (positionedAtYesterday) {
yesterday.takeProfitPhase = takeProfitPhase;
yesterday.takeProfitStage = takeProfitStage;
yesterday.strategyStage = strategyStage;
let value = false
if (conditions.get(key) !== undefined) {
value = conditions.get(key).value;
}
if (value === false) { passed = false; }
}
checkAnnouncements(nextPhaseEvent)
return;
if (passed) {
takeProfitPhase++;
takeProfitStage = 'Manage Stage'
if (stopLossPhase > 0) { strategyStage = 'Manage Stage' }
if (processingDailyFiles) {
if (positionedAtYesterday) {
yesterday.takeProfitPhase = takeProfitPhase;
yesterday.takeProfitStage = takeProfitStage;
yesterday.strategyStage = strategyStage;
}
}
checkAnnouncements(nextPhaseEvent)
return;
}
}
}
}