Refactoring remaining sensor, indicator and tradingengine stuff
This commit is contained in:
1 parent
6baa267f2a
commit
d419d91e6d
5 files changed
+37
-37
No files matched your search
@@ -278,16 +278,16 @@ function newProductsPanel () {
|
||||
}
|
||||
|
||||
/* Then we get an Array of all instances of this bot placed at Definitions on the Workspace. */
|
||||
let tradingEngineInstances = canvas.strategySpace.workspace.getAllTradingEngines()
|
||||
let tradingBotInstances = canvas.strategySpace.workspace.getAllTradingBotInstances()
|
||||
|
||||
/* Here we will go through all the instances of trading engines and see their layers, to see
|
||||
if we can find a matching layer. */
|
||||
|
||||
for (let n = 0; n < tradingEngineInstances.length; n++) {
|
||||
let tradingEngine = tradingEngineInstances[n]
|
||||
for (let n = 0; n < tradingBotInstances.length; n++) {
|
||||
let tradingBotInstance = tradingBotInstances[n]
|
||||
let code
|
||||
try {
|
||||
code = JSON.parse(tradingEngine.code)
|
||||
code = JSON.parse(tradingBotInstance.code)
|
||||
} catch (err) {
|
||||
// if we can not parse this, then we ignore this trading engine.
|
||||
}
|
||||
@@ -303,8 +303,8 @@ function newProductsPanel () {
|
||||
/* We found an instance of the same Trading Engine we are currently looking at.
|
||||
Next thing to do is to see its layers to see if we can match it with the current product. */
|
||||
|
||||
for (let m = 0; m < tradingEngine.processes.length; m++) {
|
||||
let process = tradingEngine.processes[m]
|
||||
for (let m = 0; m < tradingBotInstance.processes.length; m++) {
|
||||
let process = tradingBotInstance.processes[m]
|
||||
if (process.session !== undefined) {
|
||||
if (process.session.layerManager !== undefined) {
|
||||
let layerManager = process.session.layerManager
|
||||
|
||||
@@ -39,13 +39,13 @@ function newNodeChildren () {
|
||||
return countChildrenTask(parentNode, childNode)
|
||||
}
|
||||
case 'Sensor Bot Instance': {
|
||||
return countChildrenSensor(parentNode, childNode)
|
||||
return countChildrenSensorBotInstance(parentNode, childNode)
|
||||
}
|
||||
case 'Indicator Bot Instance': {
|
||||
return countChildrenIndicator(parentNode, childNode)
|
||||
return countChildrenIndicatorBotInstance(parentNode, childNode)
|
||||
}
|
||||
case 'Trading Bot Instance': {
|
||||
return countChildrenTradingEngine(parentNode, childNode)
|
||||
return countChildrenTradingBotInstance(parentNode, childNode)
|
||||
}
|
||||
case 'Process': {
|
||||
return countChildrenProcess(parentNode, childNode)
|
||||
@@ -324,7 +324,7 @@ function newNodeChildren () {
|
||||
return response
|
||||
}
|
||||
|
||||
function countChildrenSensor (parentNode, childNode) {
|
||||
function countChildrenSensorBotInstance (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
@@ -340,7 +340,7 @@ function newNodeChildren () {
|
||||
return response
|
||||
}
|
||||
|
||||
function countChildrenIndicator (parentNode, childNode) {
|
||||
function countChildrenIndicatorBotInstance (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
@@ -356,7 +356,7 @@ function newNodeChildren () {
|
||||
return response
|
||||
}
|
||||
|
||||
function countChildrenTradingEngine (parentNode, childNode) {
|
||||
function countChildrenTradingBotInstance (parentNode, childNode) {
|
||||
let response = {
|
||||
childrenCount: 0,
|
||||
childIndex: undefined
|
||||
|
||||
@@ -10,9 +10,9 @@ function newNodeDeleter () {
|
||||
deleteLayer: deleteLayer,
|
||||
deleteTaskManager: deleteTaskManager,
|
||||
deleteTask: deleteTask,
|
||||
deleteSensor: deleteBot,
|
||||
deleteIndicator: deleteBot,
|
||||
deleteTradingEngine: deleteBot,
|
||||
deleteSensorBotInstance: deleteBotInstance,
|
||||
deleteIndicatorBotInstance: deleteBotInstance,
|
||||
deleteTradingBotInstance: deleteBotInstance,
|
||||
deleteProcess: deleteProcess,
|
||||
deletePersonalData: deletePersonalData,
|
||||
deleteExchangeAccount: deleteExchangeAccount,
|
||||
@@ -102,15 +102,15 @@ function newNodeDeleter () {
|
||||
break
|
||||
}
|
||||
case 'Sensor Bot Instance': {
|
||||
deleteBot(rootNode, rootNodes)
|
||||
deleteBotInstance(rootNode, rootNodes)
|
||||
break
|
||||
}
|
||||
case 'Indicator Bot Instance': {
|
||||
deleteBot(rootNode, rootNodes)
|
||||
deleteBotInstance(rootNode, rootNodes)
|
||||
break
|
||||
}
|
||||
case 'Trading Bot Instance': {
|
||||
deleteBot(rootNode, rootNodes)
|
||||
deleteBotInstance(rootNode, rootNodes)
|
||||
break
|
||||
}
|
||||
case 'Process': {
|
||||
@@ -455,14 +455,14 @@ function newNodeDeleter () {
|
||||
}
|
||||
}
|
||||
if (node.bot !== undefined) {
|
||||
deleteBot(node.bot, rootNodes)
|
||||
deleteBotInstance(node.bot, rootNodes)
|
||||
}
|
||||
completeDeletion(node, rootNodes)
|
||||
destroyPart(node)
|
||||
cleanNode(node)
|
||||
}
|
||||
|
||||
function deleteBot (node, rootNodes) {
|
||||
function deleteBotInstance (node, rootNodes) {
|
||||
let payload = node.payload
|
||||
if (payload.parentNode !== undefined) {
|
||||
payload.parentNode.bot = undefined
|
||||
|
||||
@@ -11,9 +11,9 @@ function newPartsFromNodes () {
|
||||
addLayer: addLayer,
|
||||
addTaskManager: addTaskManager,
|
||||
addTask: addTask,
|
||||
addSensor: addSensor,
|
||||
addIndicator: addIndicator,
|
||||
addTradingEngine: addTradingEngine,
|
||||
addSensorBotInstance: addSensorBotInstance,
|
||||
addIndicatorBotInstance: addIndicatorBotInstance,
|
||||
addTradingBotInstance: addTradingBotInstance,
|
||||
addProcess: addProcess,
|
||||
addBacktestingSession: addBacktestingSession,
|
||||
addLiveTradingSession: addLiveTradingSession,
|
||||
@@ -673,7 +673,7 @@ function newPartsFromNodes () {
|
||||
return task
|
||||
}
|
||||
|
||||
function addSensor (node) {
|
||||
function addSensorBotInstance (node) {
|
||||
if (node.bot === undefined) {
|
||||
node.bot = {
|
||||
processes: [],
|
||||
@@ -684,7 +684,7 @@ function newPartsFromNodes () {
|
||||
return node.bot
|
||||
}
|
||||
|
||||
function addIndicator (node) {
|
||||
function addIndicatorBotInstance (node) {
|
||||
if (node.bot === undefined) {
|
||||
node.bot = {
|
||||
processes: [],
|
||||
@@ -695,7 +695,7 @@ function newPartsFromNodes () {
|
||||
return node.bot
|
||||
}
|
||||
|
||||
function addTradingEngine (node) {
|
||||
function addTradingBotInstance (node) {
|
||||
if (node.bot === undefined) {
|
||||
node.bot = {
|
||||
processes: [],
|
||||
|
||||
@@ -13,7 +13,7 @@ function newWorkspace () {
|
||||
nodeChildren: undefined,
|
||||
getNodeThatIsOnFocus: getNodeThatIsOnFocus,
|
||||
getNodeByShortcutKey: getNodeByShortcutKey,
|
||||
getAllTradingEngines: getAllTradingEngines,
|
||||
getAllTradingBotInstances: getAllTradingBotInstances,
|
||||
stopAllRunningTasks: stopAllRunningTasks,
|
||||
onMenuItemClick: onMenuItemClick,
|
||||
physics: physics,
|
||||
@@ -165,8 +165,8 @@ function newWorkspace () {
|
||||
}
|
||||
}
|
||||
|
||||
function getAllTradingEngines () {
|
||||
let tradingEngines = []
|
||||
function getAllTradingBotInstances () {
|
||||
let tradingBotInstances = []
|
||||
for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) {
|
||||
let rootNode = thisObject.workspaceNode.rootNodes[i]
|
||||
if (rootNode.type === 'Definition') {
|
||||
@@ -180,7 +180,7 @@ function newWorkspace () {
|
||||
for (k = 0; k < taskManager.tasks.length; k++) {
|
||||
let task = taskManager.tasks[k]
|
||||
if (task.bot.type === 'Trading Bot Instance') {
|
||||
tradingEngines.push(task.bot)
|
||||
tradingBotInstances.push(task.bot)
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -189,7 +189,7 @@ function newWorkspace () {
|
||||
}
|
||||
}
|
||||
}
|
||||
return tradingEngines
|
||||
return tradingBotInstances
|
||||
}
|
||||
|
||||
function getNodeByShortcutKey (searchingKey) {
|
||||
@@ -366,17 +366,17 @@ function newWorkspace () {
|
||||
break
|
||||
case 'Add Sensor Bot Instance':
|
||||
{
|
||||
functionLibraryPartsFromNodes.addSensor(payload.node)
|
||||
functionLibraryPartsFromNodes.addSensorBotInstance(payload.node)
|
||||
}
|
||||
break
|
||||
case 'Add Indicator Bot Instance':
|
||||
{
|
||||
functionLibraryPartsFromNodes.addIndicator(payload.node)
|
||||
functionLibraryPartsFromNodes.addIndicatorBotInstance(payload.node)
|
||||
}
|
||||
break
|
||||
case 'Add Trading Bot Instance':
|
||||
{
|
||||
functionLibraryPartsFromNodes.addTradingEngine(payload.node)
|
||||
functionLibraryPartsFromNodes.addTradingBotInstance(payload.node)
|
||||
}
|
||||
break
|
||||
case 'Add Process':
|
||||
@@ -541,15 +541,15 @@ function newWorkspace () {
|
||||
break
|
||||
}
|
||||
case 'Delete Sensor Bot Instance': {
|
||||
functionLibraryNodeDeleter.deleteSensor(payload.node, thisObject.workspaceNode.rootNodes)
|
||||
functionLibraryNodeDeleter.deleteSensorBotInstance(payload.node, thisObject.workspaceNode.rootNodes)
|
||||
break
|
||||
}
|
||||
case 'Delete Indicator Bot Instance': {
|
||||
functionLibraryNodeDeleter.deleteIndicator(payload.node, thisObject.workspaceNode.rootNodes)
|
||||
functionLibraryNodeDeleter.deleteIndicatorBotInstance(payload.node, thisObject.workspaceNode.rootNodes)
|
||||
break
|
||||
}
|
||||
case 'Delete Trading Bot Instance': {
|
||||
functionLibraryNodeDeleter.deleteTradingEngine(payload.node, thisObject.workspaceNode.rootNodes)
|
||||
functionLibraryNodeDeleter.deleteTradingBotInstance(payload.node, thisObject.workspaceNode.rootNodes)
|
||||
break
|
||||
}
|
||||
case 'Delete Process': {
|
||||
|
||||
Reference in new issue
Block a user