New Modules for Outgoing Signals and Portfolio Manager Client
This commit is contained in:
1 parent
c741f8b2c4
commit
b577dcc3d5
9 files changed
+144
-140
No files matched your search
+13
-2
@@ -25,6 +25,8 @@ exports.newAlgorithmicTradingBotModulesTradingStages = function (processIndex) {
|
||||
let tradingPositionModuleObject = TS.projects.algorithmicTrading.botModules.tradingPosition.newAlgorithmicTradingBotModulesTradingPosition(processIndex)
|
||||
let tradingExecutionModuleObject = TS.projects.algorithmicTrading.botModules.tradingExecution.newAlgorithmicTradingBotModulesTradingExecution(processIndex)
|
||||
let announcementsModuleObject = TS.projects.socialBots.botModules.announcements.newSocialBotsBotModulesAnnouncements(processIndex)
|
||||
let outgoingTradingSignalsModuleObject = TS.projects.tradingSignals.modules.outgoingTradingSignals.newTradingSignalsModulesOutgoingTradingSignals(processIndex)
|
||||
let portfolioManagerClient = TS.projects.portfolioManagement.modules.portfolioManagerClient.newPortfolioManagementModulesPortfolioManagerClient(processIndex)
|
||||
let snapshotsModuleObject = TS.projects.algorithmicTrading.botModules.snapshots.newAlgorithmicTradingBotModulesSnapshots(processIndex)
|
||||
let tradingEpisodeModuleObject = TS.projects.algorithmicTrading.botModules.tradingEpisode.newAlgorithmicTradingBotModulesTradingEpisode(processIndex)
|
||||
|
||||
@@ -137,7 +139,11 @@ exports.newAlgorithmicTradingBotModulesTradingStages = function (processIndex) {
|
||||
passed = tradingSystem.checkConditions(situation, passed)
|
||||
|
||||
tradingSystem.values.push([situation.id, passed])
|
||||
|
||||
portfolioManagerClient.askPortfolioEventManager(triggerStage.triggerOn, { status: passed })
|
||||
|
||||
if (passed) {
|
||||
|
||||
tradingSystem.highlights.push(situation.id)
|
||||
tradingSystem.highlights.push(triggerStage.triggerOn.id)
|
||||
tradingSystem.highlights.push(triggerStage.id)
|
||||
@@ -147,6 +153,7 @@ exports.newAlgorithmicTradingBotModulesTradingStages = function (processIndex) {
|
||||
/* Initialize this */
|
||||
tradingEngine.tradingCurrent.tradingEpisode.distanceToTradingEvent.triggerOn.value = 1
|
||||
|
||||
outgoingTradingSignalsModuleObject.broadcastSignal(triggerStage.triggerOn)
|
||||
announcementsModuleObject.makeAnnouncements(triggerStage.triggerOn)
|
||||
|
||||
if (TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.type === 'Backtesting Session') {
|
||||
@@ -156,9 +163,7 @@ exports.newAlgorithmicTradingBotModulesTradingStages = function (processIndex) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
changeStageStatus('Trigger Stage', 'Open')
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -194,6 +199,8 @@ exports.newAlgorithmicTradingBotModulesTradingStages = function (processIndex) {
|
||||
tradingSystem.highlights.push(triggerStage.id)
|
||||
|
||||
tradingEngine.tradingCurrent.tradingEpisode.distanceToTradingEvent.triggerOff.value = 1
|
||||
|
||||
outgoingTradingSignalsModuleObject.broadcastSignal(triggerStage.triggerOff)
|
||||
announcementsModuleObject.makeAnnouncements(triggerStage.triggerOff)
|
||||
changeStageStatus('Trigger Stage', 'Closed', 'Trigger Off Event')
|
||||
tradingStrategyModuleObject.closeStrategy('Trigger Off')
|
||||
@@ -233,6 +240,7 @@ exports.newAlgorithmicTradingBotModulesTradingStages = function (processIndex) {
|
||||
|
||||
tradingPositionModuleObject.openPosition(situation.name)
|
||||
|
||||
outgoingTradingSignalsModuleObject.broadcastSignal(triggerStage.takePosition)
|
||||
announcementsModuleObject.makeAnnouncements(triggerStage.takePosition)
|
||||
|
||||
if (TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.type === 'Backtesting Session') {
|
||||
@@ -696,6 +704,7 @@ exports.newAlgorithmicTradingBotModulesTradingStages = function (processIndex) {
|
||||
|
||||
tradingPositionModuleObject.updateTakeProfit(tradingEngine.tradingCurrent.position.takeProfit.takeProfitPhase.value + 1)
|
||||
|
||||
outgoingTradingSignalsModuleObject.broadcastSignal(nextPhaseEvent)
|
||||
announcementsModuleObject.makeAnnouncements(nextPhaseEvent)
|
||||
|
||||
/* Reset this counter */
|
||||
@@ -747,6 +756,7 @@ exports.newAlgorithmicTradingBotModulesTradingStages = function (processIndex) {
|
||||
continue
|
||||
}
|
||||
|
||||
outgoingTradingSignalsModuleObject.broadcastSignal(moveToPhaseEvent)
|
||||
announcementsModuleObject.makeAnnouncements(moveToPhaseEvent)
|
||||
|
||||
/* Reset this counter */
|
||||
@@ -1108,6 +1118,7 @@ exports.newAlgorithmicTradingBotModulesTradingStages = function (processIndex) {
|
||||
tradingSystem.highlights.push(closeStageEvent.id)
|
||||
tradingSystem.highlights.push(stage.id)
|
||||
|
||||
outgoingTradingSignalsModuleObject.broadcastSignal(closeStageEvent)
|
||||
announcementsModuleObject.makeAnnouncements(closeStageEvent)
|
||||
return true
|
||||
}
|
||||
|
||||
@@ -961,8 +961,10 @@
|
||||
},
|
||||
"referenceParentCombinedNodePath": [
|
||||
[
|
||||
"Superalgos",
|
||||
"Positions"
|
||||
"Teams of Contributors",
|
||||
"Positions",
|
||||
"Governance",
|
||||
"862caa2e-7c05-4051-b5eb-3494174e2cd9"
|
||||
]
|
||||
]
|
||||
}
|
||||
@@ -1006,7 +1008,7 @@
|
||||
"floatingObject": {
|
||||
"isPinned": false,
|
||||
"isFrozen": false,
|
||||
"isCollapsed": false,
|
||||
"isCollapsed": true,
|
||||
"angleToParent": 1,
|
||||
"distanceToParent": 3,
|
||||
"arrangementStyle": 0
|
||||
|
||||
@@ -2343,7 +2343,7 @@
|
||||
"floatingObject": {
|
||||
"isPinned": false,
|
||||
"isFrozen": false,
|
||||
"isCollapsed": false,
|
||||
"isCollapsed": true,
|
||||
"angleToParent": 1,
|
||||
"distanceToParent": 3,
|
||||
"arrangementStyle": 0
|
||||
|
||||
@@ -0,0 +1,30 @@
|
||||
exports.newPortfolioManagementModulesPortfolioManagerClient = function (processIndex) {
|
||||
/*
|
||||
This object represents a proxy of the Profile Manager. It is used to send
|
||||
questions to the Event and Formula Managers and receive their answers.
|
||||
*/
|
||||
let thisObject = {
|
||||
askPortfolioEventManager: askPortfolioEventManager,
|
||||
askPortfolioFormulaManager: askPortfolioFormulaManager,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize() {
|
||||
|
||||
}
|
||||
|
||||
function finalize() {
|
||||
|
||||
}
|
||||
|
||||
async function askPortfolioEventManager(eventNode, conectInfo) {
|
||||
console.log('here')
|
||||
}
|
||||
|
||||
async function askPortfolioFormulaManager() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,28 @@
|
||||
exports.newPortfolioManagementModulesPortfolioManagerEventsClient = function (processIndex) {
|
||||
/*
|
||||
This object represents the client to access the Portfolio Manager from a Trading Bot.
|
||||
It is an events client because the communication with the Portfolio Manager happens
|
||||
at the events layer, provided by the Events Server.
|
||||
*/
|
||||
let thisObject = {
|
||||
sendMessage: sendMessage,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize() {
|
||||
|
||||
}
|
||||
|
||||
function finalize() {
|
||||
|
||||
}
|
||||
|
||||
async function sendMessage(message) {
|
||||
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
exports.newPortfolioManagementModulesPortfolioManagerEventsInterface = function (processIndex) {
|
||||
/*
|
||||
This object represents the interface between the Portfolio Manager and Trading Bots.
|
||||
It is an events based interface because the communicatin happens via the Events Server.
|
||||
*/
|
||||
let thisObject = {
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize() {
|
||||
|
||||
}
|
||||
|
||||
function finalize() {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -171,6 +171,26 @@
|
||||
]
|
||||
},
|
||||
"TS": {
|
||||
"modules": [
|
||||
{
|
||||
"name": "Portfolio Manager Client",
|
||||
"propertyName": "portfolioManagerClient",
|
||||
"functionName": "newPortfolioManagementModulesPortfolioManagerClient",
|
||||
"fileName": "PortfolioManagerClient.js"
|
||||
},
|
||||
{
|
||||
"name": "Portfolio Manager Events Client",
|
||||
"propertyName": "portfolioManagerEventsClient",
|
||||
"functionName": "newPortfolioManagementModulesPortfolioManagerEventsClient",
|
||||
"fileName": "PortfolioManagerEventsClient.js"
|
||||
},
|
||||
{
|
||||
"name": "Portfolio Manager Events Interface",
|
||||
"propertyName": "portfolioManagerEventsInterface",
|
||||
"functionName": "newPortfolioManagementModulesPortfolioManagerEventsInterface",
|
||||
"fileName": "PortfolioManagerEventsInterface.js"
|
||||
}
|
||||
],
|
||||
"botModules": [
|
||||
{
|
||||
"name": "PM Communication Module - Portfolio",
|
||||
@@ -1921,12 +1941,12 @@
|
||||
"utilities": []
|
||||
},
|
||||
"TS": {
|
||||
"botModules": [
|
||||
"modules": [
|
||||
{
|
||||
"name": "Trading Signals",
|
||||
"propertyName": "tradingSignals",
|
||||
"functionName": "newTradingSignalsBotModulesTradingSignals",
|
||||
"fileName": "TradingSignals.js",
|
||||
"name": "Outgoing Trading Signals",
|
||||
"propertyName": "outgoingTradingSignals",
|
||||
"functionName": "newTradingSignalsModulesOutgoingTradingSignals",
|
||||
"fileName": "OutgoingTradingSignals.js",
|
||||
"folderName": ""
|
||||
}
|
||||
]
|
||||
|
||||
@@ -1,129 +0,0 @@
|
||||
exports.newTradingSignalsBotModulesTradingSignals = function (processIndex) {
|
||||
|
||||
let thisObject = {
|
||||
makeAnnouncements: makeAnnouncements,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
let tradingSystem
|
||||
let tradingEngine
|
||||
let sessionParameters
|
||||
let taskParameters
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize() {
|
||||
tradingSystem = TS.projects.foundations.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SIMULATION_STATE.tradingSystem
|
||||
tradingEngine = TS.projects.foundations.globals.processVariables.VARIABLES_BY_PROCESS_INDEX_MAP.get(processIndex).SIMULATION_STATE.tradingEngine
|
||||
sessionParameters = TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.tradingParameters
|
||||
|
||||
|
||||
taskParameters = {
|
||||
exchange: TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.name,
|
||||
market: TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName +
|
||||
'/' +
|
||||
TS.projects.foundations.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName
|
||||
}
|
||||
}
|
||||
|
||||
function finalize() {
|
||||
tradingSystem = undefined
|
||||
tradingEngine = undefined
|
||||
sessionParameters = undefined
|
||||
taskParameters = undefined
|
||||
TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.messagesSent = undefined
|
||||
}
|
||||
|
||||
function makeAnnouncements(node, status='Open') {
|
||||
if (node === undefined) { return }
|
||||
if (node.announcements === undefined) { return }
|
||||
|
||||
for (let i = 0; i < node.announcements.length; i++) {
|
||||
let announcement = node.announcements[i]
|
||||
let canAnnounce = true
|
||||
|
||||
// Check configuration to see if Announcement should be run at Enter or Exit of Node
|
||||
// set defaults, protect against empty configurations or missing values
|
||||
let onEnter = true
|
||||
let onExit = false
|
||||
if (announcement.config.onEnter !== undefined) {
|
||||
onEnter = announcement.config.onEnter
|
||||
}
|
||||
if (announcement.config.onExit !== undefined) {
|
||||
onExit = announcement.config.onExit
|
||||
if (announcement.config.onEnter === undefined) {
|
||||
onEnter = false
|
||||
}
|
||||
}
|
||||
if ((status === 'Open' && onEnter) || (status === 'Closed' && onExit)) {
|
||||
canAnnounce = true
|
||||
} else {
|
||||
canAnnounce = false
|
||||
}
|
||||
|
||||
if (announcement.announcementCondition !== undefined) {
|
||||
let conditionValue
|
||||
try {
|
||||
conditionValue = eval(announcement.announcementCondition.code)
|
||||
} catch (err) {
|
||||
|
||||
const message = 'Announcement Condition Evaluation Error'
|
||||
let docs = {
|
||||
project: 'Foundations',
|
||||
category: 'Topic',
|
||||
type: 'TS LF Trading Bot Error - ' + message,
|
||||
placeholder: {}
|
||||
}
|
||||
|
||||
TS.projects.education.utilities.docsFunctions.buildPlaceholder(docs, err, announcement.announcementCondition.name, announcement.announcementCondition.code, undefined, undefined, undefined)
|
||||
|
||||
tradingSystem.addError([announcement.announcementCondition.id, err.message, docs])
|
||||
}
|
||||
if (conditionValue !== true) { canAnnounce = false }
|
||||
}
|
||||
if (canAnnounce === true) {
|
||||
let text = announcement.config.text
|
||||
if (announcement.announcementFormula !== undefined) {
|
||||
let formulaValue
|
||||
let errorMessage
|
||||
|
||||
try {
|
||||
formulaValue = eval(announcement.announcementFormula.code)
|
||||
} catch (err) {
|
||||
|
||||
errorMessage = err.message
|
||||
const message = 'Announcement Formula Evaluation Error'
|
||||
let docs = {
|
||||
project: 'Foundations',
|
||||
category: 'Topic',
|
||||
type: 'TS LF Trading Bot Error - ' + message,
|
||||
placeholder: {}
|
||||
}
|
||||
|
||||
TS.projects.education.utilities.docsFunctions.buildPlaceholder(docs, err, announcement.announcementFormula.name, announcement.announcementFormula.code, undefined, undefined, undefined)
|
||||
|
||||
tradingSystem.addError([announcement.announcementFormula.id, err.message, docs])
|
||||
}
|
||||
if (errorMessage == undefined) { text = formulaValue }
|
||||
}
|
||||
|
||||
if (TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots !== undefined) {
|
||||
TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.socialBots.announce(text)
|
||||
tradingSystem.announcements.push([announcement.id, text])
|
||||
} else {
|
||||
|
||||
const message = 'Social Bots Node Missing'
|
||||
let docs = {
|
||||
project: 'Foundations',
|
||||
category: 'Topic',
|
||||
type: 'TS LF Trading Bot Error - ' + message,
|
||||
placeholder: {}
|
||||
}
|
||||
|
||||
tradingSystem.addError([TS.projects.foundations.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).SESSION_NODE.id, message, docs])
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,22 @@
|
||||
exports.newTradingSignalsModulesOutgoingTradingSignals = function (processIndex) {
|
||||
|
||||
let thisObject = {
|
||||
broadcastSignal: broadcastSignal,
|
||||
initialize: initialize,
|
||||
finalize: finalize
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function initialize() {
|
||||
|
||||
}
|
||||
|
||||
function finalize() {
|
||||
}
|
||||
|
||||
function broadcastSignal(node) {
|
||||
if (node === undefined) { return }
|
||||
if (node.outgoingSignals === undefined) { return }
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user