Compare commits

..

12 Commits

Author SHA1 Message Date
Joe Tretter
abf300501f Fix price used to determine volume if the last Execution was higher than the max price. 2021-01-14 07:17:57 -06:00
Joe Tretter
8c464795b0 Fix dynamic currencies in the initialization 2021-01-09 21:43:29 -06:00
Joe Tretter
468124421d misc fixes in volume calc 2021-01-07 16:39:14 -06:00
Joe Tretter
b20a141daf Fix calculation of multibuy 2021-01-07 15:06:27 -06:00
Joe Tretter
8693543bb2 Fix scaled trades for big jumps. 2021-01-07 11:02:54 -06:00
Joe Tretter
2164d63e96 Misc small fixes 2021-01-05 14:26:00 -06:00
Joe Tretter
3882bc587f Merge branch 'master' of kawomi.com:/var/local/git/krakentrading 2021-01-04 11:37:01 -06:00
Joe Tretter
65624a5206 ... 2021-01-04 11:36:23 -06:00
Joe Tretter
8ba924c19d Merge branch 'master' of ssh://kawomi.com/var/local/git/krakentrading into master 2020-12-31 15:51:15 -06:00
Joe Tretter
388965e34c Make datafile dynamic 2020-12-31 15:51:05 -06:00
Joe Tretter
205fc92347 Merge branch 'master' of kawomi.com:/var/local/git/krakentrading 2020-12-24 18:12:22 -06:00
Joe Tretter
d0aa9dd413 Add NG-flow with bugfixes 2020-12-24 18:11:28 -06:00
2 changed files with 2816 additions and 1262 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -2,8 +2,14 @@
2020-01-09 - get the gains generated by my automated ETC trading. 2020-01-09 - get the gains generated by my automated ETC trading.
2020-10-23 - fix problem because API requires windowing to handle more than 50 rows, implemented windowing. 2020-10-23 - fix problem because API requires windowing to handle more than 50 rows, implemented windowing.
2020-12-02 - change to persist transactions and handle pairs as provided by commandline parameter. 2020-12-02 - change to persist transactions and handle pairs as provided by commandline parameter.
2020-12-04 - handle commandline inlcuding verbosity of output.
*/ */
const yargs = require('yargs/yargs')
const { hideBin } = require('yargs/helpers')
const argv = yargs(hideBin(process.argv)).argv
const key = 'SOOOJ7OhVCOpJE4DAWz8v5B25UpdYya9buF8DFAkHzmUab5E9i0PlEPh'; // API Key const key = 'SOOOJ7OhVCOpJE4DAWz8v5B25UpdYya9buF8DFAkHzmUab5E9i0PlEPh'; // API Key
const secret = 'UytAbgU8ty3n5a+JhaoIlcfh8zM4OBGY6PCC+Cfg2NI4waVzM52BBp9qmmyczrTDQpeha8q3nHeE/p7wNWKiVA=='; // API Private Key const secret = 'UytAbgU8ty3n5a+JhaoIlcfh8zM4OBGY6PCC+Cfg2NI4waVzM52BBp9qmmyczrTDQpeha8q3nHeE/p7wNWKiVA=='; // API Private Key
const KrakenClient = require('kraken-api'); const KrakenClient = require('kraken-api');
@@ -34,20 +40,25 @@ const utcToLocal = (utc) => {
(async () => { (async () => {
try { try {
// get the pair to process from the first parameter and fall back if not provided. // get the pair to process from the first parameter and fall back if not provided.
let thePair=process.argv[2]; let thePair=argv.pair;
if (thePair===undefined) { if (thePair===undefined) {
thePair="XXMRZUSD"; thePair="XXMRZUSD";
} }
thePair=thePair.toUpperCase(); // the pairs are always upper case. thePair=thePair.toUpperCase(); // the pairs are always upper case.
console.log("Processing pair : ", thePair); console.log("Processing pair : ", thePair);
let allTrades=loadData("allTrades.json"); let dataFile = argv.dataFile;
if (dataFile===undefined) {
dataFile = "allTrades.json";
}
let allTrades=loadData(dataFile);
let params={ ofs : 0 }; let params={ ofs : 0 };
let maxTimestamp=0; let maxTimestamp=0;
allTrades.forEach(dta=>{if (dta.time>maxTimestamp) {maxTimestamp=dta.time;} }); allTrades.forEach(dta=>{if (dta.time>maxTimestamp) {maxTimestamp=dta.time;} });
params.start=maxTimestamp; params.start=maxTimestamp;
console.log("Max-Timestamp : ",maxTimestamp); console.log("Max-Timestamp : ",maxTimestamp);
if (!argv.skipRequestTrades) {
let allTransactions = await kraken.api('TradesHistory', params); let allTransactions = await kraken.api('TradesHistory', params);
let allTradeIDs=Object.keys(allTransactions.result.trades); let allTradeIDs=Object.keys(allTransactions.result.trades);
let numTrans=allTradeIDs.length; let numTrans=allTradeIDs.length;
@@ -59,7 +70,7 @@ const utcToLocal = (utc) => {
// the timestamp is inclusive, therefore we have to skip that record. // the timestamp is inclusive, therefore we have to skip that record.
if (theTrade.time === maxTimestamp) { continue; } if (theTrade.time === maxTimestamp) { continue; }
console.log(theTrade); if (argv.v) { console.log(theTrade); }
allTrades.push(theTrade); allTrades.push(theTrade);
if ((params.ofs % 50) == 0) { if ((params.ofs % 50) == 0) {
@@ -73,8 +84,8 @@ const utcToLocal = (utc) => {
// sort the trades by time; oldest first. // sort the trades by time; oldest first.
allTrades=allTrades.sort(function (a,b){return(a.time - b.time);}); allTrades=allTrades.sort(function (a,b){return(a.time - b.time);});
storeData(allTrades,dataFile);
storeData(allTrades,"allTrades.json"); }
let sumUSD=0; let sumUSD=0;
let sumCommission=0; let sumCommission=0;
@@ -85,7 +96,7 @@ const utcToLocal = (utc) => {
numTrades++; numTrades++;
let tradeLocalTime=utcToLocal(new Date(theTrade.time * 1000)).toISOString().substr(0,19).replace('T',' '); let tradeLocalTime=utcToLocal(new Date(theTrade.time * 1000)).toISOString().substr(0,19).replace('T',' ');
console.log(`${tradeLocalTime} [${theTrade.pair}] ${theTrade.type.substring(0,1)}#${Number(theTrade.vol).toFixed(4).padStart(10," ")}@${Number(theTrade.price).toFixed(2).padStart(8," ")} -> ${Number(theTrade.cost).toFixed(2).padStart(9," ")}(-${Number(theTrade.fee).toFixed(3).padStart(5," ")})`); if (argv.v) {console.log(`${tradeLocalTime} [${theTrade.pair}] ${theTrade.type.substring(0,1)}#${Number(theTrade.vol).toFixed(4).padStart(10," ")}@${Number(theTrade.price).toFixed(2).padStart(8," ")} -> ${Number(theTrade.cost).toFixed(2).padStart(9," ")}(-${Number(theTrade.fee).toFixed(3).padStart(5," ")})`);}
// selling adds $$$ to our Account, buying takes money out of the account // selling adds $$$ to our Account, buying takes money out of the account
let multiplier=theTrade.type==="buy"?-1:1; let multiplier=theTrade.type==="buy"?-1:1;