/
poloniex.js
37 lines (36 loc) · 868 Bytes
/
poloniex.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
const fs = require('fs');
const Line = require('./line.js');
const csv = require('csv')
const argv = require('yargs')
.option('input', {
describe: 'The path of the input file'
})
.option('type', {
describe: 'The type of history file',
choices: ['trade', 'deposit', 'withdraw']
})
.demandOption(['input', 'type'])
.help()
.strict()
.argv
fs.createReadStream(argv.input)
.pipe(csv.parse({columns: true}))
.pipe(csv.transform(function(row){
if (row === null) {
return;
}
var line;
switch (argv.type) {
case 'trade':
line = Line.fromPoloniex(row);
break;
case 'deposit':
line = Line.fromPoloniexDeposit(row);
break;
case 'withdraw':
line = Line.fromPoloniexWithdraw(row);
break;
}
return line.toString() + "\n";
}))
.pipe(process.stdout);