Changing configuration
This commit is contained in:
1 parent
fbe86ab8e5
commit
854331b50b
3 files changed
+83
-184
No files matched your search
@@ -1,112 +0,0 @@
|
||||
/*
|
||||
* Linear regression curve.
|
||||
*/
|
||||
|
||||
//var log = require('../../core/log');
|
||||
|
||||
var LRCIndicator = function(settings) {
|
||||
this.input = 'price';
|
||||
this.depth = settings;
|
||||
this.result = false;
|
||||
this.age = 0;
|
||||
this.history = [];
|
||||
this.x = [];
|
||||
/*
|
||||
* Do not use array(depth) as it might not be implemented
|
||||
*/
|
||||
for (var i = 0; i < this.depth; i++) {
|
||||
this.history.push(0.0);
|
||||
this.x.push(i);
|
||||
}
|
||||
|
||||
// log.debug("Created LRC indicator with h: ", this.depth);
|
||||
}
|
||||
|
||||
LRCIndicator.prototype.update = function(price) {
|
||||
// We need sufficient history to get the right result.
|
||||
if(this.result === false && this.age < this.depth) {
|
||||
|
||||
this.history[this.age] = price;
|
||||
this.age++;
|
||||
this.result = false;
|
||||
// log.debug("Waiting for sufficient age: ", this.age, " out of ", this.depth);
|
||||
return;
|
||||
}
|
||||
|
||||
this.age++;
|
||||
// shift history
|
||||
for (var i = 0; i < (this.depth - 1); i++) {
|
||||
this.history[i] = this.history[i+1];
|
||||
}
|
||||
this.history[this.depth-1] = price;
|
||||
|
||||
this.calculate(price);
|
||||
|
||||
// log.debug("Checking LRC: ", this.result.toFixed(8), "\tH: ", this.age);
|
||||
return;
|
||||
}
|
||||
|
||||
/*
|
||||
* Least squares linear regression fitting.
|
||||
*/
|
||||
function linreg(values_x, values_y) {
|
||||
var sum_x = 0;
|
||||
var sum_y = 0;
|
||||
var sum_xy = 0;
|
||||
var sum_xx = 0;
|
||||
var count = 0;
|
||||
|
||||
/*
|
||||
* We'll use those variables for faster read/write access.
|
||||
*/
|
||||
var x = 0;
|
||||
var y = 0;
|
||||
var values_length = values_x.length;
|
||||
|
||||
if (values_length != values_y.length) {
|
||||
throw new Error('The parameters values_x and values_y need to have same size!');
|
||||
}
|
||||
|
||||
/*
|
||||
* Nothing to do.
|
||||
*/
|
||||
if (values_length === 0) {
|
||||
return [ [], [] ];
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate the sum for each of the parts necessary.
|
||||
*/
|
||||
for (var v = 0; v < values_length; v++) {
|
||||
x = values_x[v];
|
||||
y = values_y[v];
|
||||
sum_x += x;
|
||||
sum_y += y;
|
||||
sum_xx += x*x;
|
||||
sum_xy += x*y;
|
||||
count++;
|
||||
}
|
||||
|
||||
/*
|
||||
* Calculate m and b for the formula: y = x * m + b
|
||||
*
|
||||
*/
|
||||
var m = (count*sum_xy - sum_x*sum_y) / (count*sum_xx - sum_x*sum_x);
|
||||
var b = (sum_y/count) - (m*sum_x)/count;
|
||||
|
||||
return [m, b];
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* Handle calculations
|
||||
*/
|
||||
LRCIndicator.prototype.calculate = function(price) {
|
||||
// get the reg
|
||||
var reg = linreg(this.x, this.history);
|
||||
|
||||
// y = a * x + b
|
||||
this.result = ((this.depth-1) * reg[0]) + reg[1];
|
||||
}
|
||||
|
||||
module.exports = LRCIndicator;
|
||||
+13
-11
@@ -29,6 +29,7 @@
|
||||
let key = "AAVikings-AAGauss-LRC-Points-Multi-Period-Daily-dataSet.V1";
|
||||
|
||||
gaussStorage = assistant.dataDependencies.dataSets.get(key);
|
||||
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE);
|
||||
} catch (err) {
|
||||
logger.write("[ERROR] initialize -> onDone -> err = " + err.message);
|
||||
@@ -40,6 +41,7 @@
|
||||
try {
|
||||
if (LOG_INFO === true) { logger.write("[INFO] start -> Entering function."); }
|
||||
|
||||
let market = global.MARKET;
|
||||
/*
|
||||
|
||||
This trading bot will use an strategy based on the interpretation of the Linear Regression Curve Channel.
|
||||
@@ -128,9 +130,7 @@
|
||||
if (LOG_INFO === true) { logger.write("[INFO] start -> createBuyPosition -> There is not enough available balance to buy. Available balance: " + assetABalance ); }
|
||||
|
||||
callBack(global.DEFAULT_OK_RESPONSE);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
function createSellPosition(callBack) {
|
||||
@@ -180,7 +180,7 @@
|
||||
getLRCPointsFile(queryDate, onLRCPointsFileReceived);
|
||||
|
||||
function onLRCPointsFileReceived(err, lrcPointsFile) {
|
||||
if (LOG_INFO === true) { logger.write("[INFO] start -> getChannelTilt -> onDailyFileReceived."); }
|
||||
if (LOG_INFO === true) { logger.write("[INFO] start -> getChannelTilt -> onLRCPointsFileReceived."); }
|
||||
|
||||
for (let i = 0; i < lrcPointsFile.length; i++) {
|
||||
|
||||
@@ -210,13 +210,15 @@
|
||||
getLRCPointsFile(queryDate, onPreviousLRCPointsFileReceived);
|
||||
}
|
||||
|
||||
break;
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
callBack(global.DEFAULT_OK_RESPONSE, NO_CHANNEL);
|
||||
}
|
||||
|
||||
function onLRCPointsFileReceived(err, lrcPointsFile) {
|
||||
if (LOG_INFO === true) { logger.write("[INFO] start -> getChannelTilt -> onDailyFileReceived."); }
|
||||
function onPreviousLRCPointsFileReceived(err, lrcPointsFile) {
|
||||
if (LOG_INFO === true) { logger.write("[INFO] start -> getChannelTilt -> onLRCPointsFileReceived."); }
|
||||
|
||||
let previous = lrcPointsFile.length - 2;
|
||||
previousLRCPoint = {
|
||||
@@ -270,23 +272,23 @@
|
||||
}
|
||||
}
|
||||
|
||||
function getLRCPointsFile(dateTime, onDailyFileReceived) {
|
||||
function getLRCPointsFile(dateTime, callback) {
|
||||
try {
|
||||
if (FULL_LOG === true) { logger.write("[INFO] start -> getChannelTilt -> getLRCPointsFile -> Entering function."); }
|
||||
|
||||
let periodName = "30-min";
|
||||
let datePath = dateTime.getUTCFullYear() + "/" + pad(dateTime.getUTCMonth() + 1, 2) + "/" + pad(dateTime.getUTCDate(), 2);
|
||||
let filePath = "AAVikings/AAGauss.1.0/AACloud.1.1/Poloniex/dataSet.V1/Output/LRC-Points/Multi-Period-Daily/" + periodName + "/" + datePath;
|
||||
let filePath = "LRC-Points/Multi-Period-Daily/" + periodName + "/" + datePath;
|
||||
let fileName = market.assetA + '_' + market.assetB + ".json"
|
||||
|
||||
gaussStorage.getTextFile(pFilePath, pFileName, onFileReceived);
|
||||
gaussStorage.getTextFile(filePath, fileName, onFileReceived);
|
||||
|
||||
function onFileReceived(err, text) {
|
||||
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
|
||||
if (FULL_LOG === true) { logger.write("[INFO] start -> getChannelTilt -> getLRCPointsFile -> onFileReceived > Entering Function."); }
|
||||
|
||||
let lrcPointsFile = JSON.parse(text);
|
||||
onDailyFileReceived(global.DEFAULT_OK_RESPONSE, lrcPointsFile);
|
||||
callback(global.DEFAULT_OK_RESPONSE, lrcPointsFile);
|
||||
} else {
|
||||
logger.write("[ERROR] start -> getChannelTilt -> getLRCPointsFile -> onFileReceived -> Failed to get the file. Will abort the process and request a retry.");
|
||||
callBackFunction(global.DEFAULT_RETRY_RESPONSE);
|
||||
|
||||
+70
-61
@@ -12,65 +12,77 @@
|
||||
"dataSetVersion": "dataSet.V1",
|
||||
"processes": [
|
||||
{
|
||||
"name": "Trading-Process",
|
||||
"description": "Simple trading strategy to be used as a template.",
|
||||
"startMode": {
|
||||
"live": {
|
||||
"run": "false",
|
||||
"resumeExecution": "false"
|
||||
},
|
||||
"backtest": {
|
||||
"run": "true",
|
||||
"beginDatetime": "2018-04-01T00:00:00.000Z",
|
||||
"endDatetime": "2018-04-04T11:59:00.000Z",
|
||||
"waitTime": 500
|
||||
},
|
||||
"competition": {
|
||||
"run": "false",
|
||||
"beginDatetime": "2018-04-27T16:00:00.000Z",
|
||||
"endDatetime": "2018-04-28T16:05:00.000Z",
|
||||
"resumeExecution": "false"
|
||||
}
|
||||
},
|
||||
"normalWaitTime": 60000,
|
||||
"retryWaitTime": 10000,
|
||||
"sleepWaitTime": 3600000,
|
||||
"comaWaitTime": 86400000,
|
||||
"statusDependencies": [
|
||||
{
|
||||
"devTeam": "AAVikings",
|
||||
"bot": "AAGauss",
|
||||
"botVersion": {
|
||||
"major": 1,
|
||||
"minor": 0
|
||||
},
|
||||
"process": "Multi-Period-Daily",
|
||||
"dataSetVersion": "dataSet.V1"
|
||||
},
|
||||
{
|
||||
"devTeam": "AAVikings",
|
||||
"bot": "AAArtudito",
|
||||
"botVersion": {
|
||||
"major": 1,
|
||||
"minor": 0
|
||||
"name": "Trading-Process",
|
||||
"description": "Simple trading strategy to be used as a template.",
|
||||
"startMode": {
|
||||
"live": {
|
||||
"run": "false",
|
||||
"resumeExecution": "false"
|
||||
},
|
||||
"process": "Trading-Process",
|
||||
"dataSetVersion": "dataSet.V1"
|
||||
}
|
||||
],
|
||||
"dataDependencies": [
|
||||
{
|
||||
"devTeam": "AAVikings",
|
||||
"bot": "AAGauss",
|
||||
"botVersion": {
|
||||
"major": 1,
|
||||
"minor": 0
|
||||
"backtest": {
|
||||
"run": "true",
|
||||
"beginDatetime": "2018-04-01T01:00:00.000Z",
|
||||
"endDatetime": "2018-04-01T12:00:00.000Z",
|
||||
"waitTime": 500
|
||||
},
|
||||
"product": "LRC-Points",
|
||||
"dataSetVersion": "dataSet.V1",
|
||||
"dataSet": "Multi-Period-Daily"
|
||||
}
|
||||
]
|
||||
"competition": {
|
||||
"run": "false",
|
||||
"beginDatetime": "2018-04-27T16:00:00.000Z",
|
||||
"endDatetime": "2018-04-28T16:05:00.000Z",
|
||||
"resumeExecution": "false"
|
||||
}
|
||||
},
|
||||
"normalWaitTime": 60000,
|
||||
"retryWaitTime": 10000,
|
||||
"sleepWaitTime": 3600000,
|
||||
"comaWaitTime": 86400000,
|
||||
"timePeriod": 60000,
|
||||
"statusDependencies": [
|
||||
{
|
||||
"devTeam": "AAVikings",
|
||||
"bot": "AAGauss",
|
||||
"botVersion": {
|
||||
"major": 1,
|
||||
"minor": 0
|
||||
},
|
||||
"process": "Multi-Period-Daily",
|
||||
"dataSetVersion": "dataSet.V1"
|
||||
},
|
||||
{
|
||||
"devTeam": "AAVikings",
|
||||
"bot": "AAArtudito",
|
||||
"botVersion": {
|
||||
"major": 1,
|
||||
"minor": 0
|
||||
},
|
||||
"process": "Trading-Process",
|
||||
"dataSetVersion": "dataSet.V1"
|
||||
}
|
||||
],
|
||||
"dataDependencies": [
|
||||
{
|
||||
"devTeam": "AAVikings",
|
||||
"bot": "AAGauss",
|
||||
"botVersion": {
|
||||
"major": 1,
|
||||
"minor": 0
|
||||
},
|
||||
"product": "LRC-Points",
|
||||
"dataSetVersion": "dataSet.V1",
|
||||
"dataSet": "Multi-Period-Daily"
|
||||
},
|
||||
{
|
||||
"devTeam": "AAMasters",
|
||||
"bot": "AABruce",
|
||||
"botVersion": {
|
||||
"major": 1,
|
||||
"minor": 0
|
||||
},
|
||||
"product": "Candles",
|
||||
"dataSet": "One-Min",
|
||||
"dataSetVersion": "dataSet.V1"
|
||||
}
|
||||
]
|
||||
}
|
||||
],
|
||||
"products": [
|
||||
@@ -79,10 +91,9 @@
|
||||
"displayName": "Live Trading History",
|
||||
"shortDisplayName": "Live",
|
||||
"description": "General information about Artudito trading history.",
|
||||
"storageAccount": "aaartudito",
|
||||
"dataSets": [
|
||||
{
|
||||
"codeName": "Oficial History",
|
||||
"codeName": "Live History",
|
||||
"type": "File Sequence",
|
||||
"validPeriods": [ "24-hs", "12-hs", "08-hs", "06-hs", "04-hs", "03-hs", "02-hs", "01-hs", "45-min", "40-min", "30-min", "20-min", "15-min", "10-min", "05-min", "04-min", "03-min", "02-min", "01-min" ],
|
||||
"filePath": "@DevTeam/@Bot.1.0/AACloud.1.1/Poloniex/dataSet.V1/Output/Trading-Process",
|
||||
@@ -105,7 +116,6 @@
|
||||
"displayName": "Backtest Trading History",
|
||||
"shortDisplayName": "Backtest",
|
||||
"description": "General information about Artudito backtest trading history.",
|
||||
"storageAccount": "aaartudito",
|
||||
"dataSets": [
|
||||
{
|
||||
"codeName": "Backtest History",
|
||||
@@ -131,7 +141,6 @@
|
||||
"displayName": "Competition Trading History",
|
||||
"shortDisplayName": "Competition",
|
||||
"description": "General information about Artudito competition trading history.",
|
||||
"storageAccount": "aaartudito",
|
||||
"dataSets": [
|
||||
{
|
||||
"codeName": "Competition History",
|
||||
|
||||
Reference in new issue
Block a user