Skip to content

Commit

Permalink
Merge pull request Superalgos#5138 from BastianMuc/develop
Browse files Browse the repository at this point in the history
Adding more information about inbound Trading Signals on console
  • Loading branch information
Raplh2502 authored Jun 14, 2024
2 parents cba287d + 2a46cdd commit 78505f7
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 1 deletion.
2 changes: 2 additions & 0 deletions Platform/PlatformApp.js
Original file line number Diff line number Diff line change
Expand Up @@ -171,10 +171,12 @@ exports.newPlatformApp = function newPlatformApp() {
SA.logger.info('Real-time Trading Signals ................................... Enables the broadcasting and consumption of trading signals.')
SA.logger.info('Portfolio Manager ........................................... Portfolio Manager bots supervise and manage Trading Bots for improved capital allocation and risk management.')
SA.logger.info('')
/*
SA.logger.info("What's next? This is the current development pipeline:")
SA.logger.info('')
SA.logger.info('Superalgos Mobile ........................................... Will allow users to consume trading signals from their mobile phones.')
SA.logger.info('')
*/
SA.logger.info('Join the @superalgosdevelop Telegram Group to learn more!')
SA.logger.info('')

Expand Down
9 changes: 9 additions & 0 deletions Projects/Foundations/TS/Function-Libraries/TaskFunctions.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ exports.newFoundationsFunctionLibrariesTaskFunctions = function () {
taskHearBeat: taskHearBeat,
taskError: taskError,
getBotModuleByName: getBotModuleByName,
getTaskType: getTaskType
}

return thisObject
Expand Down Expand Up @@ -61,4 +62,12 @@ exports.newFoundationsFunctionLibrariesTaskFunctions = function () {
}
}
}

function getTaskType() {
/* Returns the type of the currently running task */
let taskType
if (TS.projects.foundations.globals.taskConstants.TASK_NODE.bot?.type === 'Trading Bot Instance') { taskType = 'Trading' }
else if (TS.projects.foundations.globals.taskConstants.TASK_NODE.bot?.type === 'Sensor Bot Instance') { taskType = 'Data' }
return taskType
}
}
22 changes: 21 additions & 1 deletion Projects/Trading-Signals/TS/Modules/IncomingCandleSignals.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ exports.newTradingSignalsModulesIncomingCandleSignals = function () {
/*
Let's tell the world that we received a trading signal.
*/
TS.projects.foundations.functionLibraries.taskFunctions.taskHearBeat("Candle Signal received, delayed " + rankingStats.accumulatedDelay / 1000 + " seconds. Position in Queue: " + rankingStats.positionInQueue + " / " + rankingStats.queueSize, true)
let taskType = TS.projects.foundations.functionLibraries.taskFunctions.getTaskType()
TS.projects.foundations.functionLibraries.taskFunctions.taskHearBeat("Candle Signal received, delayed " + rankingStats.accumulatedDelay / 1000 + " seconds. Position in Queue: " + rankingStats.positionInQueue + " / " + rankingStats.queueSize + " (" + taskType + " Task)", true )
/*
What we have just received are not Trading Signals, but a Signal Meesage
that represents the File Key needed to locate and open a file with all the
Expand Down Expand Up @@ -76,9 +77,28 @@ exports.newTradingSignalsModulesIncomingCandleSignals = function () {
if (keys === undefined) { keys = [] }
keys.push(key)
keysByCandle.set(candleKey, keys)

/* If this is a Trading Task, provide information about received trading signals (not candle/trading system signals) on console */
if (taskType === 'Trading' && tradingSignalMessage.tradingSignal.signalDefinition?.type !== undefined && tradingSignalMessage.tradingSignal.signalDefinition?.type !== 'Trading System Signal') {
SA.logger.info("Trading Signal received | Type: " + tradingSignalMessage.tradingSignal.signalDefinition.type + " | Label: " + getSignalLabel(tradingSignalMessage.tradingSignal.signalDefinition.id))
}

}
}

function getSignalLabel(signalDefinitionId) {
let signalLabel = "no local mapping found"
for (let i = 0; i < TS.projects.foundations.globals.taskConstants.TASK_NODE.bot.processes.length; i++) {
let ten = TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(i).TRADING_SYSTEM_NODE
let ref = SA.projects.visualScripting.utilities.nodeFunctions.nodeMeshToPathArray(ten, signalDefinitionId)
if (ref.at(-2)?.name) {
signalLabel = ref.at(-2).name
break
}
}
return signalLabel
}

function mantain(candle) {
let candleKey =
candle.begin + '-' +
Expand Down

0 comments on commit 78505f7

Please sign in to comment.