Dependency Filters
This commit is contained in:
1 parent
3482139b77
commit
0239c2250c
3 files changed
+81
-3
No files matched your search
@@ -0,0 +1,74 @@
|
||||
function newDependenciesFilter () {
|
||||
thisObject = {
|
||||
createFilter: createFilter
|
||||
}
|
||||
|
||||
return thisObject
|
||||
|
||||
function createFilter (node) {
|
||||
let filters = new Map()
|
||||
recursiveFilter(node)
|
||||
|
||||
return Array.from(filters.keys())
|
||||
|
||||
function recursiveFilter (node) {
|
||||
filter(node.code)
|
||||
|
||||
let nodeDefinition = APP_SCHEMA_MAP.get(node.type)
|
||||
if (nodeDefinition !== undefined) {
|
||||
if (nodeDefinition.properties !== undefined) {
|
||||
let previousPropertyName // Since there are cases where there are many properties with the same name,because they can hold nodes of different types but only one at the time, we have to avoind counting each property of those as individual children.
|
||||
for (let i = 0; i < nodeDefinition.properties.length; i++) {
|
||||
let property = nodeDefinition.properties[i]
|
||||
|
||||
switch (property.type) {
|
||||
case 'node': {
|
||||
if (property.name !== previousPropertyName) {
|
||||
if (node[property.name] !== undefined) {
|
||||
recursiveFilter(node[property.name])
|
||||
}
|
||||
previousPropertyName = property.name
|
||||
}
|
||||
}
|
||||
break
|
||||
case 'array': {
|
||||
let nodePropertyArray = node[property.name]
|
||||
if (nodePropertyArray !== undefined) {
|
||||
for (let j = 0; j < nodePropertyArray.length; j++) {
|
||||
let nodeProperty = nodePropertyArray[j]
|
||||
recursiveFilter(nodeProperty)
|
||||
}
|
||||
}
|
||||
}
|
||||
break
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function filter (code) {
|
||||
if (code === undefined) { return }
|
||||
|
||||
let instructionsArray = code.split(' ')
|
||||
for (let i = 0; i < instructionsArray.length; i++) {
|
||||
let instruction = instructionsArray[i]
|
||||
if (instruction.indexOf('chart') >= 0) {
|
||||
let parts = instruction.split('.')
|
||||
let timeFrame = parts[1]
|
||||
let product = parts[2]
|
||||
let productParts = product.split(',')
|
||||
product = productParts[0]
|
||||
productParts = product.split(')')
|
||||
product = productParts[0]
|
||||
|
||||
// Example: chart.at01hs.popularSMA.sma200 - chart.at01hs.popularSMA.sma100 < 10
|
||||
if (timeFrame !== 'atAnyTimeFrame') {
|
||||
timeFrame = timeFrame.substring(2, 4) + '-' + timeFrame.substring(4, 7)
|
||||
}
|
||||
filters.set(timeFrame + '-' + product, true)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -6,7 +6,7 @@ function newSessionFunctions () {
|
||||
|
||||
return thisObject
|
||||
|
||||
function runSession (node, functionLibraryProtocolNode, callBackFunction) {
|
||||
function runSession (node, functionLibraryProtocolNode, functionLibraryDependenciesFilter, callBackFunction) {
|
||||
/* We can not run a sessionif its parent process is not running. Less if it does not have a parent. */
|
||||
if (node.payload.parentNode === undefined) {
|
||||
node.payload.uiObject.setErrorMessage('Session needs a Process Instance parent to be able to run.')
|
||||
@@ -59,10 +59,13 @@ function newSessionFunctions () {
|
||||
|
||||
let session = functionLibraryProtocolNode.getProtocolNode(node, false, true, true, false, false, lightingPath)
|
||||
|
||||
let dependencyFilter = functionLibraryDependenciesFilter.createFilter(node.payload.referenceParent)
|
||||
|
||||
/* Raise event to run the session */
|
||||
let event = {
|
||||
session: JSON.stringify(session),
|
||||
tradingSystem: JSON.stringify(tradingSystem)
|
||||
tradingSystem: JSON.stringify(tradingSystem),
|
||||
dependencyFilter: JSON.stringify(dependencyFilter)
|
||||
}
|
||||
|
||||
eventsServerClient.raiseEvent(key, 'Run Session', event)
|
||||
|
||||
@@ -60,6 +60,7 @@ function newWorkspace () {
|
||||
let functionLibrarySuperScripts = newSuperScriptsFunctions()
|
||||
let functionLibraryCCXTFunctions = newCCXTFunctions()
|
||||
let functionLibraryWebhookFunctions = newWebhookFunctions()
|
||||
let functionLibraryDependenciesFilter = newDependenciesFilter()
|
||||
|
||||
thisObject.nodeChildren = newNodeChildren()
|
||||
|
||||
@@ -420,7 +421,7 @@ function newWorkspace () {
|
||||
break
|
||||
case 'Run Session':
|
||||
{
|
||||
functionLibrarySessionFunctions.runSession(payload.node, functionLibraryProtocolNode, callBackFunction)
|
||||
functionLibrarySessionFunctions.runSession(payload.node, functionLibraryProtocolNode, functionLibraryDependenciesFilter, callBackFunction)
|
||||
}
|
||||
break
|
||||
case 'Stop Session':
|
||||
|
||||
Reference in new issue
Block a user