initialBalance
This commit is contained in:
1 parent
da115112a6
commit
4088d631a8
4 files changed
+44
-9
No files matched your search
@@ -26,9 +26,10 @@ exports.newTradingEngine = function newTradingEngine(bot, logger) {
|
||||
tradingEngine = bot.simulationState.tradingEngine
|
||||
sessionParameters = bot.SESSION.parameters
|
||||
|
||||
if (tradingEngine.isInitialized !== true || bot.RESUME === false) {
|
||||
tradingEngine.isInitialized = true
|
||||
if (bot.RESUME === false) {
|
||||
initializeNode(tradingEngine)
|
||||
tradingEngine.current.balance.baseAsset.value = sessionParameters.sessionBaseAsset.config.initialBalance
|
||||
tradingEngine.current.balance.quotedAsset.value = sessionParameters.sessionQuotedAsset.config.initialBalance
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -56,10 +56,44 @@ exports.newTradingOutput = function newTradingOutput(bot, logger, UTILITIES, FIL
|
||||
if (bot.RESUME !== true) {
|
||||
bot.simulationState.tradingEngine = bot.TRADING_ENGINE
|
||||
bot.simulationState.tradingSystem = bot.TRADING_SYSTEM
|
||||
initializeOutputs()
|
||||
} else {
|
||||
readFiles()
|
||||
}
|
||||
readFiles()
|
||||
return
|
||||
|
||||
function initializeOutputs() {
|
||||
if (bot.processingDailyFiles) {
|
||||
initializeDailyFiles()
|
||||
} else {
|
||||
initializeMarketFiles()
|
||||
}
|
||||
}
|
||||
|
||||
function initializeDailyFiles() {
|
||||
for (let i = 0; i < outputDatasets.length; i++) {
|
||||
let outputDatasetNode = outputDatasets[i]
|
||||
let dataset = outputDatasetNode.referenceParent
|
||||
|
||||
if (dataset.config.type === 'Daily Files') {
|
||||
outputDatasetsMap.set(dataset.parentNode.config.codeName, [])
|
||||
}
|
||||
}
|
||||
runSimulation()
|
||||
}
|
||||
|
||||
function initializeMarketFiles() {
|
||||
for (let i = 0; i < outputDatasets.length; i++) {
|
||||
let outputDatasetNode = outputDatasets[i]
|
||||
let dataset = outputDatasetNode.referenceParent
|
||||
|
||||
if (dataset.config.type === 'Market Files') {
|
||||
outputDatasetsMap.set(dataset.parentNode.config.codeName, [])
|
||||
}
|
||||
}
|
||||
runSimulation()
|
||||
}
|
||||
|
||||
function readFiles() {
|
||||
/*
|
||||
This bot have an output of files that it generates. At every call to the bot, it needs to read the previously generated
|
||||
|
||||
@@ -38,17 +38,17 @@ exports.newTradingRecords = function newTradingRecords(bot, logger) {
|
||||
let dataset = outputDatasetNode.referenceParent
|
||||
let product = dataset.parentNode
|
||||
let record
|
||||
let outputDatasetArray = outputDatasetsMap.get(product.config.codeName)
|
||||
|
||||
if (bot.processingDailyFiles === true && dataset.config.type === 'Daily Files') {
|
||||
record = scanRecordDefinition(product)
|
||||
outputDatasetArray.push(record)
|
||||
}
|
||||
|
||||
if (bot.processingDailyFiles === false && dataset.config.type === 'Market Files') {
|
||||
record = scanRecordDefinition(product)
|
||||
outputDatasetArray.push(record)
|
||||
}
|
||||
|
||||
let outputDatasetArray = outputDatasetsMap.get(product.config.codeName)
|
||||
outputDatasetArray.push(record)
|
||||
}
|
||||
|
||||
function scanRecordDefinition(product) {
|
||||
@@ -113,6 +113,9 @@ exports.newTradingRecords = function newTradingRecords(bot, logger) {
|
||||
if (recordProperty.config.isString === true) {
|
||||
value = '"' + value + '"'
|
||||
}
|
||||
if (recordProperty.config.decimals !== undefined) {
|
||||
value = value.toFixed(decimals)
|
||||
}
|
||||
record.push(value)
|
||||
}
|
||||
return record
|
||||
|
||||
@@ -77,9 +77,6 @@ exports.newTradingSimulation = function newTradingSimulation(bot, logger, UTILIT
|
||||
let propertyName = 'at' + sessionParameters.timeFrame.config.label.replace('-', '')
|
||||
let candles = chart[propertyName].candles
|
||||
|
||||
/* Last Candle */
|
||||
let lastCandle = candles[candles.length - 1] // TODO Maybe remove this
|
||||
|
||||
/* Variables needed for heartbeat functionality */
|
||||
let heartBeatDate
|
||||
let previousheartBeatDate
|
||||
|
||||
Reference in new issue
Block a user