Announcements Improved
This commit is contained in:
1 parent
ae6517bf56
commit
2a0a5a44ca
4 files changed
+89
-32
No files matched your search
+45
-4
@@ -3680,6 +3680,12 @@
|
||||
"relatedUiObject": "Trigger Stage",
|
||||
"actionFunction": "payload.onMenuItemClick"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Announcement",
|
||||
"relatedUiObject": "Announcement",
|
||||
"actionFunction": "payload.onMenuItemClick"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
"askConfirmation": true,
|
||||
@@ -3714,6 +3720,11 @@
|
||||
"type": "node",
|
||||
"childType": "Take Position Event",
|
||||
"autoAdd": true
|
||||
},
|
||||
{
|
||||
"name": "announcements",
|
||||
"type": "array",
|
||||
"childType": "Announcement"
|
||||
}
|
||||
],
|
||||
"propertyNameAtParent": "triggerStage"
|
||||
@@ -3879,6 +3890,12 @@
|
||||
"relatedUiObject": "Open Execution",
|
||||
"actionFunction": "payload.onMenuItemClick"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Announcement",
|
||||
"relatedUiObject": "Announcement",
|
||||
"actionFunction": "payload.onMenuItemClick"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
"askConfirmation": true,
|
||||
@@ -3907,6 +3924,11 @@
|
||||
"type": "node",
|
||||
"childType": "Open Execution",
|
||||
"autoAdd": true
|
||||
},
|
||||
{
|
||||
"name": "announcements",
|
||||
"type": "array",
|
||||
"childType": "Announcement"
|
||||
}
|
||||
],
|
||||
"propertyNameAtParent": "openStage"
|
||||
@@ -4325,6 +4347,12 @@
|
||||
"relatedUiObject": "Manage Stage",
|
||||
"actionFunction": "payload.onMenuItemClick"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Announcement",
|
||||
"relatedUiObject": "Announcement",
|
||||
"actionFunction": "payload.onMenuItemClick"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
"askConfirmation": true,
|
||||
@@ -4353,6 +4381,11 @@
|
||||
"type": "node",
|
||||
"childType": "Take Profit",
|
||||
"autoAdd": true
|
||||
},
|
||||
{
|
||||
"name": "announcements",
|
||||
"type": "array",
|
||||
"childType": "Announcement"
|
||||
}
|
||||
],
|
||||
"propertyNameAtParent": "manageStage"
|
||||
@@ -4369,6 +4402,12 @@
|
||||
"relatedUiObject": "Close Execution",
|
||||
"actionFunction": "payload.onMenuItemClick"
|
||||
},
|
||||
{
|
||||
"action": "Add UI Object",
|
||||
"label": "Add Announcement",
|
||||
"relatedUiObject": "Announcement",
|
||||
"actionFunction": "payload.onMenuItemClick"
|
||||
},
|
||||
{
|
||||
"action": "Delete UI Object",
|
||||
"askConfirmation": true,
|
||||
@@ -4391,6 +4430,11 @@
|
||||
"type": "node",
|
||||
"childType": "Close Execution",
|
||||
"autoAdd": true
|
||||
},
|
||||
{
|
||||
"name": "announcements",
|
||||
"type": "array",
|
||||
"childType": "Announcement"
|
||||
}
|
||||
],
|
||||
"propertyNameAtParent": "closeStage"
|
||||
@@ -4523,11 +4567,8 @@
|
||||
},
|
||||
"addLeftIcons": true,
|
||||
"level": 4,
|
||||
"referenceAttachesTo": {
|
||||
"compatibleTypes": "->Telegram Bot->"
|
||||
},
|
||||
"chainAttachesTo": {
|
||||
"compatibleTypes": "->Trigger On Event->Trigger Off Event->Take Position Event->Next Phase Event->Phase->"
|
||||
"compatibleTypes": "->Trigger On Event->Trigger Off Event->Take Position Event->Next Phase Event->Phase->Trigger Stage->Open Stage->Manage Stage->Close Stage->"
|
||||
},
|
||||
"properties": [
|
||||
{
|
||||
|
||||
@@ -37,7 +37,7 @@ function newSessionFunctions () {
|
||||
'Exchange Account Asset->Asset->' +
|
||||
'Strategy->' +
|
||||
'Trigger Stage->Trigger On Event->Trigger Off Event->Take Position Event->' +
|
||||
'Announcement->Telegram Bot->' +
|
||||
'Announcement->Formula->' +
|
||||
'Open Stage->Initial Definition->Open Execution->' +
|
||||
'Position Size->Position Rate->Formula->' +
|
||||
'Initial Stop->Initial Take Profit->' +
|
||||
@@ -45,8 +45,8 @@ function newSessionFunctions () {
|
||||
'Stop->Take Profit->' +
|
||||
'Phase->Formula->Next Phase Event->' +
|
||||
'Situation->Condition->Javascript Code->' +
|
||||
'Announcement->Telegram Bot->Formula->' +
|
||||
'Close Stage->Close Execution->'
|
||||
'Close Stage->Close Execution->' +
|
||||
'Announcement->Formula->'
|
||||
|
||||
let tradingSystem = functionLibraryProtocolNode.getProtocolNode(node.payload.referenceParent, false, true, true, false, false, lightingPath)
|
||||
|
||||
|
||||
@@ -513,17 +513,15 @@
|
||||
let socialBot = bot.SESSION.socialBots.bots[i]
|
||||
try {
|
||||
let code = announcement.code
|
||||
if (announcement.referenceParent !== undefined) {
|
||||
if (socialBot.id === announcement.referenceParent.id) {
|
||||
if (socialBot.type === "Telegram Bot") {
|
||||
if (announcement.formulaValue !== undefined) {
|
||||
socialBot.botInstance.telegramAPI.sendMessage(socialBot.botInstance.chatId, announcement.formulaValue).catch(err => parentLogger.write(MODULE_NAME, "[WARN] initialize -> setUpSocialBots -> announce -> Telegram API error -> err = " + err))
|
||||
} else {
|
||||
socialBot.botInstance.telegramAPI.sendMessage(socialBot.botInstance.chatId, code.text).catch(err => parentLogger.write(MODULE_NAME, "[WARN] initialize -> setUpSocialBots -> announce -> Telegram API error -> err = " + err))
|
||||
}
|
||||
}
|
||||
|
||||
if (socialBot.type === "Telegram Bot") {
|
||||
if (announcement.formulaValue !== undefined) {
|
||||
socialBot.botInstance.telegramAPI.sendMessage(socialBot.botInstance.chatId, announcement.formulaValue).catch(err => parentLogger.write(MODULE_NAME, "[WARN] initialize -> setUpSocialBots -> announce -> Telegram API error -> err = " + err))
|
||||
} else {
|
||||
socialBot.botInstance.telegramAPI.sendMessage(socialBot.botInstance.chatId, code.text).catch(err => parentLogger.write(MODULE_NAME, "[WARN] initialize -> setUpSocialBots -> announce -> Telegram API error -> err = " + err))
|
||||
}
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
parentLogger.write(MODULE_NAME, "[WARN] initialize -> setUpSocialBots -> announce -> err = " + err.stack);
|
||||
}
|
||||
|
||||
@@ -1167,6 +1167,8 @@
|
||||
if (passed) {
|
||||
|
||||
strategyStage = 'Trigger Stage';
|
||||
checkAnnouncements(triggerStage)
|
||||
|
||||
currentStrategyIndex = j;
|
||||
currentStrategy.begin = candle.begin;
|
||||
currentStrategy.beginRate = candle.min;
|
||||
@@ -1313,6 +1315,8 @@
|
||||
type = '"Take Position"';
|
||||
|
||||
strategyStage = 'Open Stage';
|
||||
checkAnnouncements(strategy.openStage)
|
||||
|
||||
stopLossStage = 'Open Stage';
|
||||
takeProfitStage = 'Open Stage';
|
||||
stopLossPhase = 0;
|
||||
@@ -1330,7 +1334,7 @@
|
||||
|
||||
takePositionNow = true
|
||||
currentTrade.takePositionSituation = situation.name
|
||||
|
||||
|
||||
checkAnnouncements(triggerStage.takePosition)
|
||||
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] runSimulation -> loop -> Conditions at the Take Position Event were met."); }
|
||||
@@ -1411,7 +1415,10 @@
|
||||
|
||||
stopLossPhase++;
|
||||
stopLossStage = 'Manage Stage'
|
||||
if (takeProfitPhase > 0) { strategyStage = 'Manage Stage' }
|
||||
if (takeProfitPhase > 0) {
|
||||
strategyStage = 'Manage Stage'
|
||||
checkAnnouncements(manageStage, 'Take Profit')
|
||||
}
|
||||
|
||||
if (processingDailyFiles) {
|
||||
if (positionedAtYesterday) {
|
||||
@@ -1543,7 +1550,10 @@
|
||||
|
||||
takeProfitPhase++;
|
||||
takeProfitStage = 'Manage Stage'
|
||||
if (stopLossPhase > 0) { strategyStage = 'Manage Stage' }
|
||||
if (stopLossPhase > 0) {
|
||||
strategyStage = 'Manage Stage'
|
||||
checkAnnouncements(manageStage, 'Stop')
|
||||
}
|
||||
|
||||
if (processingDailyFiles) {
|
||||
if (positionedAtYesterday) {
|
||||
@@ -1745,6 +1755,8 @@
|
||||
marketRate = closeRate;
|
||||
type = '"Close@StopLoss"';
|
||||
strategyStage = 'Close Stage';
|
||||
checkAnnouncements(strategy.closeStage, 'Stop')
|
||||
|
||||
stopLossStage = 'No Stage';
|
||||
takeProfitStage = 'No Stage';
|
||||
currentTrade.end = candle.end;
|
||||
@@ -1814,6 +1826,8 @@
|
||||
marketRate = closeRate;
|
||||
type = '"Close@TakeProfit"';
|
||||
strategyStage = 'Close Stage';
|
||||
checkAnnouncements(strategy.closeStage, 'Take Profit')
|
||||
|
||||
stopLossStage = 'No Stage';
|
||||
takeProfitStage = 'No Stage';
|
||||
|
||||
@@ -2669,7 +2683,7 @@
|
||||
|
||||
function checkAnnouncements(node, value) {
|
||||
/*
|
||||
Value is an optional parameter that represents the value that the announcement is monitoring for change.
|
||||
Value is an optional parameter that represents the value that the announcement is monitoring for change (for numeric values only).
|
||||
If we do receive this value, we will only make the annoucement if the variance is grater than the user pre-defined value
|
||||
for this variance.
|
||||
*/
|
||||
@@ -2693,18 +2707,20 @@
|
||||
|
||||
if (periods > lastPeriodAnnounced) {
|
||||
|
||||
/* The Value Variation is what tells us how much the value already announced must change in order to annouce it again. */
|
||||
let valueVariation
|
||||
|
||||
let code = announcement.code
|
||||
valueVariation = code.valueVariation
|
||||
|
||||
if (newAnnouncementRecord.value !== undefined && valueVariation !== undefined) {
|
||||
let upperLimit = newAnnouncementRecord.value + newAnnouncementRecord.value * valueVariation / 100
|
||||
let lowerLimit = newAnnouncementRecord.value - newAnnouncementRecord.value * valueVariation / 100
|
||||
if (value > lowerLimit && value < upperLimit) {
|
||||
/* There is not enough variation to announce this again. */
|
||||
return
|
||||
if (isNaN(value) === false) {
|
||||
/* The Value Variation is what tells us how much the value already announced must change in order to annouce it again. */
|
||||
let valueVariation
|
||||
|
||||
let code = announcement.code
|
||||
valueVariation = code.valueVariation
|
||||
|
||||
if (newAnnouncementRecord.value !== undefined && valueVariation !== undefined) {
|
||||
let upperLimit = newAnnouncementRecord.value + newAnnouncementRecord.value * valueVariation / 100
|
||||
let lowerLimit = newAnnouncementRecord.value - newAnnouncementRecord.value * valueVariation / 100
|
||||
if (value > lowerLimit && value < upperLimit) {
|
||||
/* There is not enough variation to announce this again. */
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2712,6 +2728,7 @@
|
||||
We store the announcement temporarily at an Array to differ its execution, becasue we need to evaulate its formula
|
||||
and at this point in time the potential variables used at the formula are still not set.
|
||||
*/
|
||||
announcement.value = value
|
||||
announcementsToBeMade.push(announcement)
|
||||
|
||||
/* Next, we will remmeber this announcement was already done, so that it is not announced again in further processing of the same day. */
|
||||
@@ -2739,6 +2756,7 @@
|
||||
let formulaValue
|
||||
if (announcement.formula !== undefined) {
|
||||
try {
|
||||
let value = announcement.value
|
||||
formulaValue = eval(announcement.formula.code);
|
||||
} catch (err) {
|
||||
announcement.formula.error = err.message
|
||||
|
||||
Reference in new issue
Block a user