Running Session from menu item implemented

This commit is contained in:
Luis Fernando Molina committed 2019-10-03 16:53:36 +02:00
1 parent bb816ecc21
commit 79bff38001
4 files changed
+54 -11

No files matched your search

+6 -7
View File
@@ -593,11 +593,11 @@ function newStrategyPart () {
thisObject.circularProgressBar.fitFunction = thisObject.fitFunction
thisObject.circularProgressBar.container = thisObject.container
/* We will wait to the event that the task was terminated in order to call back the menu item */
/* We will wait to the event that the execution was terminated in order to call back the menu item */
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id
systemEventHandler.listenToEvent(key, 'Running', undefined, key, undefined, onTaskTerminated)
systemEventHandler.listenToEvent(key, 'Running', undefined, key, undefined, onExecutionTerminated)
function onTaskTerminated () {
function onExecutionTerminated () {
if (callBackFunction !== undefined) {
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
}
@@ -605,11 +605,11 @@ function newStrategyPart () {
}
function stop (callBackFunction) {
/* We will wait to the event that the task was terminated in order to call back the menu item */
/* We will wait to the event that the execution was terminated in order to call back the menu item */
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id
let eventSubscriptionId = systemEventHandler.listenToEvent(key, 'Stopped', undefined, key, undefined, onTaskTerminated)
let eventSubscriptionId = systemEventHandler.listenToEvent(key, 'Stopped', undefined, key, undefined, onExecutionTerminated)
function onTaskTerminated () {
function onExecutionTerminated () {
if (callBackFunction !== undefined) {
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
}
@@ -1130,4 +1130,3 @@ function newStrategyPart () {
}
}
}
+4 -4
View File
@@ -887,7 +887,7 @@ function newStrategyPartConstructor () {
addLeftIcons(menuItemsInitialValues, floatingObject)
menuItemsInitialValues.push(
{
action: 'Run Backtesting Session',
action: 'Run Session',
actionFunction: payload.onMenuItemClick,
label: 'Run',
workingLabel: 'Stop',
@@ -944,7 +944,7 @@ function newStrategyPartConstructor () {
addLeftIcons(menuItemsInitialValues, floatingObject)
menuItemsInitialValues.push(
{
action: 'Run Live Trading Session',
action: 'Run Session',
actionFunction: payload.onMenuItemClick,
label: 'Run',
workingLabel: 'Stop',
@@ -1001,7 +1001,7 @@ function newStrategyPartConstructor () {
addLeftIcons(menuItemsInitialValues, floatingObject)
menuItemsInitialValues.push(
{
action: 'Run Fordward Testing Session',
action: 'Run Session',
actionFunction: payload.onMenuItemClick,
label: 'Run',
workingLabel: 'Stop',
@@ -1058,7 +1058,7 @@ function newStrategyPartConstructor () {
addLeftIcons(menuItemsInitialValues, floatingObject)
menuItemsInitialValues.push(
{
action: 'Run Paper Trading Session',
action: 'Run Session',
actionFunction: payload.onMenuItemClick,
label: 'Run',
workingLabel: 'Stop',
@@ -0,0 +1,33 @@
function newSessionFunctions () {
thisObject = {
runSession: runSession,
stopSession: stopSession
}
return thisObject
function runSession (node, functionLibraryProtocolNode, callBackFunction) {
node.payload.uiObject.run(callBackFunction)
let event = {
session: JSON.stringify(functionLibraryProtocolNode.getProtocolNode(node, false, false, true)),
definition: getDefinition()
}
let key = 'Session' + '-' + node.id + '-' + 'Events'
systemEventHandler.raiseEvent(key, 'Run Session', event)
function getDefinition () {
let definitionNode = canvas.strategySpace.workspace.getProtocolDefinitionNode()
definitionNode.simulationParams = getSimulationParams()
return JSON.stringify(definitionNode)
}
}
function stopSession (node, functionLibraryProtocolNode, callBackFunction) {
let key = 'Session' + '-' + node.id + '-' + 'Events'
systemEventHandler.raiseEvent(key, 'Stop Session')
node.payload.uiObject.stop(callBackFunction)
}
}
+11
View File
@@ -46,6 +46,7 @@ function newWorkspace () {
let functionLibraryProtocolNode = newProtocolNode()
let functionLibraryWorkspaceNodes = newStringifyNode()
let functionLibraryTaskFunctions = newTaskFunctions()
let functionLibrarySessionFunctions = newSessionFunctions()
thisObject.nodeChildren = newNodeChildren()
return thisObject
@@ -246,6 +247,16 @@ function newWorkspace () {
functionLibraryTaskFunctions.stopAllTasks(payload.node, functionLibraryProtocolNode)
}
break
case 'Run Session':
{
functionLibrarySessionFunctions.runSession(payload.node, functionLibraryProtocolNode, callBackFunction)
}
break
case 'Stop Session':
{
functionLibrarySessionFunctions.stopSession(payload.node, functionLibraryProtocolNode, callBackFunction)
}
break
case 'Add Network':
{
functionLibraryPartsFromNodes.addNetwork(payload.node)