From c14b03a25b4f91ffd731e19c3580fa894ceeed57 Mon Sep 17 00:00:00 2001 From: Luis Fernando Molina Date: Thu, 12 Sep 2019 10:08:23 +0200 Subject: [PATCH] Backtests Tested and Running with events --- CockpitSpace/GraphQLRestartSimulation.js | 39 ------------------- .../FunctionLibraries/TaskFunctions.js | 4 +- Utilities.js | 18 +-------- 3 files changed, 4 insertions(+), 57 deletions(-) delete mode 100644 CockpitSpace/GraphQLRestartSimulation.js diff --git a/CockpitSpace/GraphQLRestartSimulation.js b/CockpitSpace/GraphQLRestartSimulation.js deleted file mode 100644 index fc42a3a66..000000000 --- a/CockpitSpace/GraphQLRestartSimulation.js +++ /dev/null @@ -1,39 +0,0 @@ - -async function graphQlRestartSimulation (simulationParams) { - try { - const accessToken = window.localStorage.getItem(LOGGED_IN_ACCESS_TOKEN_LOCAL_STORAGE_KEY) - - if (accessToken === null) { - throw new Error('Can not restart the simulation because the user is not logged in. ') - } - - const graphQLServer = await axios({ - url: window.canvasApp.graphQL.masterAppApiUrl, - method: 'post', - data: { - query: ` - mutation operations_RunSimulation( - $simulation: operations_SimulationInput) - { - operations_RunSimulation(simulation: $simulation) - } - `, - variables: { - simulation: simulationParams - } - }, - headers: { - authorization: 'Bearer ' + accessToken - } - }) - - if (graphQLServer.data.errors) { - console.log(graphQLServer.data.errors) - throw new Error(graphQLServer.data.errors[0].message) - } - } catch (err) { - console.log(err.stack) - throw new Error('There has been an error restarting the simulation. Error: ' + err.stack) - } -} - diff --git a/StrategySpace/Workspace/FunctionLibraries/TaskFunctions.js b/StrategySpace/Workspace/FunctionLibraries/TaskFunctions.js index 72b48c1e3..df729a1c3 100644 --- a/StrategySpace/Workspace/FunctionLibraries/TaskFunctions.js +++ b/StrategySpace/Workspace/FunctionLibraries/TaskFunctions.js @@ -22,6 +22,7 @@ function newTaskFunctions () { let event = { taskId: node.id, + taskName: node.name, definition: JSON.stringify(functionLibraryProtocolNode.getProtocolNode(node, false, true, true)) // <- We need to do this workaround in order no to send unescaped charactars to the taskManager. } systemEventHandler.raiseEvent('Task Manager', 'Run Task', event) @@ -29,7 +30,8 @@ function newTaskFunctions () { function stopTask (node, functionLibraryProtocolNode) { let event = { - taskId: node.id + taskId: node.id, + taskName: node.name } systemEventHandler.raiseEvent('Task Manager', 'Stop Task', event) diff --git a/Utilities.js b/Utilities.js index 17f0dba24..1639bdb62 100644 --- a/Utilities.js +++ b/Utilities.js @@ -7,25 +7,9 @@ function getSimulationParams () { let timePeriodArray = timePeriodsMasterArray[currentTimePeriod.filePeriodIndex] let timePeriod = timePeriodArray[currentTimePeriod.timePeriodIndex][1] - let timePeriodDailyArray = [] - let timePeriodMarketArray = [] - - switch (currentTimePeriod.filePeriodIndex) { - case 0: { - timePeriodMarketArray.push(timePeriod) - break - } - case 1: { - timePeriodDailyArray.push(timePeriod) - break - } - } - let simulationParams = { beginDatetime: dateAtScreenCorner.valueOf(), - resumeExecution: false, - timePeriodDailyArray: timePeriodDailyArray, - timePeriodMarketArray: timePeriodMarketArray, + timePeriod: timePeriod, timestamp: (new Date()).valueOf() }