Trading Engines as Include
No files matched your search
@@ -16,6 +16,7 @@ PLOTTERS_PATH=./Legacy-Code
|
||||
DATA_MINES_PATH=./Data-Mines
|
||||
TRADING_SYSTEMS_PATH=./Trading-Systems
|
||||
SUPER_SCRIPTS_PATH=./Super-Scripts
|
||||
TRADING_ENGINES_PATH=./Trading-Engines
|
||||
|
||||
WRITE_LOGS_TO_FILES=true
|
||||
BOTS_PATH=./Legacy-Code
|
||||
|
||||
@@ -13959,8 +13959,7 @@
|
||||
"childType": "Bot Data Dependencies",
|
||||
"autoAdd": false
|
||||
}
|
||||
],
|
||||
"icon": "stellar"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Bot Data Dependencies",
|
||||
@@ -14006,8 +14005,7 @@
|
||||
"childType": "Data Dependency Folder",
|
||||
"autoAdd": false
|
||||
}
|
||||
],
|
||||
"icon": "stop"
|
||||
]
|
||||
},
|
||||
{
|
||||
"type": "Data Dependency Folder",
|
||||
@@ -14053,7 +14051,6 @@
|
||||
"childType": "Data Dependency Folder",
|
||||
"autoAdd": false
|
||||
}
|
||||
],
|
||||
"icon": "status"
|
||||
]
|
||||
}
|
||||
]
|
||||
|
After Width: | Height: | Size: 16 KiB |
|
After Width: | Height: | Size: 20 KiB |
|
After Width: | Height: | Size: 23 KiB |
|
After Width: | Height: | Size: 5.1 KiB |
|
After Width: | Height: | Size: 13 KiB |
|
After Width: | Height: | Size: 14 KiB |
|
After Width: | Height: | Size: 9.4 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 29 KiB |
|
After Width: | Height: | Size: 18 KiB |
|
After Width: | Height: | Size: 7.9 KiB |
|
Before Width: | Height: | Size: 19 KiB After Width: | Height: | Size: 18 KiB |
|
Before Width: | Height: | Size: 24 KiB After Width: | Height: | Size: 23 KiB |
|
Before Width: | Height: | Size: 20 KiB After Width: | Height: | Size: 22 KiB |
|
Before Width: | Height: | Size: 17 KiB After Width: | Height: | Size: 17 KiB |
@@ -9,16 +9,14 @@
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
This server creates and destroys Task Servers according to what is going on at the UI. Each of these created servers will do their own
|
||||
work. The responsibility of this server is to manage those children processes in order to be in sync with what the end user want and is defining
|
||||
at the user interface.
|
||||
|
||||
*/
|
||||
|
||||
const { fork } = require('child_process')
|
||||
require('dotenv').config()
|
||||
tasks = new Map()
|
||||
tasksMap = new Map()
|
||||
|
||||
return thisObject
|
||||
|
||||
@@ -31,15 +29,11 @@
|
||||
}
|
||||
|
||||
function run() {
|
||||
|
||||
/*
|
||||
|
||||
Here we will create an Event Handler for this server. After that we will listen to events happening here. Elements of the UI will raise events here,
|
||||
as a way to communicate what is going on with the user interacting with UI components. That is the way this server will know for example when a new
|
||||
task needs to be created or destroyed.
|
||||
|
||||
*/
|
||||
|
||||
let eventsServerClient = newEventsServerClient()
|
||||
eventsServerClient.createEventHandler('Task Manager')
|
||||
eventsServerClient.listenToEvent('Task Manager', 'Run Task', undefined, undefined, undefined, runTask)
|
||||
@@ -65,7 +59,7 @@
|
||||
return
|
||||
}
|
||||
|
||||
if (tasks.get(message.event.taskId) !== undefined) {
|
||||
if (tasksMap.get(message.event.taskId) !== undefined) {
|
||||
let key = message.event.taskName + '-' + 'Task' + '-' + message.event.taskId
|
||||
eventsServerClient.raiseEvent(key, 'Running') // Meaning Task Running
|
||||
return
|
||||
@@ -82,29 +76,45 @@
|
||||
process.execArgv[i] = ''
|
||||
}
|
||||
}
|
||||
/*
|
||||
Forking this process:
|
||||
|
||||
/* Forking this process. */
|
||||
The Task Server is going to run at a fork of this process. In this way we have a some communication capabilities
|
||||
between processes, which is kind of limited but good enough for what we need. We send to the forked process
|
||||
the taskId and taskName at the same time we create the process. Once the process is up and running it will
|
||||
emit an event that is ready, and at that point we will send all the information needed to run the task.
|
||||
*/
|
||||
let task = {
|
||||
childProcess: fork(path, [message.event.taskId], { stdio: 'inherit' }),
|
||||
id: message.event.taskId,
|
||||
name: message.event.taskName
|
||||
}
|
||||
|
||||
tasks.set(message.event.taskId, task)
|
||||
|
||||
/* Remember this is a running task now */
|
||||
tasksMap.set(message.event.taskId, task)
|
||||
/* If the Task Server crashes, we remove it from our task map */
|
||||
task.childProcess.on('error', (err) => {
|
||||
console.log('[ERROR] BackendServers -> Task Manager Server -> runTask -> Problem with Task Name = ' + task.name)
|
||||
console.log('[ERROR] BackendServers -> Task Manager Server -> runTask -> Problem with Task Id = ' + task.id)
|
||||
console.log(`[ERROR] BackendServers -> Task Manager Server -> runTask -> Task Manager exited with error ${err}`)
|
||||
console.log(`[ERROR] BackendServers -> Task Manager Server -> runTask -> Task Server exited with error ${err}`)
|
||||
tasksMap.delete(task.id)
|
||||
})
|
||||
/* If the Tast Server stops, we remove it from our task map */
|
||||
task.childProcess.on('close', (code, signal) => {
|
||||
//console.log('[INFO] BackendServers -> Task Manager Server -> runTask -> Task Terminated. -> Task Name = ' + task.name)
|
||||
//console.log('[INFO] BackendServers -> Task Manager Server -> runTask -> Task Terminated. -> Task Id = ' + task.id)
|
||||
tasks.delete(task.id)
|
||||
tasksMap.delete(task.id)
|
||||
})
|
||||
|
||||
/*
|
||||
We listen to the newly created Task Server events, waiting until it is up and ready to receive all the Task specific
|
||||
instruction, to know what kind of task to execute.
|
||||
*/
|
||||
eventsServerClient.listenToEvent('Task Manager - ' + message.event.taskId, 'Nodejs Process Ready for Task', undefined, undefined, undefined, sendStartingEvent)
|
||||
|
||||
/*
|
||||
Here we do send the rest of the task information we have, which is what defines what the Task Server is actually
|
||||
going to do. From there on, here at the Task Manager, we have nothing to do until either the Task Server crashes or exit,
|
||||
or the end users requests to stop it. Note that the due to the size of the instructions can not be sent via
|
||||
intra-process communications.
|
||||
*/
|
||||
function sendStartingEvent() {
|
||||
//console.log('[INFO] BackendServers -> Task Manager Server -> runTask -> Emitting Event -> key = ' + 'Task Server - ' + task.id)
|
||||
eventsServerClient.raiseEvent('Task Server - ' + task.id, 'Run Task', message.event)
|
||||
@@ -112,9 +122,7 @@
|
||||
}
|
||||
|
||||
function stopTask(message) {
|
||||
|
||||
//console.log('[INFO] BackendServers -> Task Manager Server -> stopTask -> Entering function.')
|
||||
|
||||
if (message.event === undefined) {
|
||||
console.log('[WARN] BackendServers -> Task Manager Server -> stopTask -> Message Received Without Event -> message = ' + JSON.stringify(message).substring(0, 1000))
|
||||
return
|
||||
@@ -124,12 +132,15 @@
|
||||
console.log('[WARN] BackendServers -> Task Manager Server -> stopTask -> Message Received Without taskId -> message = ' + JSON.stringify(message).substring(0, 1000))
|
||||
return
|
||||
}
|
||||
|
||||
//console.log('[INFO] BackendServers -> Task Manager Server -> stopTask -> Task Name = ' + message.event.taskName)
|
||||
//console.log('[INFO] BackendServers -> Task Manager Server -> stopTask -> Task Id = ' + message.event.taskId)
|
||||
|
||||
let task = tasks.get(message.event.taskId)
|
||||
let task = tasksMap.get(message.event.taskId)
|
||||
|
||||
/*
|
||||
The instruction to stop the Task Server process is sent via intra-process messaging. We will remove this task from
|
||||
our map once we received the onClose event of our forked process.
|
||||
*/
|
||||
if (task) {
|
||||
task.childProcess.send('Stop this Task');
|
||||
//console.log('[INFO] BackendServers -> Task Manager Server -> stopTask -> Child Process instructed to finish.')
|
||||
|
||||
@@ -458,10 +458,11 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
|
||||
{
|
||||
const fs = require('fs')
|
||||
let folder
|
||||
let includedNames = {
|
||||
let includedNames = {
|
||||
includedDataMines: [],
|
||||
includedTradingSystems: [],
|
||||
includedSuperScripts: []
|
||||
includedSuperScripts: [],
|
||||
includedTradingEngines: []
|
||||
}
|
||||
|
||||
folder = process.env.DATA_MINES_PATH + '/'
|
||||
@@ -473,7 +474,11 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
|
||||
folder = process.env.SUPER_SCRIPTS_PATH + '/'
|
||||
fs.readdir(folder, (err, files) => {
|
||||
includedNames.includedSuperScripts = files
|
||||
respondWithContent(JSON.stringify(includedNames), response)
|
||||
folder = process.env.TRADING_ENGINES_PATH + '/'
|
||||
fs.readdir(folder, (err, files) => {
|
||||
includedNames.includedTradingEngines = files
|
||||
respondWithContent(JSON.stringify(includedNames), response)
|
||||
})
|
||||
})
|
||||
})
|
||||
})
|
||||
@@ -617,6 +622,12 @@ exports.newWebServer = function newWebServer(EVENTS_SERVER) {
|
||||
}
|
||||
break
|
||||
|
||||
case 'TradingEngines':
|
||||
{
|
||||
respondWithFile(process.env.TRADING_ENGINES_PATH + '/' + requestParameters[2], response)
|
||||
}
|
||||
break
|
||||
|
||||
case 'Storage':
|
||||
{
|
||||
respondWithFile(process.env.STORAGE_PATH + '/' + request.url.substring(9), response)
|
||||
|
||||
@@ -27,18 +27,18 @@ function newUiObjectsFromNodes() {
|
||||
sessionsToRun = []
|
||||
|
||||
getIncludedNames()
|
||||
|
||||
|
||||
function getIncludedNames() {
|
||||
|
||||
callServer(undefined, 'IncludedNames', onResponse)
|
||||
|
||||
|
||||
function onResponse(err, data) {
|
||||
if (err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
console.log('Failed to Fetch Inclided Names from the Backend')
|
||||
return
|
||||
}
|
||||
|
||||
let includedNames = JSON.parse(data)
|
||||
|
||||
let includedNames = JSON.parse(data)
|
||||
addIncludedNodes(includedNames)
|
||||
}
|
||||
}
|
||||
@@ -48,6 +48,7 @@ function newUiObjectsFromNodes() {
|
||||
let includedDataMines = includedNames.includedDataMines
|
||||
let includedTradingSystems = includedNames.includedTradingSystems
|
||||
let includedSuperScripts = includedNames.includedSuperScripts
|
||||
let includedTradingEngines = includedNames.includedTradingEngines
|
||||
|
||||
let totalIncluded = 0
|
||||
|
||||
@@ -74,7 +75,7 @@ function newUiObjectsFromNodes() {
|
||||
receivedNode.isIncluded = true
|
||||
node.rootNodes.unshift(receivedNode)
|
||||
totalIncluded++
|
||||
if (totalIncluded === includedDataMines.length + includedTradingSystems.length + includedSuperScripts.length) {
|
||||
if (totalIncluded === includedDataMines.length + includedTradingSystems.length + includedSuperScripts.length + includedTradingEngines.length) {
|
||||
addUserDefinedNodes()
|
||||
}
|
||||
}
|
||||
@@ -85,7 +86,7 @@ function newUiObjectsFromNodes() {
|
||||
blobService.getFileFromHost('TradingSystems' + '/' + name, onFileReceived, true)
|
||||
function onFileReceived(err, text, response) {
|
||||
if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
console.log('Cannot load included Data Mine ' + name + '. The workspace can not be loaded.')
|
||||
console.log('Cannot load included Trading System ' + name + '. The workspace can not be loaded.')
|
||||
return
|
||||
}
|
||||
let receivedNode = JSON.parse(text)
|
||||
@@ -103,7 +104,7 @@ function newUiObjectsFromNodes() {
|
||||
receivedNode.isIncluded = true
|
||||
node.rootNodes.unshift(receivedNode)
|
||||
totalIncluded++
|
||||
if (totalIncluded === includedDataMines.length + includedTradingSystems.length + includedSuperScripts.length) {
|
||||
if (totalIncluded === includedDataMines.length + includedTradingSystems.length + includedSuperScripts.length + includedTradingEngines.length) {
|
||||
addUserDefinedNodes()
|
||||
}
|
||||
}
|
||||
@@ -114,7 +115,7 @@ function newUiObjectsFromNodes() {
|
||||
blobService.getFileFromHost('SuperScripts' + '/' + name, onFileReceived, true)
|
||||
function onFileReceived(err, text, response) {
|
||||
if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
console.log('Cannot load included Data Mine ' + name + '. The workspace can not be loaded.')
|
||||
console.log('Cannot load included Super Script ' + name + '. The workspace can not be loaded.')
|
||||
return
|
||||
}
|
||||
let receivedNode = JSON.parse(text)
|
||||
@@ -132,7 +133,33 @@ function newUiObjectsFromNodes() {
|
||||
receivedNode.isIncluded = true
|
||||
node.rootNodes.unshift(receivedNode)
|
||||
totalIncluded++
|
||||
if (totalIncluded === includedDataMines.length + includedTradingSystems.length + includedSuperScripts.length) {
|
||||
if (totalIncluded === includedDataMines.length + includedTradingSystems.length + includedSuperScripts.length + includedTradingEngines.length) {
|
||||
addUserDefinedNodes()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for (let i = 0; i < includedTradingEngines.length; i++) {
|
||||
let name = includedTradingEngines[i]
|
||||
blobService.getFileFromHost('TradingEngines' + '/' + name, onFileReceived, true)
|
||||
function onFileReceived(err, text, response) {
|
||||
if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
|
||||
console.log('Cannot load included Trading Engine ' + name + '. The workspace can not be loaded.')
|
||||
return
|
||||
}
|
||||
let receivedNode = JSON.parse(text)
|
||||
for (let i = 0; i < node.rootNodes.length; i++) {
|
||||
let rootNode = node.rootNodes[i]
|
||||
if (rootNode.type === 'Trading Engine') {
|
||||
if (rootNode.name === name) {
|
||||
rootNodes.splice(i, 1)
|
||||
}
|
||||
}
|
||||
}
|
||||
receivedNode.isIncluded = true
|
||||
node.rootNodes.unshift(receivedNode)
|
||||
totalIncluded++
|
||||
if (totalIncluded === includedDataMines.length + includedTradingSystems.length + includedSuperScripts.length + includedTradingEngines.length) {
|
||||
addUserDefinedNodes()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -973,48 +973,96 @@ function newUiObject() {
|
||||
setupErrorEventListener(callBackFunction)
|
||||
setupWarningEventListener()
|
||||
setupInfoEventListener()
|
||||
}
|
||||
|
||||
function setupRunningEventListener(callBackFunction) {
|
||||
/* We will wait to hear the Running event in order to confirm the execution was really started */
|
||||
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id
|
||||
eventsServerClient.listenToEvent(key, 'Running', undefined, 'UiObject', onResponse, onRunning)
|
||||
|
||||
onRunningCallBackFunction = callBackFunction
|
||||
|
||||
function onResponse(message) {
|
||||
eventSubscriptionIdOnRunning = message.eventSubscriptionId
|
||||
function setupRunningEventListener(callBackFunction) {
|
||||
/* We will wait to hear the Running event in order to confirm the execution was really started */
|
||||
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id
|
||||
eventsServerClient.listenToEvent(key, 'Running', undefined, 'UiObject', onResponse, onRunning)
|
||||
|
||||
onRunningCallBackFunction = callBackFunction
|
||||
|
||||
function onResponse(message) {
|
||||
eventSubscriptionIdOnRunning = message.eventSubscriptionId
|
||||
}
|
||||
|
||||
function onRunning() {
|
||||
if (thisObject.payload === undefined) { return }
|
||||
|
||||
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id
|
||||
eventsServerClient.stopListening(key, eventSubscriptionIdOnRunning, 'UiObject')
|
||||
|
||||
thisObject.isRunning = true
|
||||
|
||||
if (callBackFunction !== undefined) {
|
||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
|
||||
onRunningCallBackFunctionWasCalled = true
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
While it is running, it can happen that it naturally stops or is stopped not from the UI but from other means.
|
||||
In those cases, the stop function would never be called (from the UI). So what we will do is to call it from
|
||||
here with and event, and passing our own callBackFunction. In case there is an external source stopping this,
|
||||
this will produce an execution of the callback with our event, which will produce that the menu item is restored
|
||||
to its default stage.
|
||||
|
||||
If on the other side, it is executed from the UI, then we will be processing the Stopped event twice, which in
|
||||
both cases will reset the menu item to its default state.
|
||||
*/
|
||||
|
||||
let event = {
|
||||
type: 'Secondary Action Already Executed'
|
||||
}
|
||||
stop(callBackFunction, event)
|
||||
}
|
||||
|
||||
function onRunning() {
|
||||
if (thisObject.payload === undefined) { return }
|
||||
|
||||
function setupErrorEventListener(callBackFunction) {
|
||||
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id
|
||||
eventsServerClient.stopListening(key, eventSubscriptionIdOnRunning, 'UiObject')
|
||||
|
||||
thisObject.isRunning = true
|
||||
|
||||
if (callBackFunction !== undefined) {
|
||||
callBackFunction(GLOBAL.DEFAULT_OK_RESPONSE)
|
||||
onRunningCallBackFunctionWasCalled = true
|
||||
eventsServerClient.listenToEvent(key, 'Error', undefined, key, onResponse, onError)
|
||||
|
||||
function onResponse(message) {
|
||||
eventSubscriptionIdOnError = message.eventSubscriptionId
|
||||
}
|
||||
|
||||
function onError(message) {
|
||||
|
||||
let uiObject = getTargetUiObject(message)
|
||||
uiObject.setErrorMessage(message.event.errorMessage, 10)
|
||||
|
||||
let event = {
|
||||
type: 'Secondary Action Already Executed'
|
||||
}
|
||||
completeStop(callBackFunction, event)
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
While it is running, it can happen that it naturally stops or is stopped not from the UI but from other means.
|
||||
In those cases, the stop function would never be called (from the UI). So what we will do is to call it from
|
||||
here with and event, and passing our own callBackFunction. In case there is an external source stopping this,
|
||||
this will produce an execution of the callback with our event, which will produce that the menu item is restored
|
||||
to its default stage.
|
||||
|
||||
If on the other side, it is executed from the UI, then we will be processing the Stopped event twice, which in
|
||||
both cases will reset the menu item to its default state.
|
||||
*/
|
||||
|
||||
let event = {
|
||||
type: 'Secondary Action Already Executed'
|
||||
function setupWarningEventListener() {
|
||||
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id
|
||||
eventsServerClient.listenToEvent(key, 'Warning', undefined, key, onResponse, onWarning)
|
||||
|
||||
function onResponse(message) {
|
||||
eventSubscriptionIdOnWarning = message.eventSubscriptionId
|
||||
}
|
||||
|
||||
function onWarning(message) {
|
||||
let uiObject = getTargetUiObject(message)
|
||||
uiObject.setWarningMessage(message.event.warningMessage, 10)
|
||||
}
|
||||
}
|
||||
|
||||
function setupInfoEventListener() {
|
||||
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id
|
||||
eventsServerClient.listenToEvent(key, 'Info', undefined, key, onResponse, onInfo)
|
||||
|
||||
function onResponse(message) {
|
||||
eventSubscriptionIdOnInfo = message.eventSubscriptionId
|
||||
}
|
||||
|
||||
function onInfo(message) {
|
||||
let uiObject = getTargetUiObject(message)
|
||||
uiObject.setInfoMessage(message.event.infoMessage, 10)
|
||||
}
|
||||
}
|
||||
stop(callBackFunction, event)
|
||||
}
|
||||
|
||||
function getTargetUiObject(message) {
|
||||
@@ -1032,54 +1080,6 @@ function newUiObject() {
|
||||
return uiObject
|
||||
}
|
||||
|
||||
function setupErrorEventListener(callBackFunction) {
|
||||
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id
|
||||
eventsServerClient.listenToEvent(key, 'Error', undefined, key, onResponse, onError)
|
||||
|
||||
function onResponse(message) {
|
||||
eventSubscriptionIdOnError = message.eventSubscriptionId
|
||||
}
|
||||
|
||||
function onError(message) {
|
||||
|
||||
let uiObject = getTargetUiObject(message)
|
||||
uiObject.setErrorMessage(message.event.errorMessage, 10)
|
||||
|
||||
let event = {
|
||||
type: 'Secondary Action Already Executed'
|
||||
}
|
||||
completeStop(callBackFunction, event)
|
||||
}
|
||||
}
|
||||
|
||||
function setupWarningEventListener() {
|
||||
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id
|
||||
eventsServerClient.listenToEvent(key, 'Warning', undefined, key, onResponse, onWarning)
|
||||
|
||||
function onResponse(message) {
|
||||
eventSubscriptionIdOnWarning = message.eventSubscriptionId
|
||||
}
|
||||
|
||||
function onWarning(message) {
|
||||
let uiObject = getTargetUiObject(message)
|
||||
uiObject.setWarningMessage(message.event.warningMessage, 10)
|
||||
}
|
||||
}
|
||||
|
||||
function setupInfoEventListener() {
|
||||
let key = thisObject.payload.node.name + '-' + thisObject.payload.node.type + '-' + thisObject.payload.node.id
|
||||
eventsServerClient.listenToEvent(key, 'Info', undefined, key, onResponse, onInfo)
|
||||
|
||||
function onResponse(message) {
|
||||
eventSubscriptionIdOnInfo = message.eventSubscriptionId
|
||||
}
|
||||
|
||||
function onInfo(message) {
|
||||
let uiObject = getTargetUiObject(message)
|
||||
uiObject.setInfoMessage(message.event.infoMessage, 10)
|
||||
}
|
||||
}
|
||||
|
||||
function stop(callBackFunction, event) {
|
||||
/* 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
|
||||
|
||||
@@ -822,8 +822,12 @@ function newPlotter() {
|
||||
imagePosition.x = dataPoint.x
|
||||
imagePosition.y = dataPoint.y
|
||||
let imageToDraw = canvas.designSpace.iconCollection.get(imageName)
|
||||
if (imageToDraw.canDrawIcon === true) {
|
||||
browserCanvasContext.drawImage(imageToDraw, imagePosition.x - imageSize / 2 + offsetX, imagePosition.y - imageSize / 2 - offsetY, imageSize, imageSize)
|
||||
if (imageToDraw !== undefined) {
|
||||
if (imageToDraw.canDrawIcon === true) {
|
||||
browserCanvasContext.drawImage(imageToDraw, imagePosition.x - imageSize / 2 + offsetX, imagePosition.y - imageSize / 2 - offsetY, imageSize, imageSize)
|
||||
}
|
||||
} else {
|
||||
console.log('Can not plot image named '+ imageName + ' of product ' + productDefinition.name + ' because it does not exist.')
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
{"type":"Data Mine","name":"Masters-Trading","config":"{ \n\"codeName\": \"Masters-Trading\"\n}","sensorBots":[],"indicatorBots":[],"tradingBots":[{"type":"Trading Bot","name":"Low Frequency","config":"{\n\"codeName\": \"Low-Frequency\"\n}","processes":[{"type":"Process Definition","name":"Trading","config":"{\n \"codeName\": \"Trading\",\n \"sessionRunWaitTime\": 5000,\n \"retryWaitTime\": 10000,\n \"framework\": {\n \"name\": \"Low-Frequency-Trading-Process\"\n }\n }","processOutput":{"type":"Process Output","name":"New Process Output","outputDatasets":[],"outputDatasetFolders":[{"type":"Output Dataset Folder","name":"Trading Engine","outputDatasets":[],"outputDatasetFolders":[{"type":"Output Dataset Folder","name":"Episode","outputDatasets":[{"type":"Output Dataset","name":"Multi-Period-Market Episode Counters","id":"a1ba5aea-27cf-4789-858f-bcae5e844d68","savedPayload":{"position":{"x":18695.98620237498,"y":18096.904605501608},"targetPosition":{"x":18302.944150761276,"y":17399.99377423144},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Dataset Definition","name":"Multi-Period-Market","id":"3ed03a02-381d-43fe-9faa-761728c53bd8"}}},{"type":"Output Dataset","name":"Multi-Period-Daily Episode Counters","id":"0545bf38-80e0-4888-88bc-a8710355fa57","savedPayload":{"position":{"x":18553.26812687739,"y":18154.986404670184},"targetPosition":{"x":18302.944150761276,"y":17399.99377423144},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Dataset Definition","name":"Multi-Period-Daily","id":"15f5b150-f1cf-403c-8cb9-2c7c4e1db8e8"}}},{"type":"Output Dataset","name":"Multi-Period-Market Episode Statistics","id":"5af42032-7ce1-4afe-95d7-e33ba00794eb","savedPayload":{"position":{"x":18403.68005112028,"y":18180.85313634756},"targetPosition":{"x":18302.944150761276,"y":17399.99377423144},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Dataset Definition","name":"Multi-Period-Market","id":"fc9dc0f7-35e0-4548-bb91-f920825d694f"}}},{"type":"Output Dataset","name":"Multi-Period-Daily Episode Statistics","id":"d18cec41-5512-44d3-8005-5b9a7fd80461","savedPayload":{"position":{"x":18248.553833321002,"y":18249.937044603947},"targetPosition":{"x":18302.944150761276,"y":17399.99377423144},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Dataset Definition","name":"Multi-Period-Daily","id":"91953362-8751-4440-a898-21245cd47c15"}}},{"type":"Output Dataset","name":"Multi-Period-Market Episode Candle","id":"3df1601e-ef97-4103-b90e-364c1b6527f6","savedPayload":{"position":{"x":18112.439448601337,"y":18182.963523815775},"targetPosition":{"x":18302.944150761276,"y":17399.99377423144},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Dataset Definition","name":"Multi-Period-Market","id":"17fb41f5-61b5-4433-9a10-950ff8216a7e"}}},{"type":"Output Dataset","name":"Multi-Period-Daily Episode Candle","id":"7745d3f8-0a55-4d1a-9778-1360c5a5fad6","savedPayload":{"position":{"x":17974.850677897197,"y":18125.029991449926},"targetPosition":{"x":18302.944150761276,"y":17399.99377423144},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Dataset Definition","name":"Multi-Period-Daily","id":"bbc9467d-28bf-432b-9e49-582d1bcabfb9"}}},{"type":"Output Dataset","name":"Multi-Period-Market Episode Balances","id":"f5549653-3d66-4f6b-8aff-44f728772ed9","savedPayload":{"position":{"x":17843.973444284773,"y":18054.262005948138},"targetPosition":{"x":18302.944150761276,"y":17399.99377423144},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Dataset Definition","name":"Multi-Period-Market","id":"acddff59-b51b-4b45-b58f-71d4077755ee"}}},{"type":"Output Dataset","name":"Multi-Period-Daily Episode Balances","id":"5d016965-9c3b-48bf-8969-157430be4d54","savedPayload":{"position":{"x":17731.896346507434,"y":17957.73263577934},"targetPosition":{"x":18302.944150761276,"y":17399.99377423144},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Dataset Definition","name":"Multi-Period-Daily","id":"213b8fe8-f772-41ea-a3f5-97867be555f7"}}},{"type":"Output Dataset","name":"Multi-PerioLine truncated
|
||||
{"type":"Data Mine","name":"Masters-Trading","config":"{ \n\"codeName\": \"Masters-Trading\"\n}","sensorBots":[],"indicatorBots":[],"tradingBots":[{"type":"Trading Bot","name":"Low Frequency","config":"{\n\"codeName\": \"Low-Frequency\"\n}","processes":[{"type":"Process Definition","name":"Trading","config":"{\n \"codeName\": \"Trading\",\n \"sessionRunWaitTime\": 5000,\n \"retryWaitTime\": 10000,\n \"framework\": {\n \"name\": \"Low-Frequency-Trading-Process\"\n }\n }","processOutput":{"type":"Process Output","name":"New Process Output","outputDatasets":[],"outputDatasetFolders":[{"type":"Output Dataset Folder","name":"Trading Engine","outputDatasets":[],"outputDatasetFolders":[{"type":"Output Dataset Folder","name":"Episode","outputDatasets":[{"type":"Output Dataset","name":"Multi-Period-Market Episode Counters","id":"a1ba5aea-27cf-4789-858f-bcae5e844d68","savedPayload":{"position":{"x":18695.98620237498,"y":18096.904605501608},"targetPosition":{"x":18302.944150761276,"y":17399.99377423144},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Dataset Definition","name":"Multi-Period-Market","id":"3ed03a02-381d-43fe-9faa-761728c53bd8"}}},{"type":"Output Dataset","name":"Multi-Period-Daily Episode Counters","id":"0545bf38-80e0-4888-88bc-a8710355fa57","savedPayload":{"position":{"x":18553.26812687739,"y":18154.986404670184},"targetPosition":{"x":18302.944150761276,"y":17399.99377423144},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Dataset Definition","name":"Multi-Period-Daily","id":"15f5b150-f1cf-403c-8cb9-2c7c4e1db8e8"}}},{"type":"Output Dataset","name":"Multi-Period-Market Episode Statistics","id":"5af42032-7ce1-4afe-95d7-e33ba00794eb","savedPayload":{"position":{"x":18403.68005112028,"y":18180.85313634756},"targetPosition":{"x":18302.944150761276,"y":17399.99377423144},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Dataset Definition","name":"Multi-Period-Market","id":"fc9dc0f7-35e0-4548-bb91-f920825d694f"}}},{"type":"Output Dataset","name":"Multi-Period-Daily Episode Statistics","id":"d18cec41-5512-44d3-8005-5b9a7fd80461","savedPayload":{"position":{"x":18248.553833321002,"y":18249.937044603947},"targetPosition":{"x":18302.944150761276,"y":17399.99377423144},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Dataset Definition","name":"Multi-Period-Daily","id":"91953362-8751-4440-a898-21245cd47c15"}}},{"type":"Output Dataset","name":"Multi-Period-Market Episode Candle","id":"3df1601e-ef97-4103-b90e-364c1b6527f6","savedPayload":{"position":{"x":18112.439448601337,"y":18182.963523815775},"targetPosition":{"x":18302.944150761276,"y":17399.99377423144},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Dataset Definition","name":"Multi-Period-Market","id":"17fb41f5-61b5-4433-9a10-950ff8216a7e"}}},{"type":"Output Dataset","name":"Multi-Period-Daily Episode Candle","id":"7745d3f8-0a55-4d1a-9778-1360c5a5fad6","savedPayload":{"position":{"x":17974.850677897197,"y":18125.029991449926},"targetPosition":{"x":18302.944150761276,"y":17399.99377423144},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Dataset Definition","name":"Multi-Period-Daily","id":"bbc9467d-28bf-432b-9e49-582d1bcabfb9"}}},{"type":"Output Dataset","name":"Multi-Period-Market Episode Balances","id":"f5549653-3d66-4f6b-8aff-44f728772ed9","savedPayload":{"position":{"x":17843.973444284773,"y":18054.262005948138},"targetPosition":{"x":18302.944150761276,"y":17399.99377423144},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Dataset Definition","name":"Multi-Period-Market","id":"acddff59-b51b-4b45-b58f-71d4077755ee"}}},{"type":"Output Dataset","name":"Multi-Period-Daily Episode Balances","id":"5d016965-9c3b-48bf-8969-157430be4d54","savedPayload":{"position":{"x":17731.896346507434,"y":17957.73263577934},"targetPosition":{"x":18302.944150761276,"y":17399.99377423144},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{},"referenceParent":{"type":"Dataset Definition","name":"Multi-Period-Daily","id":"213b8fe8-f772-41ea-a3f5-97867be555f7"}}},{"type":"Output Dataset","name":"Multi-PerioLine truncated
|
||||
@@ -124,7 +124,7 @@
|
||||
This is the Data Structure used at the Simulation with all indicator data.
|
||||
We start creating it right here.
|
||||
*/
|
||||
let chart = {}
|
||||
let chart = {}
|
||||
/*
|
||||
Here we check if we need to get Daily Files or not. As an optimization, when
|
||||
we are running on a Time Frame of 1hs or above, we are not going to load
|
||||
@@ -146,8 +146,8 @@
|
||||
} else {
|
||||
/* We are processing Daily Files */
|
||||
do {
|
||||
if (checkStopTaskGracefully() === false) {break}
|
||||
if (checkStopProcessing() === false) {break}
|
||||
if (checkStopTaskGracefully() === false) { break }
|
||||
if (checkStopProcessing() === false) { break }
|
||||
|
||||
/*
|
||||
We update the Trading Process Date with the date calculated at the simulation.
|
||||
@@ -170,15 +170,15 @@
|
||||
/*
|
||||
If for any reason the session was stopped, we will break this loop and exit the process.
|
||||
*/
|
||||
if (bot.STOP_SESSION === true) {break}
|
||||
if (bot.STOP_SESSION === true) { break }
|
||||
/*
|
||||
When we get to the end of the market, we need to break this process loop in order
|
||||
to let time pass, new information be collected from the exchange, new data built
|
||||
into indicators, and eventually a new execution of this process.
|
||||
*/
|
||||
if (checkStopHeadOfTheMarket() === false) {break}
|
||||
}
|
||||
while (true)
|
||||
if (checkStopHeadOfTheMarket() === false) { break }
|
||||
}
|
||||
while (true)
|
||||
}
|
||||
|
||||
checkIfSessionMustStop()
|
||||
@@ -289,7 +289,7 @@
|
||||
for (let dependencyIndex = 0; dependencyIndex < dataDependenciesModule.nodeArray.length; dependencyIndex++) {
|
||||
let dependency = dataDependenciesModule.nodeArray[dependencyIndex];
|
||||
let datasetModule = dataDependenciesModule.dataSetsModulesArray[dependencyIndex];
|
||||
|
||||
|
||||
if (datasetModule.node.config.codeName !== "Single-File") {
|
||||
continue
|
||||
}
|
||||
@@ -302,10 +302,10 @@
|
||||
let filePath = datasetModule.node.parentNode.config.codeName + '/' + datasetModule.node.config.codeName;
|
||||
|
||||
/* We cut the async calls via callBacks at this point, so as to have a clearer code upstream */
|
||||
let response = await asyncGetDatasetFile(datasetModule, filePath, fileName)
|
||||
let response = await asyncGetDatasetFile(datasetModule, filePath, fileName)
|
||||
|
||||
if (response.err.result !== global.DEFAULT_OK_RESPONSE.result) {
|
||||
throw(response.err)
|
||||
throw (response.err)
|
||||
}
|
||||
|
||||
let dataFile = JSON.parse(response.text);
|
||||
@@ -351,12 +351,12 @@
|
||||
let filePath = dependency.referenceParent.parentNode.config.codeName + '/' + dependency.referenceParent.config.codeName + "/" + timeFrameLabel;
|
||||
|
||||
/* We cut the async calls via callBacks at this point, so as to have a clearer code upstream */
|
||||
let response = await asyncGetDatasetFile(datasetModule, filePath, fileName)
|
||||
let response = await asyncGetDatasetFile(datasetModule, filePath, fileName)
|
||||
|
||||
if (response.err.result !== global.DEFAULT_OK_RESPONSE.result) {
|
||||
throw(response.err)
|
||||
throw (response.err)
|
||||
}
|
||||
|
||||
|
||||
let dataFile = JSON.parse(response.text);
|
||||
let trimmedDataFile = trimDataFile(dataFile, datasetModule.node.parentNode.record)
|
||||
dataFiles.set(dependency.id, trimmedDataFile);
|
||||
@@ -402,7 +402,7 @@
|
||||
/* Telling the world we are alive and doing well and which date we are processing right now. */
|
||||
let processingDateString = tradingProcessDate.getUTCFullYear() + '-' + utilities.pad(tradingProcessDate.getUTCMonth() + 1, 2) + '-' + utilities.pad(tradingProcessDate.getUTCDate(), 2);
|
||||
bot.processHeartBeat(processingDateString)
|
||||
|
||||
|
||||
/*
|
||||
We will iterate through all posible timeFrames.
|
||||
*/
|
||||
@@ -456,10 +456,10 @@
|
||||
let fileName = "Data.json";
|
||||
|
||||
/* We cut the async calls via callBacks at this point, so as to have a clearer code upstream */
|
||||
let response = await asyncGetDatasetFile(datasetModule, filePath, fileName)
|
||||
|
||||
let response = await asyncGetDatasetFile(datasetModule, filePath, fileName)
|
||||
|
||||
if (response.err.result !== global.DEFAULT_OK_RESPONSE.result) {
|
||||
throw(response.err)
|
||||
throw (response.err)
|
||||
}
|
||||
|
||||
let dataFile = JSON.parse(response.text);
|
||||
@@ -471,7 +471,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
function checkStopHeadOfTheMarket() {
|
||||
function checkStopHeadOfTheMarket() {
|
||||
/*
|
||||
We need to check if we have reached the head of the market in order to know
|
||||
when to break the Daily Files Process loop and give time for a new candles /
|
||||
@@ -556,13 +556,13 @@
|
||||
currentTimeFrame,
|
||||
currentTimeFrameLabel,
|
||||
tradingProcessDate
|
||||
)
|
||||
)
|
||||
|
||||
/*
|
||||
From here on, all other loops executions wont be the first execution and also
|
||||
we will consider that it is not resuming a previous execution as well.
|
||||
*/
|
||||
bot.FIRST_EXECUTION = false
|
||||
bot.FIRST_EXECUTION = false
|
||||
bot.RESUME = false
|
||||
}
|
||||
|
||||
@@ -571,7 +571,7 @@
|
||||
|
||||
await writeTimeFramesFiles(currentTimeFrame, currentTimeFrameLabel)
|
||||
await writeDataRanges()
|
||||
|
||||
|
||||
if (currentTimeFrame > global.dailyFilePeriods[0][0]) {
|
||||
await writeMarketStatusReport(currentTimeFrameLabel)
|
||||
} else {
|
||||
@@ -580,30 +580,30 @@
|
||||
|
||||
async function writeDataRanges() {
|
||||
for (
|
||||
let outputDatasetIndex = 0;
|
||||
outputDatasetIndex < outputDatasets.length;
|
||||
outputDatasetIndex++
|
||||
) {
|
||||
let outputDatasetIndex = 0;
|
||||
outputDatasetIndex < outputDatasets.length;
|
||||
outputDatasetIndex++
|
||||
) {
|
||||
let productCodeName = outputDatasets[outputDatasetIndex].referenceParent.parentNode.config.codeName;
|
||||
await writeDataRange(productCodeName);
|
||||
}
|
||||
|
||||
|
||||
async function writeDataRange(productCodeName) {
|
||||
let dataRange = {
|
||||
begin: contextVariables.dateBeginOfMarket.valueOf(),
|
||||
end: tradingProcessDate.valueOf() + global.ONE_DAY_IN_MILISECONDS
|
||||
}
|
||||
|
||||
|
||||
let fileContent = JSON.stringify(dataRange);
|
||||
let fileName = '/Data.Range.json';
|
||||
let filePath = bot.filePathRoot + "/Output/" + bot.SESSION.folderName + "/" + productCodeName + "/" + 'Multi-Period-Daily' + fileName;
|
||||
|
||||
|
||||
let response = await fileStorage.asyncCreateTextFile(filePath, fileContent + '\n')
|
||||
|
||||
|
||||
if (response.err.result !== global.DEFAULT_OK_RESPONSE.result) {
|
||||
throw(response.err)
|
||||
throw (response.err)
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
Raise the event that the Data Range was Updated.
|
||||
*/
|
||||
@@ -611,59 +611,59 @@
|
||||
let event = {
|
||||
dateRange: dataRange
|
||||
}
|
||||
|
||||
|
||||
global.EVENT_SERVER_CLIENT.raiseEvent(key, 'Data Range Updated', event)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
async function writeTimeFramesFiles(currentTimeFrame, currentTimeFrameLabel) {
|
||||
|
||||
|
||||
for (
|
||||
let outputDatasetIndex = 0;
|
||||
outputDatasetIndex < outputDatasets.length;
|
||||
outputDatasetIndex++
|
||||
) {
|
||||
let outputDatasetIndex = 0;
|
||||
outputDatasetIndex < outputDatasets.length;
|
||||
outputDatasetIndex++
|
||||
) {
|
||||
let productCodeName = outputDatasets[outputDatasetIndex].referenceParent.parentNode.config.codeName;
|
||||
await writeTimeFramesFile( currentTimeFrameLabel, productCodeName, 'Multi-Period-Daily')
|
||||
await writeTimeFramesFile( currentTimeFrameLabel, productCodeName, 'Multi-Period-Market')
|
||||
|
||||
await writeTimeFramesFile(currentTimeFrameLabel, productCodeName, 'Multi-Period-Daily')
|
||||
await writeTimeFramesFile(currentTimeFrameLabel, productCodeName, 'Multi-Period-Market')
|
||||
|
||||
async function writeTimeFramesFile(currentTimeFrameLabel, productCodeName, processType) {
|
||||
|
||||
|
||||
let timeFramesArray = []
|
||||
timeFramesArray.push(currentTimeFrameLabel)
|
||||
|
||||
|
||||
let fileContent = JSON.stringify(timeFramesArray)
|
||||
let fileName = '/Time.Frames.json';
|
||||
|
||||
|
||||
let filePath = bot.filePathRoot + "/Output/" + bot.SESSION.folderName + "/" + productCodeName + "/" + processType + fileName;
|
||||
|
||||
|
||||
let response = await fileStorage.asyncCreateTextFile(filePath, fileContent + '\n')
|
||||
if (response.err.result !== global.DEFAULT_OK_RESPONSE.result) {
|
||||
throw(response.err)
|
||||
throw (response.err)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async function writeDailyStatusReport( currentTimeFrameLabel) {
|
||||
async function writeDailyStatusReport(currentTimeFrameLabel) {
|
||||
let reportKey = bot.dataMine + "-" + bot.codeName + "-" + bot.processNode.referenceParent.config.codeName
|
||||
let thisReport = statusDependencies.statusReports.get(reportKey)
|
||||
|
||||
|
||||
thisReport.file.lastExecution = bot.currentDaytime
|
||||
thisReport.file.lastFile = tradingProcessDate
|
||||
thisReport.file.simulationState = bot.simulationState
|
||||
thisReport.file.timeFrames = currentTimeFrameLabel
|
||||
await thisReport.asyncSave()
|
||||
}
|
||||
|
||||
|
||||
async function writeMarketStatusReport(currentTimeFrameLabel) {
|
||||
let reportKey = bot.dataMine + "-" + bot.codeName + "-" + bot.processNode.referenceParent.config.codeName
|
||||
let thisReport = statusDependencies.statusReports.get(reportKey);
|
||||
|
||||
|
||||
thisReport.file.lastExecution = bot.processDatetime
|
||||
thisReport.file.simulationState = bot.simulationState
|
||||
thisReport.file.timeFrames = currentTimeFrameLabel
|
||||
|
||||
|
||||
logger.newInternalLoop(bot.codeName, bot.process, tradingProcessDate)
|
||||
await thisReport.asyncSave()
|
||||
}
|
||||
@@ -675,6 +675,7 @@
|
||||
/*
|
||||
Backtests needs only one execution of this process to complete.
|
||||
*/
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, '[IMPORTANT] checkIfSessionMustStop -> Backtesting Session Finished. Stopping the Session now. ') }
|
||||
bot.SESSION.stop('Backtesting Session Finished.')
|
||||
}
|
||||
}
|
||||
@@ -714,14 +715,14 @@
|
||||
|
||||
datasetModule.getTextFile(filePath, fileName, onFileReceived);
|
||||
function onFileReceived(err, text) {
|
||||
|
||||
|
||||
let response = {
|
||||
err: err,
|
||||
text: text
|
||||
}
|
||||
resolve(response)
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
return promise
|
||||
}
|
||||
|
||||
@@ -229,7 +229,7 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, tradin
|
||||
|
||||
function checkIfWeNeedToStopAfterBothCycles() {
|
||||
if (checkNextCandle() === false) {
|
||||
updateEpisode('All Available Candles Processed')
|
||||
updateEpisode('All Candles Processed')
|
||||
breakLoop = true
|
||||
return
|
||||
}
|
||||
|
||||
@@ -54,7 +54,11 @@
|
||||
|
||||
function onSessionRan(message) {
|
||||
try {
|
||||
if (bot.SESSION_STATUS === 'Idle' || bot.SESSION_STATUS === 'Running') { return } // This happens when the UI is reloaded, the session was running and tries to run it again.
|
||||
/* This happens when the UI is reloaded, the session was running and tries to run it again. */
|
||||
if (bot.SESSION_STATUS === 'Idle' || bot.SESSION_STATUS === 'Running') {
|
||||
parentLogger.write(MODULE_NAME, "[WARN] onSessionRan -> Event receive to run the Session while it was already running. ")
|
||||
return
|
||||
}
|
||||
|
||||
/* We are going to run the Definition comming at the event. */
|
||||
bot.TRADING_SYSTEM = JSON.parse(message.event.tradingSystem)
|
||||
@@ -96,6 +100,7 @@
|
||||
bot.STOP_SESSION = false
|
||||
} else {
|
||||
bot.STOP_SESSION = true
|
||||
if (FULL_LOG === true) { parentLogger.write(MODULE_NAME, '[IMPORTANT] onSessionRan -> Stopping the Session now. ') }
|
||||
}
|
||||
|
||||
socialBotsModule.sendMessage(bot.SESSION.type + " '" + bot.SESSION.name + "' is starting.")
|
||||
@@ -109,10 +114,11 @@
|
||||
}
|
||||
|
||||
function stopSession(commandOrigin) {
|
||||
|
||||
|
||||
socialBotsModule.sendMessage(bot.SESSION.type + " '" + bot.SESSION.name + "' is stopping " + commandOrigin)
|
||||
socialBotsModule.finalize()
|
||||
bot.STOP_SESSION = true
|
||||
if (FULL_LOG === true) { parentLogger.write(MODULE_NAME, '[IMPORTANT] stopSession -> Stopping the Session now. ') }
|
||||
sessionInfo(bot.SESSION, commandOrigin)
|
||||
}
|
||||
|
||||
@@ -128,7 +134,7 @@
|
||||
if (config.folderName === undefined) {
|
||||
bot.SESSION.folderName = bot.processNode.session.type.replace(' ', '-').replace(' ', '-') + '-' + bot.SESSION.id
|
||||
} else {
|
||||
bot.SESSION.folderName = bot.processNode.session.type.replace(' ', '-').replace(' ', '-') + '-' + bot.processNode.session.config.folderName
|
||||
bot.SESSION.folderName = bot.processNode.session.type.replace(' ', '-').replace(' ', '-') + '-' + bot.processNode.session.config.folderName
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -159,14 +165,14 @@
|
||||
} else {
|
||||
/* Check that we received valid dates */
|
||||
if (bot.SESSION.type === 'Backtesting Session') {
|
||||
if(isNaN(new Date(bot.SESSION.parameters.timeRange.config.initialDatetime)).valueOf()) {
|
||||
if (isNaN(new Date(bot.SESSION.parameters.timeRange.config.initialDatetime)).valueOf()) {
|
||||
let errorMessage = "sessionParameters.timeRange.config.initialDatetime is not a valid date."
|
||||
parentLogger.write(MODULE_NAME, "[ERROR] initialize -> checkParemeters -> " + errorMessage)
|
||||
bot.sessionError(bot.SESSION.parameters, errorMessage)
|
||||
return false
|
||||
}
|
||||
}
|
||||
if(isNaN(new Date(bot.SESSION.parameters.timeRange.config.finalDatetime)).valueOf()) {
|
||||
if (isNaN(new Date(bot.SESSION.parameters.timeRange.config.finalDatetime)).valueOf()) {
|
||||
let errorMessage = "sessionParameters.timeRange.config.initialDatetime is not a valid date."
|
||||
parentLogger.write(MODULE_NAME, "[ERROR] initialize -> checkParemeters -> " + errorMessage)
|
||||
bot.sessionError(bot.SESSION.parameters, errorMessage)
|
||||
@@ -205,14 +211,14 @@
|
||||
|
||||
/* Initial Datetime */
|
||||
if (bot.SESSION.type === 'Backtesting Session') {
|
||||
if (bot.SESSION.parameters.timeRange.config.initialDatetime === undefined ) {
|
||||
if (bot.SESSION.parameters.timeRange.config.initialDatetime === undefined) {
|
||||
bot.SESSION.parameters.timeRange.config.initialDatetime = initialDefault
|
||||
} else {
|
||||
bot.SESSION.parameters.timeRange.config.initialDatetime = (new Date(bot.SESSION.parameters.timeRange.config.initialDatetime)).valueOf()
|
||||
}
|
||||
} else {
|
||||
/* Non backtest session can start from the past only if explicitly configured that way */
|
||||
if (bot.SESSION.parameters.timeRange.config.initialDatetime === undefined || bot.SESSION.parameters.timeRange.config.allowStartingFromThePast !== true ) {
|
||||
if (bot.SESSION.parameters.timeRange.config.initialDatetime === undefined || bot.SESSION.parameters.timeRange.config.allowStartingFromThePast !== true) {
|
||||
bot.SESSION.parameters.timeRange.config.initialDatetime = initialDefault
|
||||
} else {
|
||||
bot.SESSION.parameters.timeRange.config.initialDatetime = (new Date(bot.SESSION.parameters.timeRange.config.initialDatetime)).valueOf()
|
||||
@@ -393,6 +399,7 @@
|
||||
|
||||
if (global.STOP_TASK_GRACEFULLY === true) {
|
||||
bot.STOP_SESSION = true
|
||||
if (FULL_LOG === true) { parentLogger.write(MODULE_NAME, '[IMPORTANT] sessionHeartBeat -> Stopping the Session now. ') }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -414,6 +421,7 @@
|
||||
|
||||
if (global.STOP_TASK_GRACEFULLY === true) {
|
||||
bot.STOP_SESSION = true
|
||||
if (FULL_LOG === true) { parentLogger.write(MODULE_NAME, '[IMPORTANT] sessionError -> Stopping the Session now. ') }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -435,6 +443,7 @@
|
||||
|
||||
if (global.STOP_TASK_GRACEFULLY === true) {
|
||||
bot.STOP_SESSION = true
|
||||
if (FULL_LOG === true) { parentLogger.write(MODULE_NAME, '[IMPORTANT] sessionWarning -> Stopping the Session now. ') }
|
||||
}
|
||||
}
|
||||
|
||||
@@ -456,6 +465,7 @@
|
||||
|
||||
if (global.STOP_TASK_GRACEFULLY === true) {
|
||||
bot.STOP_SESSION = true
|
||||
if (FULL_LOG === true) { parentLogger.write(MODULE_NAME, '[IMPORTANT] sessionInfo -> Stopping the Session now. ') }
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -44,6 +44,7 @@
|
||||
/* Some initial values*/
|
||||
let fixedTimeLoopIntervalHandle;
|
||||
bot.STOP_SESSION = true;
|
||||
if (FULL_LOG === true) { parentLogger.write(MODULE_NAME, '[IMPORTANT] run -> Stopping the Session now. ') }
|
||||
|
||||
/* Heartbeats sent to the UI */
|
||||
bot.processHeartBeat = processHeartBeat
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
{"type":"Trading System","name":"BB Top Bounce (BTC/USDT) Beta 6 - Market","config":"{ \n\"codeName\": \"\"\n}","tradingStrategies":[{"type":"Trading Strategy","name":"S1 - 3H Down","triggerStage":{"type":"Trigger Stage","name":"New Trigger Stage","triggerOn":{"type":"Trigger On Event","name":"New Trigger On Event","situations":[{"type":"Situation","name":"New Situation","conditions":[{"type":"Condition","name":"Previous Breakup","javascriptCode":{"type":"Javascript Code","name":"New Javascript Code","code":"chart.at01hs.candle.previous.close > chart.at01hs.bollingerBand.previous.movingAverage + chart.at01hs.bollingerBand.previous.deviation","id":"99948a6e-e866-4339-86ba-eac367226312","savedPayload":{"position":{"x":32731.518164854635,"y":37190.36887098105},"targetPosition":{"x":33060.41970975256,"y":37269.656689137395},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"f0534c68-ab47-4370-b1fd-b3be4c1c262f","savedPayload":{"position":{"x":33060.41970975256,"y":37269.656689137395},"targetPosition":{"x":33387.63409912428,"y":37347.863570272166},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Condition","name":"Current Close In","javascriptCode":{"type":"Javascript Code","name":"New Javascript Code","code":"chart.at01hs.candle.close < chart.at01hs.bollingerBand.movingAverage + chart.at01hs.bollingerBand.deviation","id":"d3bd1690-1f94-484b-ac3c-7be2c7be85ed","savedPayload":{"position":{"x":32842.20246357981,"y":36950.68106756541},"targetPosition":{"x":33114.99571836738,"y":37149.45357431718},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"e2d7334d-cf52-44d9-a20e-5be201ca6799","savedPayload":{"position":{"x":33114.99571836738,"y":37149.45357431718},"targetPosition":{"x":33387.63409912428,"y":37347.863570272166},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Condition","name":"Current Red Candle","javascriptCode":{"type":"Javascript Code","name":"New Javascript Code","code":"chart.at01hs.candle.close < chart.at01hs.candle.open","id":"d1fa707f-eb75-4b1c-8117-688b9b94e539","savedPayload":{"position":{"x":33035.87192606493,"y":36771.32540679499},"targetPosition":{"x":33211.85742627204,"y":37059.584266077094},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"fb71bcfb-2a40-4e8a-b8e8-b492128350a0","savedPayload":{"position":{"x":33211.85742627204,"y":37059.584266077094},"targetPosition":{"x":33387.63409912428,"y":37347.863570272166},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Condition","name":"3H Down","code":"chart.at03hs.bollingerChannel.direction * chart.atAnyTimeFrame.externalSignal.timestamp > chart.atAnyTimeFrame.externalSignal.timestamp","javascriptCode":{"type":"Javascript Code","name":"New Javascript Code","code":"chart.at03hs.bollingerChannel.direction === \"Down\"","id":"8c8c5128-b88b-44a5-8e36-d5c61127404f","savedPayload":{"position":{"x":33284.128600701835,"y":36682.927951575584},"targetPosition":{"x":33335.998983874386,"y":37015.50846189238},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"22246178-a8f9-4ec8-b55b-36cf7a24fbff","savedPayload":{"position":{"x":33335.998983874386,"y":37015.50846189238},"targetPosition":{"x":33387.63409912428,"y":37347.863570272166},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Condition","name":"3H Medium, Steep or Extreme","javascriptCode":{"type":"Javascript Code","name":"New Javascript Code","code":"chart.at03hs.bollingerSubChannel.slope === \"Medium\" || chart.at03hs.bollingerSubChannel.slope === \"Steep\" || chart.at03hs.bollingerSubChannel.slope === \"Extreme\" ","id":"bf8df41c-c62f-4cd6-840e-1dd538359c3b","savedPayload":{"position":{"x":33546.11930569506,"y":36691.780308464346},"targetPosition":{"x":33467.032289939845,"y":37020.43149244697},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{}}},"id":"9dba774d-1afa-40dd-b5ec-8f4029824473","savedPayload":{"position":{"x":33467.032289939845,"y":37020.43149244697},"targetPosition":{"x":33387.63409912428,"y":37347.863570272166},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParLine truncated
|
||||
@@ -0,0 +1 @@
|
||||
{"type":"Trading System","name":"WHB v.2 (BTC/USDT) Beta 6 - Market","config":"{ \n\"codeName\": \"Sparta-WHB-BTC-USDT\"\n}","tradingStrategies":[{"type":"Trading Strategy","name":"Steep","triggerStage":{"type":"Trigger Stage","triggerOn":{"type":"Trigger On Event","situations":[{"type":"Situation","name":"Steep","conditions":[{"type":"Condition","name":"3 Closes Below MA","javascriptCode":{"type":"Javascript Code","code":"chart.at01hs.candle.close < chart.at01hs.bollingerBand.movingAverage && \nchart.at01hs.candle.previous.close < chart.at01hs.bollingerBand.previous.movingAverage && \nchart.at01hs.candle.previous.previous.close < chart.at01hs.bollingerBand.previous.previous.movingAverage","id":"123b1af6-9639-4b6d-a4c3-7a8a9287169c","savedPayload":{"position":{"x":40169.8075224048,"y":37093.86229409448},"targetPosition":{"x":40354.74975544049,"y":37129.84758930669},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":2,"arrangementStyle":0},"uiObject":{}}},"id":"427da1e1-cc4a-4c78-88f6-c254d87cc88f","savedPayload":{"position":{"x":40354.74975544049,"y":37129.84758930669},"targetPosition":{"x":40723.50848675032,"y":37201.25051694716},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Condition","name":"Breakdown","javascriptCode":{"type":"Javascript Code","code":"chart.at01hs.candle.close < chart.at01hs.bollingerBand.movingAverage - chart.at01hs.bollingerBand.deviation","id":"1b9e755e-eefe-4b0d-addd-1e19b6a597b6","savedPayload":{"position":{"x":40240.154834427885,"y":36910.53675762087},"targetPosition":{"x":40401.568336372424,"y":37007.49315306863},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":2,"arrangementStyle":0},"uiObject":{}}},"id":"55bf7721-7fb2-42f0-8a3c-c2b97e278a29","savedPayload":{"position":{"x":40401.568336372424,"y":37007.49315306863},"targetPosition":{"x":40723.50848675032,"y":37201.25051694716},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Condition","name":"2H Down","javascriptCode":{"type":"Javascript Code","code":"chart.at02hs.bollingerChannel.direction === \"Down\"","id":"e8db5fac-2f00-47fe-ac57-dc93ad15f2b5","savedPayload":{"position":{"x":40368.55178313948,"y":36762.30864654639},"targetPosition":{"x":40487.11436226741,"y":36909.035629578386},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":2,"arrangementStyle":0},"uiObject":{}}},"id":"11e00b31-e7eb-4fe9-b006-dcd640dbbd3b","savedPayload":{"position":{"x":40487.11436226741,"y":36909.035629578386},"targetPosition":{"x":40723.50848675032,"y":37201.25051694716},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Condition","name":"Deviation > 200","javascriptCode":{"type":"Javascript Code","code":"chart.at01hs.bollingerBand.deviation > 200","id":"7671ca91-4b4c-40c5-b0c2-199169b013e8","savedPayload":{"position":{"x":40540.24271052489,"y":36667.14433492657},"targetPosition":{"x":40601.502104536274,"y":36845.41065742939},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":2,"arrangementStyle":0},"uiObject":{}}},"id":"dd938286-61b3-41e4-bfbb-db34971ffa47","savedPayload":{"position":{"x":40601.502104536274,"y":36845.41065742939},"targetPosition":{"x":40723.50848675032,"y":37201.25051694716},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Condition","name":"Candle Size < 750","javascriptCode":{"type":"Javascript Code","code":"chart.at01hs.candle.max - chart.at01hs.candle.min < 750","id":"19b7edeb-b180-429f-9adf-61bf47262033","savedPayload":{"position":{"x":40733.77112610069,"y":36636.82425336213},"targetPosition":{"x":40730.21857900794,"y":36825.10082784779},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":1,"distanceToParent":2,"arrangementStyle":0},"uiObject":{}}},"id":"8f94ab97-1574-4136-9404-b66dfc1e3b9f","savedPayload":{"position":{"x":40730.21857900794,"y":36825.10082784779},"targetPosition":{"x":40723.50848675032,"y":37201.25051694716},"floatingObject":{"isPinned":false,"isFrozen":false,"isCollapsed":false,"angleToParent":2,"distanceToParent":3,"arrangementStyle":0},"uiObject":{"isRunning":false}}},{"type":"Condition","name":"Deviation < 1000","javascriptCode":{"type":"Javascript Code","code":"chart.at01hs.bollingerBand.deviation < 1000","id":"0aa38939-f2ef-4c2b-bfc1-a45bda2ac50e","savedPayload":{"position":{"x":40925.414106257434,"y":36674.27233109751},"targetPosition":{"x":4Line truncated
|
||||