Trading Systems included

This commit is contained in:
Luis Fernando Molina committed 2020-03-29 17:29:36 +02:00
1 parent ceea65e633
commit 3ce664c31b
2 files changed
+87 -15

No files matched your search

@@ -25,35 +25,89 @@ function newUiObjectsFromNodes () {
blobService = newFileStorage()
if (node.code === undefined) {
node.code = '{ \n"includeDataMines": ["Masters", "Sparta", "TradingEngines"]\n}'
node.code = '{ \n"includeDataMines": ["Masters", "Sparta", "TradingEngines"],\n"includeTradingSystems": ["WHB-BTC-USDT", "WHB-ETH-USDT", "BRR-BTC-USDT"],\n"includeSuperScripts": ["Superalgos"]\n }'
}
let code = JSON.parse(node.code)
let includeDataMines = code.includeDataMines
let includeTradingSystems = code.includeTradingSystems
let includeSuperScripts = code.includeSuperScripts
let totalIncluded = 0
for (let i = 0; i < includeDataMines.length; i++) {
let dataMine = includeDataMines[i]
blobService.getBlobToText('DataMines' + '/' + dataMine, undefined, onFileReceived, true)
let name = includeDataMines[i]
blobService.getBlobToText('DataMines' + '/' + name, undefined, onFileReceived, true)
function onFileReceived (err, text, response) {
if (err && err.result !== GLOBAL.DEFAULT_OK_RESPONSE.result) {
console.log('Cannot load included Data Mine ' + dataMine + '. The workspace can not be loaded.')
console.log('Cannot load included Data Mine ' + name + '. The workspace can not be loaded.')
return
}
let includedDataMine = JSON.parse(text)
let receivedNode = JSON.parse(text)
for (let i = 0; i < node.rootNodes.length; i++) {
let rootNode = node.rootNodes[i]
if (rootNode.type === 'Data Mine') {
let code = JSON.parse(rootNode.code)
if (code.name === dataMine) {
if (code.name === name) {
rootNodes.splice(i, 1)
}
}
}
node.rootNodes.push(includedDataMine)
node.rootNodes.push(receivedNode)
totalIncluded++
if (totalIncluded === includeDataMines.length) {
if (totalIncluded === includeDataMines.length + includeTradingSystems.length + includeSuperScripts.length) {
addUserDefinedNodes()
}
}
}
for (let i = 0; i < includeTradingSystems.length; i++) {
let name = includeTradingSystems[i]
blobService.getBlobToText('TradingSystems' + '/' + name, undefined, 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.')
return
}
let receivedNode = JSON.parse(text)
for (let i = 0; i < node.rootNodes.length; i++) {
let rootNode = node.rootNodes[i]
if (rootNode.type === 'Trading System') {
let code = JSON.parse(rootNode.code)
if (code.name === name) {
rootNodes.splice(i, 1)
}
}
}
node.rootNodes.push(receivedNode)
totalIncluded++
if (totalIncluded === includeDataMines.length + includeTradingSystems.length + includeSuperScripts.length) {
addUserDefinedNodes()
}
}
}
for (let i = 0; i < includeSuperScripts.length; i++) {
let name = includeSuperScripts[i]
blobService.getBlobToText('SuperScripts' + '/' + name, undefined, 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.')
return
}
let receivedNode = JSON.parse(text)
for (let i = 0; i < node.rootNodes.length; i++) {
let rootNode = node.rootNodes[i]
if (rootNode.type === 'Super Scripts') {
let code = JSON.parse(rootNode.code)
if (code.name === name) {
rootNodes.splice(i, 1)
}
}
}
node.rootNodes.push(receivedNode)
totalIncluded++
if (totalIncluded === includeDataMines.length + includeTradingSystems.length + includeSuperScripts.length) {
addUserDefinedNodes()
}
}
+25 -7
View File
@@ -171,23 +171,41 @@ function newWorkspace () {
function stringifyWorkspace (removePersonalData) {
let code
if (thisObject.workspaceNode.code === undefined) {
thisObject.workspaceNode.code = '{ \n"includeDataMines": ["Masters", "Sparta", "TradingEngines"]\n}'
thisObject.workspaceNode.code = '{ \n"includeDataMines": ["Masters", "Sparta", "TradingEngines"],\n"includeTradingSystems": ["WHB-BTC-USDT", "WHB-ETH-USDT", "BRR-BTC-USDT"],\n"includeSuperScripts": ["Superalgos"]\n }'
}
code = JSON.parse(thisObject.workspaceNode.code)
let includeDataMines = code.includeDataMines
let includeTradingSystems = code.includeTradingSystems
let includeSuperScripts = code.includeSuperScripts
let stringifyReadyNodes = []
for (let i = 0; i < thisObject.workspaceNode.rootNodes.length; i++) {
let rootNode = thisObject.workspaceNode.rootNodes[i]
let node = functionLibraryProtocolNode.getProtocolNode(rootNode, removePersonalData, false, true, true, true)
if (node) {
if (node.type !== 'Data Mine') {
stringifyReadyNodes.push(node)
} else {
code = JSON.parse(node.code)
if (includeDataMines.includes(code.codeName) === false) {
stringifyReadyNodes.push(node)
switch (node.type) {
case 'Data Mine': {
code = JSON.parse(node.code)
if (includeDataMines.includes(code.codeName) === false) {
stringifyReadyNodes.push(node)
}
break
}
case 'Trading System': {
code = JSON.parse(node.code)
if (includeTradingSystems.includes(code.codeName) === false) {
stringifyReadyNodes.push(node)
}
break
}
case 'Super Scripts': {
code = JSON.parse(node.code)
if (includeSuperScripts.includes(code.codeName) === false) {
stringifyReadyNodes.push(node)
}
break
}
default: stringifyReadyNodes.push(node)
}
}
}