Skip to content

Instantly share code, notes, and snippets.

@guchimon99
Created January 5, 2018 06:34
Show Gist options
  • Save guchimon99/87661b75bdb4159a41f74eadd0369425 to your computer and use it in GitHub Desktop.
Save guchimon99/87661b75bdb4159a41f74eadd0369425 to your computer and use it in GitHub Desktop.
Zaifの取引履歴のCSVのダウンロード
const fs = require('fs'),
Zaif = require('zaif'),
moment = require('moment')
const output = './trade.csv'
const key = "****",
secret = "****"
const zaif = new Zaif(key, secret)
zaif.tradeHistory()
.then(function(res) {
var csv = "マーケット,取引種別,価格,数量,取引手数料,ボーナス円,日時,コメント\n"
var data = res.return
Object.keys(data).forEach(function(id) {
var d = data[id]
csv += [
d['currency_pair'] || '',
d['your_action'] == 'bid' ? '買い' : '売り',
d['price'] || 0,
d['amount'] || 0,
d['fee_amount'] || 0,
d['bonus'] || '',
d['bouns_yen'] || '',
moment(new Date(d['timestamp']*1000)).format('YYYY-MM-DD hh:mm:ss.000'),
d['commont']
].join(',') + "\n"
})
fs.writeFileSync(output, csv)
})
.catch(function(err) {
console.log(err)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment