Parameters splitted in 4 pieces
This commit is contained in:
1 parent
dbfe48bf1b
commit
772da41dff
3 files changed
+35
-55
No files matched your search
+33
-51
@@ -171,25 +171,23 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) {
|
||||
}
|
||||
if (definition.tradingSystem !== undefined) {
|
||||
if (definition.tradingSystem.parameters !== undefined) {
|
||||
if (definition.tradingSystem.parameters.baseAsset !== undefined) {
|
||||
if (definition.tradingSystem.parameters.baseAsset.formula !== undefined) {
|
||||
if (definition.tradingSystem.parameters.baseAsset.formula.code !== undefined) {
|
||||
try {
|
||||
let code = JSON.parse(definition.tradingSystem.parameters.baseAsset.formula.code)
|
||||
if (code.slippage !== undefined) {
|
||||
if (code.slippage.positionRate !== undefined) {
|
||||
slippage.positionRate = code.slippage.positionRate
|
||||
}
|
||||
if (code.slippage.stopLoss !== undefined) {
|
||||
slippage.stopLoss = code.slippage.stopLoss
|
||||
}
|
||||
if (code.slippage.takeProfit !== undefined) {
|
||||
slippage.takeProfit = code.slippage.takeProfit
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
tradingSystem.parameters.baseAsset.formula.error = "Slippage Error: " + err.message
|
||||
if (definition.tradingSystem.parameters.slippage !== undefined) {
|
||||
if (definition.tradingSystem.parameters.slippage.code !== undefined) {
|
||||
try {
|
||||
let code = JSON.parse(definition.tradingSystem.parameters.slippage.code)
|
||||
|
||||
if (code.positionRate !== undefined) {
|
||||
slippage.positionRate = code.positionRate
|
||||
}
|
||||
if (code.stopLoss !== undefined) {
|
||||
slippage.stopLoss = code.stopLoss
|
||||
}
|
||||
if (code.takeProfit !== undefined) {
|
||||
slippage.takeProfit = code.takeProfit
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
tradingSystem.parameters.slippage.error = err.message
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -204,22 +202,20 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) {
|
||||
|
||||
if (definition.tradingSystem !== undefined) {
|
||||
if (definition.tradingSystem.parameters !== undefined) {
|
||||
if (definition.tradingSystem.parameters.baseAsset !== undefined) {
|
||||
if (definition.tradingSystem.parameters.baseAsset.formula !== undefined) {
|
||||
if (definition.tradingSystem.parameters.baseAsset.formula.code !== undefined) {
|
||||
try {
|
||||
let code = JSON.parse(definition.tradingSystem.parameters.baseAsset.formula.code)
|
||||
if (code.feeStructure !== undefined) {
|
||||
if (code.feeStructure.maker !== undefined) {
|
||||
feeStructure.maker = code.feeStructure.maker
|
||||
}
|
||||
if (code.feeStructure.taker !== undefined) {
|
||||
feeStructure.taker = code.feeStructure.taker
|
||||
}
|
||||
}
|
||||
} catch (err) {
|
||||
tradingSystem.parameters.baseAsset.formula.error = "Fee Structure Error: " + err.message
|
||||
if (definition.tradingSystem.parameters.feeStructure !== undefined) {
|
||||
if (definition.tradingSystem.parameters.feeStructure.code !== undefined) {
|
||||
try {
|
||||
let code = JSON.parse(definition.tradingSystem.parameters.feeStructure.code)
|
||||
|
||||
if (code.maker !== undefined) {
|
||||
feeStructure.maker = code.maker
|
||||
}
|
||||
if (code.taker !== undefined) {
|
||||
feeStructure.taker = code.taker
|
||||
}
|
||||
|
||||
} catch (err) {
|
||||
tradingSystem.parameters.feeStructure.error = err.message
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -2156,23 +2152,17 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) {
|
||||
|
||||
closePositionRate = ticker.last + 100; // This is provisional and totally arbitrary, until we have a formula on the designer that defines this stuff.
|
||||
|
||||
amountA = interExecutionMemory.executionContext.amountA
|
||||
amountB = interExecutionMemory.executionContext.amountA / closePositionRate
|
||||
amountA = availableBalance.assetA
|
||||
amountB = availableBalance.assetA / closePositionRate
|
||||
|
||||
if (amountA > availableBalance.assetA) { // The assistant know what fees were paid.
|
||||
amountA = availableBalance.assetA
|
||||
}
|
||||
} else {
|
||||
positionDirection = "sell"
|
||||
|
||||
closePositionRate = ticker.last - 100; // This is provisional and totally arbitrary, until we have a formula on the designer that defines this stuff.
|
||||
|
||||
amountA = interExecutionMemory.executionContext.amountB * closePositionRate
|
||||
amountB = interExecutionMemory.executionContext.amountB
|
||||
amountA = availableBalance.assetB * closePositionRate
|
||||
amountB = availableBalance.assetB
|
||||
|
||||
if (amountB > availableBalance.assetB) { // The assistant know what fees were paid.
|
||||
amountB = availableBalance.assetB
|
||||
}
|
||||
}
|
||||
|
||||
interExecutionMemory.executionContext = {
|
||||
@@ -2257,12 +2247,10 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) {
|
||||
}
|
||||
|
||||
currentTrade.lastTradeROI = lastTradeROI;
|
||||
currentTrade.stopRate = stopLoss;
|
||||
|
||||
if (processingDailyFiles) {
|
||||
if (positionedAtYesterday) {
|
||||
yesterday.currentTrade.lastTradeROI = currentTrade.lastTradeROI;
|
||||
yesterday.currentTrade.stopRate = currentTrade.stopRate;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2581,12 +2569,6 @@ exports.newCommons = function newCommons(bot, logger, UTILITIES) {
|
||||
|
||||
strategiesArray.push(currentStrategy);
|
||||
|
||||
if (currentStrategy.begin < currentStrategy.end) {
|
||||
console.log("ES MENOR:" + i)
|
||||
} else {
|
||||
console.log("ES MAYOR:" + i)
|
||||
}
|
||||
|
||||
currentStrategy = {
|
||||
begin: 0,
|
||||
end: 0,
|
||||
|
||||
@@ -612,8 +612,7 @@
|
||||
record.lastTradeROI + "," +
|
||||
record.beginRate + "," +
|
||||
record.endRate + "," +
|
||||
record.exitType + "," +
|
||||
record.stopRate + "]";
|
||||
record.exitType + "]";
|
||||
|
||||
if (separator === "") { separator = ","; }
|
||||
|
||||
|
||||
@@ -464,8 +464,7 @@
|
||||
record.lastTradeROI + "," +
|
||||
record.beginRate + "," +
|
||||
record.endRate + "," +
|
||||
record.exitType + "," +
|
||||
record.stopRate + "]";
|
||||
record.exitType + "]";
|
||||
|
||||
if (separator === "") { separator = ","; }
|
||||
|
||||
|
||||
Reference in new issue
Block a user