Trade on USD Kraken if fiat is other than USD/EUR (#93)

* Trade on USD Kraken if fiat is other than USD/EUR

* Fix array membership logic

* Default to EUR
This commit is contained in:
Neal Conner 2018-02-16 16:15:28 +00:00 committed by Josh Harvey
parent 0c97df42e5
commit bc66b7b843

View file

@ -1,5 +1,6 @@
// Note: Using DeX3/npm-kraken-api to adjust timeout time
const Kraken = require('kraken-api')
const _ = require('lodash/fp')
const common = require('../../common/kraken')
@ -19,11 +20,14 @@ function trade (account, type, cryptoAtoms, fiatCode, cryptoCode) {
const kraken = new Kraken(account.apiKey, account.privateKey, {timeout: 30000})
const amount = common.toUnit(cryptoAtoms, cryptoCode)
const amountStr = amount.toFixed(6)
const pair = PAIRS[cryptoCode][fiatCode]
const pair = _.includes(fiatCode, ['USD', 'EUR'])
? PAIRS[cryptoCode][fiatCode]
: PAIRS[cryptoCode]['EUR']
var orderInfo = {
pair: pair,
type: type,
pair,
type,
ordertype: 'market',
volume: amountStr,
expiretm: '+60'