Dependency Filer at the UI expanded to include the market and exchange data structures

This commit is contained in:
Luis Fernando Molina committed 2021-02-01 16:06:56 +01:00
1 parent 4432244041
commit ea092fa6e5
3 files changed
+85 -16

No files matched your search

+1 -1
View File
@@ -11580,7 +11580,7 @@
},
"level": 4,
"attachingRules": {
"compatibleTypes": "->Target Size In Base Asset->Target Size In Quoted Asset->Target Rate->Phase->Simulated Actual Rate->Situation->Indicator Function->"
"compatibleTypes": "->Target Size In Base Asset->Target Size In Quoted Asset->Target Rate->Phase->Simulated Actual Rate->Situation->Indicator Function->Order Rate->"
},
"propertyNameAtParent": "formula"
},
@@ -20,6 +20,7 @@
const MODULE_NAME = "Data Dependencies";
let thisObject = {
filters: undefined,
curatedNodeArray: undefined,
dataSetsModulesArray: [],
isItADepenency: isItADepenency,
@@ -27,7 +28,20 @@
finalize: finalize
};
let filter = new Map()
thisObject.filters = {
chart: {
list: new Map(),
products: new Map()
},
market: {
list: new Map(),
products: new Map()
},
exchange: {
list: new Map(),
products: new Map()
}
}
return thisObject;
@@ -60,19 +74,47 @@
if (thisObject.curatedNodeArray.length === 0) {
// We allow old indicators not to declare their data dependencies.
callBackFunction(TS.projects.superalgos.globals.standardResponses.DEFAULT_OK_RESPONSE);
return;
}
/* Session based dependency filters */
if (TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).DEPENDENCY_FILTER !== undefined) {
for (let i = 0; i < TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).DEPENDENCY_FILTER.length; i++) {
let key = TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).DEPENDENCY_FILTER[i]
filter.set(key, true)
/* Session based dependency thisObject.filters */
let dependencyFilter = TS.projects.superalgos.globals.processConstants.CONSTANTS_BY_PROCESS_INDEX_MAP.get(processIndex).DEPENDENCY_FILTER
if (dependencyFilter !== undefined) {
/*
Javascript Maps can not travel stringified at ta JSON object, so we receive
these maps in an Array format, and here we will just convert them to Maps,
that is how we need them.
*/
arrayToMap(dependencyFilter.chart.list, thisObject.filters.chart.list)
arrayToMap(dependencyFilter.chart.products, thisObject.filters.chart.products)
arrayToMap(dependencyFilter.market.list, thisObject.filters.market.list)
arrayToMap(dependencyFilter.market.products, thisObject.filters.market.products)
arrayToMap(dependencyFilter.exchange.list, thisObject.filters.exchange.list)
arrayToMap(dependencyFilter.exchange.products, thisObject.filters.exchange.products)
function arrayToMap(array, map) {
for (let i = 0; i < array.length; i++) {
let key = array[i]
map.set(key, true)
}
}
}
/*
At our filter structure, we will add the Task default exchange and market.
This will help us lateer to build other structures in a generic way.
*/
thisObject.filters.exchange.list.set(
TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.parentNode.parentNode.config.codeName
)
thisObject.filters.market.list.set(
TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.baseAsset.referenceParent.config.codeName +
"-" +
TS.projects.superalgos.globals.taskConstants.TASK_NODE.parentNode.parentNode.parentNode.referenceParent.quotedAsset.referenceParent.config.codeName
)
/*
For each dependency declared at the curatedNodeArray, we will initialize a DataSet as part of this initialization process.
*/
@@ -145,13 +187,14 @@
dataSetModule.finalize()
}
thisObject.dataSetsModulesArray = undefined
filter = undefined
thisObject.curatedNodeArray = undefined
thisObject.filters = undefined
bot = undefined
}
function isItADepenency(timeFrame, product) {
let key = timeFrame + '-' + product
return filter.get(key)
return thisObject.filters.get(key)
}
};
@@ -19,10 +19,33 @@ function newSuperalgosFunctionLibraryDependenciesFilter() {
return thisObject
function createDependencyFilter(node) {
let filters = new Map()
let filters = {
chart: {
list: new Map(),
products: new Map()
},
market: {
list: new Map(),
products: new Map()
},
exchange: {
list: new Map(),
products: new Map()
}
}
recursiveFilter(node)
return Array.from(filters.keys())
/* Transform the Map into arrays */
filters.chart.list = Array.from(filters.chart.list.keys())
filters.chart.products = Array.from(filters.chart.products.keys())
filters.market.list = Array.from(filters.market.list.keys())
filters.market.products = Array.from(filters.market.products.keys())
filters.exchange.list = Array.from(filters.exchange.list.keys())
filters.exchange.products = Array.from(filters.exchange.products.keys())
return filters
function recursiveFilter(node) {
if (node.type === 'Javascript Code' || node.type === 'Formula') {
@@ -99,7 +122,8 @@ function newSuperalgosFunctionLibraryDependenciesFilter() {
if (timeFrame !== 'atAnyTimeFrame') {
timeFrame = timeFrame.substring(2, 4) + '-' + timeFrame.substring(4, 7)
}
filters.set(timeFrame + '-' + product, true)
filters.chart.products.set(timeFrame + '-' + product, true)
filters.chart.list.set(timeFrame, true)
}
/*
The second kind of instruction we will handle are the ones
@@ -118,7 +142,8 @@ function newSuperalgosFunctionLibraryDependenciesFilter() {
if (timeFrame !== 'atAnyTimeFrame') {
timeFrame = timeFrame.substring(2, 4) + '-' + timeFrame.substring(4, 7)
}
filters.set(baseAsset + '-' + quotedAsset + '-' + timeFrame + '-' + product, true)
filters.market.products.set(baseAsset + '-' + quotedAsset + '-' + timeFrame + '-' + product, true)
filters.market.list.set(baseAsset + '-' + quotedAsset, true)
}
/*
The third kind of instruction we will handle are the ones
@@ -138,7 +163,8 @@ function newSuperalgosFunctionLibraryDependenciesFilter() {
if (timeFrame !== 'atAnyTimeFrame') {
timeFrame = timeFrame.substring(2, 4) + '-' + timeFrame.substring(4, 7)
}
filters.set(exchange + '-' + baseAsset + '-' + quotedAsset + '-' + timeFrame + '-' + product, true)
filters.exchange.products.set(exchange + '-' + baseAsset + '-' + quotedAsset + '-' + timeFrame + '-' + product, true)
filters.exchange.list.set(exchange, true)
}
}
}