6 files changed
+120
-140
No files matched your search
File renamed without changes.
@@ -7,7 +7,6 @@
|
||||
const MODULE_NAME = "Interval";
|
||||
const LOG_INFO = true;
|
||||
|
||||
const EXCHANGE_NAME = "Poloniex";
|
||||
const EXCHANGE_ID = 1;
|
||||
|
||||
const TRADES_FOLDER_NAME = "Trades";
|
||||
@@ -269,7 +268,7 @@ This process complements the Live Trades process and write historical trades fil
|
||||
logger.write(MODULE_NAME, "[INFO] Entering function 'getMarketStatusReport'");
|
||||
}
|
||||
|
||||
let reportFilePath = EXCHANGE_NAME + "/Processes/" + bot.process;
|
||||
let reportFilePath = global.EXCHANGE_NAME + "/Processes/" + bot.process;
|
||||
let fileName = "Status.Report." + market.assetA + '_' + market.assetB + ".json";
|
||||
|
||||
charlyStorage.getTextFile(reportFilePath, fileName, onFileReceived, true);
|
||||
@@ -325,7 +324,7 @@ This process complements the Live Trades process and write historical trades fil
|
||||
logger.write(MODULE_NAME, "[INFO] Entering function 'getMarketStatusReport'");
|
||||
}
|
||||
|
||||
let reportFilePath = EXCHANGE_NAME + "/Processes/" + bot.process + "/" + year + "/" + month;
|
||||
let reportFilePath = global.EXCHANGE_NAME + "/Processes/" + bot.process + "/" + year + "/" + month;
|
||||
let fileName = "Status.Report." + market.assetA + '_' + market.assetB + ".json";
|
||||
|
||||
charlyStorage.getTextFile(reportFilePath, fileName, onFileReceived, true);
|
||||
@@ -719,7 +718,7 @@ This process complements the Live Trades process and write historical trades fil
|
||||
|
||||
dateForPath = date.getUTCFullYear() + '/' + utilities.pad(date.getUTCMonth() + 1, 2) + '/' + utilities.pad(date.getUTCDate(), 2) + '/' + utilities.pad(date.getUTCHours(), 2) + '/' + utilities.pad(date.getUTCMinutes(), 2);
|
||||
|
||||
filePath = EXCHANGE_NAME + "/Output/" + TRADES_FOLDER_NAME + '/' + dateForPath;
|
||||
filePath = global.EXCHANGE_NAME + "/Output/" + TRADES_FOLDER_NAME + '/' + dateForPath;
|
||||
|
||||
utilities.createFolderIfNeeded(filePath, charlyStorage, onFolderCreated);
|
||||
|
||||
@@ -841,7 +840,7 @@ This process complements the Live Trades process and write historical trades fil
|
||||
logger.write(MODULE_NAME, "[INFO] Entering function 'writeStatusReport'");
|
||||
}
|
||||
|
||||
let reportFilePath = EXCHANGE_NAME + "/Processes/" + bot.process + "/" + year + "/" + month;
|
||||
let reportFilePath = global.EXCHANGE_NAME + "/Processes/" + bot.process + "/" + year + "/" + month;
|
||||
|
||||
utilities.createFolderIfNeeded(reportFilePath, charlyStorage, onFolderCreated);
|
||||
|
||||
@@ -872,7 +871,7 @@ This process complements the Live Trades process and write historical trades fil
|
||||
|
||||
if (isBeginingOfMarket === true) {
|
||||
|
||||
reportFilePath = EXCHANGE_NAME + "/Processes/" + bot.process;
|
||||
reportFilePath = global.EXCHANGE_NAME + "/Processes/" + bot.process;
|
||||
|
||||
utilities.createFolderIfNeeded(reportFilePath, charlyStorage, onFolderCreated);
|
||||
|
||||
@@ -955,7 +954,7 @@ This process complements the Live Trades process and write historical trades fil
|
||||
let finalYear = (new Date()).getUTCFullYear();
|
||||
let finalMonth = (new Date()).getUTCMonth() + 1;
|
||||
|
||||
let reportFilePath = EXCHANGE_NAME + "/Processes/" + bot.process;
|
||||
let reportFilePath = global.EXCHANGE_NAME + "/Processes/" + bot.process;
|
||||
let fileName = "Status.Report." + market.assetA + '_' + market.assetB + ".json";
|
||||
|
||||
/* Lets read the main status report */
|
||||
@@ -993,7 +992,7 @@ This process complements the Live Trades process and write historical trades fil
|
||||
*/
|
||||
let paddedInitialMonth = utilities.pad(initialMonth, 2);
|
||||
|
||||
let reportFilePath = EXCHANGE_NAME + "/Processes/" + bot.process + "/" + initialYear + "/" + paddedInitialMonth;
|
||||
let reportFilePath = global.EXCHANGE_NAME + "/Processes/" + bot.process + "/" + initialYear + "/" + paddedInitialMonth;
|
||||
let fileName = "Status.Report." + market.assetA + '_' + market.assetB + ".json";
|
||||
|
||||
charlyStorage.getTextFile(reportFilePath, fileName, onStatusReportFileReceived, true);
|
||||
@@ -1059,7 +1058,7 @@ This process complements the Live Trades process and write historical trades fil
|
||||
|
||||
/* We will read the current file to preserve its data, and save it again with market complete = true */
|
||||
|
||||
let reportFilePath = EXCHANGE_NAME + "/Processes/" + bot.process;
|
||||
let reportFilePath = global.EXCHANGE_NAME + "/Processes/" + bot.process;
|
||||
let fileName = "Status.Report." + market.assetA + '_' + market.assetB + ".json";
|
||||
|
||||
charlyStorage.getTextFile(reportFilePath, fileName, onFileReceived, true);
|
||||
@@ -1,4 +1,4 @@
|
||||
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, BLOB_STORAGE, STATUS_REPORT, POLONIEX_CLIENT_MODULE) {
|
||||
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, BLOB_STORAGE, STATUS_REPORT, EXCHANGE_API) {
|
||||
|
||||
const FULL_LOG = true;
|
||||
const LOG_FILE_CONTENT = false;
|
||||
@@ -8,8 +8,6 @@
|
||||
|
||||
const MODULE_NAME = "User Bot";
|
||||
|
||||
const EXCHANGE_NAME = "Poloniex";
|
||||
|
||||
const TRADES_FOLDER_NAME = "Trades";
|
||||
|
||||
thisObject = {
|
||||
@@ -20,8 +18,7 @@
|
||||
let charlyStorage = BLOB_STORAGE.newBlobStorage(bot, logger);
|
||||
|
||||
let utilities = UTILITIES.newCloudUtilities(bot, logger);
|
||||
let poloniexApiClient = POLONIEX_CLIENT_MODULE.newPoloniexAPIClient(global.EXCHANGE_KEYS[global.EXCHANGE_NAME].Key, global.EXCHANGE_KEYS[global.EXCHANGE_NAME].Secret);
|
||||
|
||||
|
||||
let statusReportModule = STATUS_REPORT.newStatusReport(bot, logger, BLOB_STORAGE, UTILITIES);
|
||||
|
||||
let year;
|
||||
@@ -98,43 +95,43 @@
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
This process is going to do the following:
|
||||
|
||||
It will try to find "holes" on the transaction history and fix them by retrieving the missing transactions from the exchange.
|
||||
|
||||
What are holes?
|
||||
|
||||
Holes are missing transactions in the history of the market and the reason there can be holes are the following:
|
||||
|
||||
1) The "Lives Trades" process can be stopped and later started again. The process will only retrieve live trades, leaving a "hole" between it was stopped and restarted.
|
||||
2) The "Historic Trades" process might have received a "hole" of transactions directly from the exchange.
|
||||
3) The "Historic Trades" process failed to write some files to the storage and now they are missing, together with the transaction in them.
|
||||
4) The "Historic Trades" process wrote some files to the storage with corrupted content.
|
||||
5) The "Historic Trades" process wrote files with transaction not properly ordered by Trade Id (sometimes the exchange sent this wrong).
|
||||
|
||||
How does the process work?
|
||||
|
||||
Transactions have a unique id generated by the exchange. It is a secuencial number. This process scans the transaction history looking for missing ids. When it finds
|
||||
some group of missing ids, it request the exchange the missing records and it writes the necesary files to fix the hole. But some things might happen:
|
||||
|
||||
1) The exchange responds, but does not provides the missing records. In this case the process will flag this hole for retry later, up to 3 times. After that it will flag
|
||||
the hole as "permanent".
|
||||
2) The exchange call timeouts: the process will continue retrying later.
|
||||
3) The exchange returns an unexpected error: The process will retry up to 3 times later under this condition.
|
||||
4) The exchange returns neighboring transactions but not the missing ones. The process will retry 3 more times and mark the hole as permanent if the exchange refuses to send the missing trades.
|
||||
|
||||
Since the process is run in an infinite loop but can be restarted any time, the status of its running is recorded in the Status Report file.
|
||||
|
||||
What is the lastFile pointer?
|
||||
|
||||
It is the Datetime since the begining of the hitory of a market that is considered without holes (or only with permanent ones, unfixables). In other words, the process
|
||||
starts from the begining of the history of a market, and only when its history is signaled as "Complete" by the "Historic Trades" process. From there, the process is advancing
|
||||
in time, validating the history and fixing holes, and moving the lastFile pointer forward as it gets sure that all the previous trades files are with no holes or unfixable ones.
|
||||
This pointer will later be used by Indicators bots that depends of these trades, and it will be considered the head of the market.
|
||||
|
||||
*/
|
||||
/*
|
||||
|
||||
This process is going to do the following:
|
||||
|
||||
It will try to find "holes" on the transaction history and fix them by retrieving the missing transactions from the exchange.
|
||||
|
||||
What are holes?
|
||||
|
||||
Holes are missing transactions in the history of the market and the reason there can be holes are the following:
|
||||
|
||||
1) The "Lives Trades" process can be stopped and later started again. The process will only retrieve live trades, leaving a "hole" between it was stopped and restarted.
|
||||
2) The "Historic Trades" process might have received a "hole" of transactions directly from the exchange.
|
||||
3) The "Historic Trades" process failed to write some files to the storage and now they are missing, together with the transaction in them.
|
||||
4) The "Historic Trades" process wrote some files to the storage with corrupted content.
|
||||
5) The "Historic Trades" process wrote files with transaction not properly ordered by Trade Id (sometimes the exchange sent this wrong).
|
||||
|
||||
How does the process work?
|
||||
|
||||
Transactions have a unique id generated by the exchange. It is a secuencial number. This process scans the transaction history looking for missing ids. When it finds
|
||||
some group of missing ids, it request the exchange the missing records and it writes the necesary files to fix the hole. But some things might happen:
|
||||
|
||||
1) The exchange responds, but does not provides the missing records. In this case the process will flag this hole for retry later, up to 3 times. After that it will flag
|
||||
the hole as "permanent".
|
||||
2) The exchange call timeouts: the process will continue retrying later.
|
||||
3) The exchange returns an unexpected error: The process will retry up to 3 times later under this condition.
|
||||
4) The exchange returns neighboring transactions but not the missing ones. The process will retry 3 more times and mark the hole as permanent if the exchange refuses to send the missing trades.
|
||||
|
||||
Since the process is run in an infinite loop but can be restarted any time, the status of its running is recorded in the Status Report file.
|
||||
|
||||
What is the lastFile pointer?
|
||||
|
||||
It is the Datetime since the begining of the hitory of a market that is considered without holes (or only with permanent ones, unfixables). In other words, the process
|
||||
starts from the begining of the history of a market, and only when its history is signaled as "Complete" by the "Historic Trades" process. From there, the process is advancing
|
||||
in time, validating the history and fixing holes, and moving the lastFile pointer forward as it gets sure that all the previous trades files are with no holes or unfixable ones.
|
||||
This pointer will later be used by Indicators bots that depends of these trades, and it will be considered the head of the market.
|
||||
|
||||
*/
|
||||
|
||||
function start(callBackFunction) {
|
||||
|
||||
@@ -197,7 +194,7 @@ What is the lastFile pointer?
|
||||
let thisReport;
|
||||
let reportKey;
|
||||
|
||||
reportKey = "AAMasters" + "-" + "AACharly" + "-" + "Poloniex-Live-Trades" + "-" + "dataSet.V1";
|
||||
reportKey = "AAMasters" + "-" + "AACharly" + "-" + "Live-Trades" + "-" + "dataSet.V1";
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> getContextVariables -> reportKey = " + reportKey); }
|
||||
|
||||
if (statusDependencies.statusReports.get(reportKey).status === "Status Report is corrupt.") {
|
||||
@@ -222,7 +219,7 @@ What is the lastFile pointer?
|
||||
|
||||
lastLiveTradeFile = new Date(thisReport.lastFile.year + "-" + thisReport.lastFile.month + "-" + thisReport.lastFile.days + " " + thisReport.lastFile.hours + ":" + thisReport.lastFile.minutes + GMT_SECONDS);
|
||||
|
||||
reportKey = "AAMasters" + "-" + "AACharly" + "-" + "Poloniex-Historic-Trades" + "-" + "dataSet.V1";
|
||||
reportKey = "AAMasters" + "-" + "AACharly" + "-" + "Historic-Trades" + "-" + "dataSet.V1";
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> getContextVariables -> reportKey = " + reportKey); }
|
||||
|
||||
if (statusDependencies.statusReports.get(reportKey).status === "Status Report is corrupt.") {
|
||||
@@ -265,7 +262,7 @@ What is the lastFile pointer?
|
||||
logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> customOK = " + customOK.message);
|
||||
callBackFunction(customOK);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
} else {
|
||||
logger.write(MODULE_NAME, "[WARN] start -> getContextVariables -> Trade History is not complete.");
|
||||
@@ -278,8 +275,8 @@ What is the lastFile pointer?
|
||||
callBackFunction(customOK);
|
||||
return;
|
||||
}
|
||||
|
||||
reportKey = "AAMasters" + "-" + "AACharly" + "-" + "Poloniex-Hole-Fixing" + "-" + "dataSet.V1" + "-" + year + "-" + month;
|
||||
|
||||
reportKey = "AAMasters" + "-" + "AACharly" + "-" + "Hole-Fixing" + "-" + "dataSet.V1" + "-" + year + "-" + month;
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> getContextVariables -> reportKey = " + reportKey); }
|
||||
|
||||
if (statusDependencies.statusReports.get(reportKey).status === "Status Report is corrupt.") {
|
||||
@@ -377,7 +374,7 @@ What is the lastFile pointer?
|
||||
|
||||
let fileCheckedCounter = 0;
|
||||
|
||||
date = new Date(lastHoleFixingFile.valueOf());
|
||||
date = new Date(lastHoleFixingFile.valueOf());
|
||||
|
||||
readNextFile();
|
||||
|
||||
@@ -421,7 +418,7 @@ What is the lastFile pointer?
|
||||
return;
|
||||
}
|
||||
|
||||
/* Lets check if we have reached the end of the month. */
|
||||
/* Lets check if we have reached the end of the month. */
|
||||
|
||||
if (date.valueOf() > lastMinuteOfMonth.valueOf()) {
|
||||
|
||||
@@ -458,7 +455,7 @@ What is the lastFile pointer?
|
||||
}
|
||||
|
||||
dateForPath = date.getUTCFullYear() + '/' + utilities.pad(date.getUTCMonth() + 1, 2) + '/' + utilities.pad(date.getUTCDate(), 2) + '/' + utilities.pad(date.getUTCHours(), 2) + '/' + utilities.pad(date.getUTCMinutes(), 2);
|
||||
|
||||
|
||||
filePath = bot.filePathRoot + "/Output/" + TRADES_FOLDER_NAME + '/' + dateForPath;
|
||||
|
||||
charlyStorage.getTextFile(filePath, fileName, onNextFileReceived, true);
|
||||
@@ -490,7 +487,7 @@ What is the lastFile pointer?
|
||||
|
||||
findEndOfHole();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
|
||||
try {
|
||||
@@ -548,11 +545,11 @@ What is the lastFile pointer?
|
||||
We will need these trades at the end of the process.
|
||||
*/
|
||||
|
||||
tradesWithHole = trades;
|
||||
tradesWithHole = trades;
|
||||
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> findNextHole -> checkHolesInFile -> Checking File '" + fileName + "' @ " + filePath + " - " + trades.length + " records in it."); }
|
||||
|
||||
if (currentTradeId === FIRST_TRADE_RECORD_ID || currentTradeId === UNKNOWN_TRADE_RECORD_ID) {
|
||||
if (currentTradeId === FIRST_TRADE_RECORD_ID || currentTradeId === UNKNOWN_TRADE_RECORD_ID) {
|
||||
|
||||
/*
|
||||
Here we dont know the currentTradeId, so we might take it directly from the file. There will be a problem though if the market starts
|
||||
@@ -714,7 +711,7 @@ What is the lastFile pointer?
|
||||
return;
|
||||
}
|
||||
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE);
|
||||
callBackFunction(global.DEFAULT_OK_RESPONSE);
|
||||
return;
|
||||
} catch (err) {
|
||||
logger.write(MODULE_NAME, "[ERROR] start -> findNextHole -> findEndOfHole -> onStatusReportWritten -> err = " + err.message);
|
||||
@@ -753,10 +750,9 @@ What is the lastFile pointer?
|
||||
|
||||
findEndOfHole();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (err.result === global.DEFAULT_OK_RESPONSE.result)
|
||||
{
|
||||
if (err.result === global.DEFAULT_OK_RESPONSE.result) {
|
||||
let trades;
|
||||
|
||||
try {
|
||||
@@ -771,7 +767,7 @@ What is the lastFile pointer?
|
||||
|
||||
findEndOfHole();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if (trades.length === 0) {
|
||||
|
||||
@@ -835,9 +831,7 @@ What is the lastFile pointer?
|
||||
|
||||
exchangeCallTime = new Date();
|
||||
|
||||
let poloniexApiClient = POLONIEX_CLIENT_MODULE.newPoloniexAPIClient(global.EXCHANGE_KEYS[global.EXCHANGE_NAME].Key, global.EXCHANGE_KEYS[global.EXCHANGE_NAME].Secret);
|
||||
|
||||
poloniexApiClient.API.returnPublicTradeHistory(market.assetA, market.assetB, startTime, endTime, onExchangeCallReturned);
|
||||
EXCHANGE_API.getPublicTradeHistory(market.assetA, market.assetB, startTime, endTime, onExchangeCallReturned);
|
||||
|
||||
} catch (err) {
|
||||
logger.write(MODULE_NAME, "[ERROR] start -> getTheTrades -> err = " + err.message);
|
||||
@@ -859,12 +853,7 @@ What is the lastFile pointer?
|
||||
logger.write(MODULE_NAME, "[INFO] start -> onExchangeCallReturned -> Call time recorded = " + timeDifference + " seconds.");
|
||||
}
|
||||
|
||||
poloniexApiClient.API.analizeResponse(logger, err, exchangeResponse, callBackFunction, onResponseOk);
|
||||
|
||||
function onResponseOk() {
|
||||
|
||||
tradesReadyToBeSaved(exchangeResponse);
|
||||
}
|
||||
tradesReadyToBeSaved(exchangeResponse);
|
||||
|
||||
} catch (err) {
|
||||
logger.write(MODULE_NAME, "[ERROR] start -> onExchangeCallReturned -> err = " + err.message);
|
||||
@@ -1104,9 +1093,9 @@ What is the lastFile pointer?
|
||||
logger.write(MODULE_NAME, "[INFO] start -> tradesReadyToBeSaved -> nextRecord -> onFileCreated -> Content written = " + fileContent);
|
||||
}
|
||||
|
||||
logger.write(MODULE_NAME, "[INFO] start -> tradesReadyToBeSaved -> nextRecord -> onFileCreated -> Finished with File @ " + market.assetA + "_" + market.assetB);
|
||||
logger.write(MODULE_NAME, "[INFO] start -> tradesReadyToBeSaved -> nextRecord -> onFileCreated -> Records inserted = " + fileRecordCounter);
|
||||
logger.write(MODULE_NAME, "[INFO] start -> tradesReadyToBeSaved -> nextRecord -> onFileCreated -> Path = " + filePath + "/" + fileName + "");
|
||||
logger.write(MODULE_NAME, "[INFO] start -> tradesReadyToBeSaved -> nextRecord -> onFileCreated -> Finished with File @ " + market.assetA + "_" + market.assetB);
|
||||
logger.write(MODULE_NAME, "[INFO] start -> tradesReadyToBeSaved -> nextRecord -> onFileCreated -> Records inserted = " + fileRecordCounter);
|
||||
logger.write(MODULE_NAME, "[INFO] start -> tradesReadyToBeSaved -> nextRecord -> onFileCreated -> Path = " + filePath + "/" + fileName + "");
|
||||
|
||||
controlLoop();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, BLOB_STORAGE, STATUS_REPORT, POLONIEX_CLIENT_MODULE) {
|
||||
exports.newUserBot = function newUserBot(bot, logger, COMMONS, UTILITIES, BLOB_STORAGE, STATUS_REPORT, EXCHANGE_API) {
|
||||
|
||||
const FULL_LOG = true;
|
||||
const LOG_FILE_CONTENT = false;
|
||||
@@ -8,8 +8,6 @@
|
||||
|
||||
const MODULE_NAME = "User Bot";
|
||||
|
||||
const EXCHANGE_NAME = "Poloniex";
|
||||
|
||||
const TRADES_FOLDER_NAME = "Trades";
|
||||
|
||||
thisObject = {
|
||||
@@ -20,7 +18,6 @@
|
||||
let charlyStorage = BLOB_STORAGE.newBlobStorage(bot, logger);
|
||||
|
||||
let utilities = UTILITIES.newCloudUtilities(bot, logger);
|
||||
let poloniexApiClient = POLONIEX_CLIENT_MODULE.newPoloniexAPIClient(global.EXCHANGE_KEYS[global.EXCHANGE_NAME].Key, global.EXCHANGE_KEYS[global.EXCHANGE_NAME].Secret);
|
||||
|
||||
let statusDependencies;
|
||||
|
||||
@@ -58,30 +55,30 @@
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
We are going to generate 2 files:
|
||||
|
||||
A. The first one will contain all the trades of the current minute and will be store in a folder that we will create for this if it does not exist.
|
||||
This file will be incomplete, since we are at the current minute and some trades will happen after we retrieve the information from the exchange,
|
||||
but this is not a problem, since the second file is going to fix this. This file is only usefull for viewing a partial candle as it is being built
|
||||
at the head of the market.
|
||||
|
||||
B. The second file will contain all the trades of the previous minute. This will override the incomplete file written a minute before.
|
||||
|
||||
FILE FORMAT
|
||||
-----------
|
||||
|
||||
Array of records with this information:
|
||||
|
||||
1. Trade Id provided by the exchange.
|
||||
2. Trade Type: "buy" or "sell"
|
||||
3. Trade Rate: the rate of the transaction.
|
||||
4. Amount Asset A
|
||||
5. Amount Asset B
|
||||
6. Time: Seconds and Milliseconds the trade happened. (the rest of the time and date whoever reads the file already know it since it is organized in folders according to this.)
|
||||
|
||||
*/
|
||||
/*
|
||||
|
||||
We are going to generate 2 files:
|
||||
|
||||
A. The first one will contain all the trades of the current minute and will be store in a folder that we will create for this if it does not exist.
|
||||
This file will be incomplete, since we are at the current minute and some trades will happen after we retrieve the information from the exchange,
|
||||
but this is not a problem, since the second file is going to fix this. This file is only usefull for viewing a partial candle as it is being built
|
||||
at the head of the market.
|
||||
|
||||
B. The second file will contain all the trades of the previous minute. This will override the incomplete file written a minute before.
|
||||
|
||||
FILE FORMAT
|
||||
-----------
|
||||
|
||||
Array of records with this information:
|
||||
|
||||
1. Trade Id provided by the exchange.
|
||||
2. Trade Type: "buy" or "sell"
|
||||
3. Trade Rate: the rate of the transaction.
|
||||
4. Amount Asset A
|
||||
5. Amount Asset B
|
||||
6. Time: Seconds and Milliseconds the trade happened. (the rest of the time and date whoever reads the file already know it since it is organized in folders according to this.)
|
||||
|
||||
*/
|
||||
|
||||
function start(callBackFunction) {
|
||||
|
||||
@@ -101,11 +98,11 @@ Array of records with this information:
|
||||
let filePathA;
|
||||
let filePathB;
|
||||
|
||||
let reportFilePath = EXCHANGE_NAME + "/Processes/" + bot.process;
|
||||
let reportFilePath = global.EXCHANGE_NAME + "/Processes/" + bot.process;
|
||||
|
||||
let exchangeCallTime;
|
||||
|
||||
firstSteps();
|
||||
firstSteps();
|
||||
|
||||
function firstSteps() {
|
||||
|
||||
@@ -114,7 +111,7 @@ Array of records with this information:
|
||||
if (FULL_LOG === true) { logger.write(MODULE_NAME, "[INFO] start -> firstSteps -> Entering function."); }
|
||||
|
||||
currentDate = bot.processDatetime;
|
||||
|
||||
|
||||
previousMinute = new Date(currentDate.valueOf() - 60000);
|
||||
|
||||
dateForPathA = currentDate.getUTCFullYear() + '/' + utilities.pad(currentDate.getUTCMonth() + 1, 2) + '/' + utilities.pad(currentDate.getUTCDate(), 2) + '/' + utilities.pad(currentDate.getUTCHours(), 2) + '/' + utilities.pad(currentDate.getUTCMinutes(), 2);
|
||||
@@ -123,7 +120,7 @@ Array of records with this information:
|
||||
filePathA = bot.filePathRoot + "/Output/" + TRADES_FOLDER_NAME + '/' + dateForPathA;
|
||||
filePathB = bot.filePathRoot + "/Output/" + TRADES_FOLDER_NAME + '/' + dateForPathB;
|
||||
|
||||
getTheTrades();
|
||||
getTheTrades();
|
||||
|
||||
} catch (err) {
|
||||
logger.write(MODULE_NAME, "[ERROR] start -> firstSteps -> err = " + err.message);
|
||||
@@ -149,7 +146,7 @@ Array of records with this information:
|
||||
|
||||
exchangeCallTime = new Date();
|
||||
|
||||
poloniexApiClient.API.returnPublicTradeHistory(market.assetA, market.assetB, startTime, endTime, onExchangeCallReturned);
|
||||
EXCHANGE_API.getPublicTradeHistory(market.assetA, market.assetB, startTime, endTime, onExchangeCallReturned);
|
||||
|
||||
} catch (err) {
|
||||
logger.write(MODULE_NAME, "[ERROR] start -> getTheTrades -> err = " + err.message);
|
||||
@@ -170,12 +167,7 @@ Array of records with this information:
|
||||
logger.write(MODULE_NAME, "[INFO] start -> onExchangeCallReturned -> Call time recorded = " + timeDifference + " seconds.");
|
||||
}
|
||||
|
||||
poloniexApiClient.API.analizeResponse(logger, err, exchangeResponse, callBackFunction, onResponseOk);
|
||||
|
||||
function onResponseOk() {
|
||||
|
||||
tradesReadyToBeSaved(exchangeResponse);
|
||||
}
|
||||
tradesReadyToBeSaved(exchangeResponse);
|
||||
|
||||
} catch (err) {
|
||||
logger.write(MODULE_NAME, "[ERROR] start -> onExchangeCallReturned -> err = " + err.message);
|
||||
@@ -259,7 +251,7 @@ Array of records with this information:
|
||||
|
||||
logger.write(MODULE_NAME, "[INFO] start -> tradesReadyToBeSaved -> onFirstFileACreated -> Finished with File A @ " + market.assetA + "_" + market.assetB);
|
||||
logger.write(MODULE_NAME, "[INFO] start -> tradesReadyToBeSaved -> onFirstFileACreated -> Records inserted = " + fileRecordCounterA);
|
||||
logger.write(MODULE_NAME, "[INFO] start -> tradesReadyToBeSaved -> onFirstFileACreated -> Path = " + filePathA + "/" + fileNameA + "");
|
||||
logger.write(MODULE_NAME, "[INFO] start -> tradesReadyToBeSaved -> onFirstFileACreated -> Path = " + filePathA + "/" + fileNameA + "");
|
||||
|
||||
generateFileB();
|
||||
}
|
||||
@@ -326,7 +318,7 @@ Array of records with this information:
|
||||
|
||||
logger.write(MODULE_NAME, "[INFO] start -> tradesReadyToBeSaved -> onFileBCreated -> Finished with File B @ " + market.assetA + "_" + market.assetB);
|
||||
logger.write(MODULE_NAME, "[INFO] start -> tradesReadyToBeSaved -> onFileBCreated -> Content written -> Records inserted = " + fileRecordCounterB);
|
||||
logger.write(MODULE_NAME, "[INFO] start -> tradesReadyToBeSaved -> onFileBCreated -> Content written -> Path = " + filePathB + "/" + fileNameB + "");
|
||||
logger.write(MODULE_NAME, "[INFO] start -> tradesReadyToBeSaved -> onFileBCreated -> Content written -> Path = " + filePathB + "/" + fileNameB + "");
|
||||
|
||||
writeStatusReport();
|
||||
}
|
||||
+6
-6
@@ -18,15 +18,15 @@
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Debug'" />
|
||||
<PropertyGroup Condition="'$(Configuration)' == 'Release'" />
|
||||
<ItemGroup>
|
||||
<Compile Include="Poloniex-Historic-Trades\User.Bot.js" />
|
||||
<Compile Include="Poloniex-Hole-Fixing\User.Bot.js" />
|
||||
<Compile Include="Poloniex-Live-Trades\User.Bot.js" />
|
||||
<Compile Include="Historic-Trades\User.Bot.js" />
|
||||
<Compile Include="Hole-Fixing\User.Bot.js" />
|
||||
<Compile Include="Live-Trades\User.Bot.js" />
|
||||
<Content Include="this.bot.config.json" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Folder Include="Poloniex-Historic-Trades" />
|
||||
<Folder Include="Poloniex-Hole-Fixing" />
|
||||
<Folder Include="Poloniex-Live-Trades" />
|
||||
<Folder Include="Historic-Trades\" />
|
||||
<Folder Include="Hole-Fixing\" />
|
||||
<Folder Include="Live-Trades\" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.Common.targets" Condition="Exists('$(MSBuildExtensionsPath)\$(MSBuildToolsVersion)\Microsoft.Common.props')" />
|
||||
<!--Do not delete the following Import Project. While this appears to do nothing it is a marker for setting TypeScript properties before our import that depends on them.-->
|
||||
|
||||
+14
-14
@@ -1,7 +1,7 @@
|
||||
{
|
||||
"displayName": "Charly",
|
||||
"codeName": "AACharly",
|
||||
"type": "Extraction",
|
||||
"type": "Sensor",
|
||||
"version": {
|
||||
"major": 1,
|
||||
"minor": 0,
|
||||
@@ -12,7 +12,7 @@
|
||||
"dataSetVersion": "dataSet.V1",
|
||||
"processes": [
|
||||
{
|
||||
"name": "Poloniex-Live-Trades",
|
||||
"name": "Live-Trades",
|
||||
"description": "Retrieves the trades done at the current and the previous minute and saves them at the storage account.",
|
||||
"startMode": {
|
||||
"allMonths": {
|
||||
@@ -45,24 +45,24 @@
|
||||
"major": 1,
|
||||
"minor": 0
|
||||
},
|
||||
"process": "Poloniex-Live-Trades",
|
||||
"process": "Live-Trades",
|
||||
"dataSetVersion": "dataSet.V1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Poloniex-Historic-Trades",
|
||||
"name": "Historic-Trades",
|
||||
"description": "Retrieves and saves the historical trades in batches going backwards from the current time until reaching the begining of the market.",
|
||||
"startMode": {
|
||||
"allMonths": {
|
||||
"run": "false",
|
||||
"minYear": "2014",
|
||||
"maxYear": "2018"
|
||||
"maxYear": "2020"
|
||||
},
|
||||
"oneMonth": {
|
||||
"run": "true",
|
||||
"year": "2018",
|
||||
"month": "04"
|
||||
"month": "01"
|
||||
},
|
||||
"noTime": {
|
||||
"run": "false"
|
||||
@@ -84,7 +84,7 @@
|
||||
"major": 1,
|
||||
"minor": 0
|
||||
},
|
||||
"process": "Poloniex-Live-Trades",
|
||||
"process": "Live-Trades",
|
||||
"dataSetVersion": "dataSet.V1"
|
||||
},
|
||||
{
|
||||
@@ -94,19 +94,19 @@
|
||||
"major": 1,
|
||||
"minor": 0
|
||||
},
|
||||
"process": "Poloniex-Historic-Trades",
|
||||
"process": "Historic-Trades",
|
||||
"dataSetVersion": "dataSet.V1"
|
||||
}
|
||||
]
|
||||
},
|
||||
{
|
||||
"name": "Poloniex-Hole-Fixing",
|
||||
"name": "Hole-Fixing",
|
||||
"description": "Scans the trades saved by the Live Trades and Historic Trades processes searching for missing records. Once a hole is found on the data set, it patches it by retrieving the missing records from the exchange.",
|
||||
"startMode": {
|
||||
"allMonths": {
|
||||
"run": "true",
|
||||
"minYear": "2018",
|
||||
"maxYear": "2018"
|
||||
"maxYear": "2019"
|
||||
},
|
||||
"oneMonth": {
|
||||
"run": "false",
|
||||
@@ -133,7 +133,7 @@
|
||||
"major": 1,
|
||||
"minor": 0
|
||||
},
|
||||
"process": "Poloniex-Live-Trades",
|
||||
"process": "Live-Trades",
|
||||
"dataSetVersion": "dataSet.V1"
|
||||
},
|
||||
{
|
||||
@@ -143,7 +143,7 @@
|
||||
"major": 1,
|
||||
"minor": 0
|
||||
},
|
||||
"process": "Poloniex-Historic-Trades",
|
||||
"process": "Historic-Trades",
|
||||
"dataSetVersion": "dataSet.V1"
|
||||
},
|
||||
{
|
||||
@@ -153,7 +153,7 @@
|
||||
"major": 1,
|
||||
"minor": 0
|
||||
},
|
||||
"process": "Poloniex-Hole-Fixing",
|
||||
"process": "Hole-Fixing",
|
||||
"dataSetVersion": "dataSet.V1",
|
||||
"dataSetSection": "Month"
|
||||
},
|
||||
@@ -164,7 +164,7 @@
|
||||
"major": 1,
|
||||
"minor": 0
|
||||
},
|
||||
"process": "Poloniex-Hole-Fixing",
|
||||
"process": "Hole-Fixing",
|
||||
"dataSetVersion": "dataSet.V1"
|
||||
}
|
||||
]
|
||||
|
||||
Reference in new issue
Block a user