Bugs Fixed

This commit is contained in:
Luis Fernando Molina committed 2020-07-22 20:33:17 +02:00
1 parent 744d5939a3
commit ac6493dff1
3 files changed
+17 -7

No files matched your search

+7 -6
View File
@@ -233,7 +233,7 @@ exports.newTradingExecution = function newTradingExecution(bot, logger, tradingE
sizeFilledSimulation()
amountReceivedSimulation()
doTheAccounting(previousSizeFilled, previousPercentageFilled, previousAmountReceived, previousFeesPaid)
doTheAccounting(tradingSystemOrder, tradingEngineOrder, previousSizeFilled, previousPercentageFilled, previousAmountReceived, previousFeesPaid)
/* If the Stage is Closing and this order is still open, we need to cancel it now */
if (stageIsClosing === true && tradingEngineOrder.status.value !== 'Closed') {
@@ -432,10 +432,10 @@ exports.newTradingExecution = function newTradingExecution(bot, logger, tradingE
tradingEngineOrder.orderStatistics.actualRate.value = order.price
tradingEngineOrder.orderStatistics.actualRate.value = global.PRECISE(tradingEngineOrder.orderStatistics.actualRate.value, 10)
doTheAccounting(previousSizeFilled, previousPercentageFilled, previousAmountReceived, previousFeesPaid)
doTheAccounting(tradingSystemOrder, tradingEngineOrder, previousSizeFilled, previousPercentageFilled, previousAmountReceived, previousFeesPaid)
}
function doTheAccounting(previousSizeFilled, previousPercentageFilled, previousAmountReceived, previousFeesPaid) {
function doTheAccounting(tradingSystemOrder, tradingEngineOrder, previousSizeFilled, previousPercentageFilled, previousAmountReceived, previousFeesPaid) {
/* Unaccount for the previous Stage Filled Size */
stageFilledSize.value = stageFilledSize.value - tradingEngineOrder.size.value * previousPercentageFilled / 100
@@ -443,9 +443,10 @@ exports.newTradingExecution = function newTradingExecution(bot, logger, tradingE
stageFilledSize.value = stageFilledSize.value + tradingEngineOrder.size.value * tradingEngineOrder.orderStatistics.percentageFilled.value / 100
stageFilledSize.value = global.PRECISE(stageFilledSize.value, 10)
/* Balances Update */
switch (order.side) {
case 'buy': {
switch (true) {
case tradingSystemOrder.type === 'Market Buy Order' || tradingSystemOrder.type === 'Limit Buy Order': {
/* Undo the previous accounting */
tradingEngine.current.balance.baseAsset.value = tradingEngine.current.balance.baseAsset.value - previousFeesPaid - previousSizeFilled
@@ -459,7 +460,7 @@ exports.newTradingExecution = function newTradingExecution(bot, logger, tradingE
break
}
case 'sell': {
case tradingSystemOrder.type === 'Market Sell Order' || tradingSystemOrder.type === 'Limit Sell Order': {
/* Undo the previous accounting */
tradingEngine.current.balance.baseAsset.value = tradingEngine.current.balance.baseAsset.value + previousFeesPaid + previousSizeFilled
+8 -1
View File
@@ -119,7 +119,14 @@ exports.newTradingRecords = function newTradingRecords(bot, logger) {
the Root Node specifically for this property only.
*/
if (recordProperty.config.nodePath !== undefined) {
propertyRootNode = eval(recordProperty.config.nodePath)
try {
propertyRootNode = eval(recordProperty.config.nodePath)
} catch (err) {
logger.write(MODULE_NAME, "[ERROR] appendRecords -> scanRecordDefinition -> Error at Record Property Definition -> recordProperty.name = " + recordProperty.name);
logger.write(MODULE_NAME, "[ERROR] appendRecords -> scanRecordDefinition -> Error at Record Property Definition -> recordProperty.config.nodePath = " + recordProperty.config.nodePath);
logger.write(MODULE_NAME, "[ERROR] appendRecords -> scanRecordDefinition -> Error at Record Property Definition -> err.stack = " + err.stack);
throw 'Can not continue with a Definition Error like this.'
}
}
/*
The Target Node is the node from where we are going to exctract the value.
+2
View File
@@ -47,12 +47,14 @@ global.PRECISE = function (floatNumber, precision) {
process.on('uncaughtException', function (err) {
console.log('[ERROR] Task Server -> server -> uncaughtException -> err.message = ' + err.message)
console.log('[ERROR] Task Server -> server -> uncaughtException -> err.stack = ' + err.stack)
console.log(err.stack)
global.EXIT_NODE_PROCESS()
})
process.on('unhandledRejection', (reason, p) => {
console.log('[ERROR] Task Server -> server -> unhandledRejection -> reason = ' + JSON.stringify(reason))
console.log('[ERROR] Task Server -> server -> unhandledRejection -> p = ' + JSON.stringify(p))
console.log(reason.stack)
global.EXIT_NODE_PROCESS()
})