hightlights and values working
This commit is contained in:
1 parent
fb3cdde61a
commit
83da1c32aa
3 files changed
+48
-35
No files matched your search
@@ -106,15 +106,26 @@ exports.newTradingRecords = function newTradingRecords(bot, logger) {
|
||||
*/
|
||||
let value
|
||||
if (targetNode !== undefined) {
|
||||
value = targetNode.value
|
||||
}
|
||||
|
||||
value = safeValue(value)
|
||||
if (recordProperty.config.isString === true) {
|
||||
value = '"' + value + '"'
|
||||
}
|
||||
if (recordProperty.config.decimals !== undefined) {
|
||||
value = Number(value.toFixed(recordProperty.config.decimals))
|
||||
if (targetNode.type !== undefined) {
|
||||
/*
|
||||
In this case the Target Node is really a node (since it has a type), so we extract the value
|
||||
from its value property.
|
||||
*/
|
||||
value = targetNode.value
|
||||
value = safeValue(value)
|
||||
if (recordProperty.config.isString === true) {
|
||||
value = '"' + value + '"'
|
||||
}
|
||||
if (recordProperty.config.decimals !== undefined) {
|
||||
value = Number(value.toFixed(recordProperty.config.decimals))
|
||||
}
|
||||
} else {
|
||||
/*
|
||||
In this case the Target Node is not really node, but the value itself. Se we return this as the
|
||||
value of the Record Property.
|
||||
*/
|
||||
value = targetNode
|
||||
}
|
||||
}
|
||||
record.push(value)
|
||||
}
|
||||
|
||||
@@ -151,7 +151,7 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, UTILIT
|
||||
|
||||
heartBeat()
|
||||
positionChartAtCurrentCandle()
|
||||
tradingSystemModule.setChart(chart)
|
||||
tradingSystemModule.reset(chart)
|
||||
|
||||
tradingEngineModule.updateEpisodeCountersAndStatistics()
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ exports.newTradingSystem = function newTradingSystem(bot, logger) {
|
||||
const FULL_LOG = true
|
||||
|
||||
let thisObject = {
|
||||
setChart: setChart,
|
||||
reset: reset,
|
||||
evalConditions: evalConditions,
|
||||
evalFormulas: evalFormulas,
|
||||
checkTriggerOn: checkTriggerOn,
|
||||
@@ -34,30 +34,33 @@ exports.newTradingSystem = function newTradingSystem(bot, logger) {
|
||||
function initialize() {
|
||||
tradingSystem = bot.simulationState.tradingSystem
|
||||
tradingEngine = bot.simulationState.tradingEngine
|
||||
|
||||
tradingSystem.highlights = []
|
||||
tradingSystem.conditionsErrors = []
|
||||
tradingSystem.formulasValues = []
|
||||
tradingSystem.formulasErrors = []
|
||||
}
|
||||
|
||||
function finalize() {
|
||||
chart = undefined
|
||||
|
||||
conditions = undefined
|
||||
tradingSystem.highlights = undefined
|
||||
tradingSystem.conditionsErrors = undefined
|
||||
|
||||
formulas = undefined
|
||||
tradingSystem.formulasValues = undefined
|
||||
tradingSystem.formulasErrors = undefined
|
||||
|
||||
tradingSystem.highlights = undefined
|
||||
tradingSystem.errors = undefined
|
||||
tradingSystem.values = undefined
|
||||
tradingSystem.status = undefined
|
||||
tradingSystem.progress = undefined
|
||||
tradingSystem.running = undefined
|
||||
|
||||
tradingSystem = undefined
|
||||
tradingEngine = undefined
|
||||
}
|
||||
|
||||
function setChart(pChart) {
|
||||
function reset(pChart) {
|
||||
chart = pChart // We need chat to be a local object accessible from conditions and formulas.
|
||||
tradingSystem.highlights = []
|
||||
tradingSystem.errors = []
|
||||
tradingSystem.values = []
|
||||
tradingSystem.status = []
|
||||
tradingSystem.progress = []
|
||||
tradingSystem.running = []
|
||||
}
|
||||
|
||||
function evalConditions() {
|
||||
@@ -143,19 +146,20 @@ exports.newTradingSystem = function newTradingSystem(bot, logger) {
|
||||
*/
|
||||
} else {
|
||||
error = err.message
|
||||
node.error = error
|
||||
}
|
||||
}
|
||||
|
||||
conditions.set(node.id, value)
|
||||
|
||||
if (value === true) {
|
||||
tradingSystem.highlights.push(1)
|
||||
} else {
|
||||
tradingSystem.highlights.push(0)
|
||||
tradingSystem.highlights.push([node.id, ''])
|
||||
}
|
||||
if (error !== undefined) {
|
||||
tradingSystem.errors.push([node.id, error])
|
||||
}
|
||||
if (value !== undefined) {
|
||||
tradingSystem.values.push([node.id, value])
|
||||
}
|
||||
|
||||
tradingSystem.conditionsErrors.push(error)
|
||||
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, '[INFO] evalCondition -> value = ' + value) }
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, '[INFO] evalCondition -> error = ' + error) }
|
||||
@@ -183,19 +187,17 @@ exports.newTradingSystem = function newTradingSystem(bot, logger) {
|
||||
*/
|
||||
} else {
|
||||
error = err.message
|
||||
node.error = error
|
||||
}
|
||||
}
|
||||
|
||||
formulas.set(node.id, value)
|
||||
|
||||
if (value === true) {
|
||||
tradingSystem.formulasValues.push(1)
|
||||
} else {
|
||||
tradingSystem.formulasValues.push(0)
|
||||
if (error !== undefined) {
|
||||
tradingSystem.errors.push([node.id, error])
|
||||
}
|
||||
if (value !== undefined) {
|
||||
tradingSystem.values.push([node.id, value])
|
||||
}
|
||||
|
||||
tradingSystem.formulasErrors.push(error)
|
||||
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, '[INFO] evalFormula -> value = ' + value) }
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, '[INFO] evalFormula -> error = ' + error) }
|
||||
|
||||
Reference in new issue
Block a user