fix exchanges, kraken
This commit is contained in:
parent
35fb620b38
commit
f70211d774
5 changed files with 72 additions and 54 deletions
|
|
@ -31,7 +31,7 @@ function atomic (machineTx, pi) {
|
|||
.then(r => {
|
||||
pp('DEBUG701.5')(r)
|
||||
return insertNewBills(billRows, machineTx)
|
||||
.then(_.constant(_.set('bills', machineTx.bills, r)))
|
||||
.then(newBills => _.set('newBills', newBills, r))
|
||||
.then(pp('DEBUG702'))
|
||||
})
|
||||
})
|
||||
|
|
@ -167,6 +167,7 @@ function insertNewBills (billRows, machineTx) {
|
|||
const sql = pgp.helpers.insert(dbBills, columns, 'bills')
|
||||
|
||||
return db.none(sql)
|
||||
.then(() => bills)
|
||||
}
|
||||
|
||||
function upsert (dbTx, preProcessedTx) {
|
||||
|
|
@ -225,7 +226,7 @@ function isClearToSend (oldTx, newTx) {
|
|||
|
||||
function postProcess (r, pi) {
|
||||
console.log('DEBUG701: %j', r)
|
||||
registerTrades(pi, r.bills)
|
||||
registerTrades(pi, r.newBills)
|
||||
|
||||
if (isClearToSend(r.dbTx, r.tx)) {
|
||||
return pi.sendCoins(r.tx)
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
// Note: Using DeX3/npm-kraken-api to adjust timeout time
|
||||
const Kraken = require('kraken-api')
|
||||
|
||||
const common = require('../../common/kraken')
|
||||
|
||||
var PAIRS = common.PAIRS
|
||||
|
|
@ -14,7 +16,7 @@ function sell (account, cryptoAtoms, fiatCode, cryptoCode) {
|
|||
}
|
||||
|
||||
function trade (account, type, cryptoAtoms, fiatCode, cryptoCode) {
|
||||
const kraken = new Kraken(account.apiKey, account.privateKey)
|
||||
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]
|
||||
|
|
@ -28,14 +30,11 @@ function trade (account, type, cryptoAtoms, fiatCode, cryptoCode) {
|
|||
}
|
||||
|
||||
return new Promise((resolve, reject) => {
|
||||
kraken.api('AddOrder', orderInfo, function (error, response) {
|
||||
if (error) {
|
||||
// TODO: handle: EOrder:Order minimum not met (volume too low)
|
||||
return reject(error)
|
||||
} else {
|
||||
console.log('DEBUG900: %j', response)
|
||||
return resolve()
|
||||
}
|
||||
kraken.api('AddOrder', orderInfo, (error, response) => {
|
||||
if (error) return reject(error)
|
||||
|
||||
console.log('DEBUG900: %j', response)
|
||||
return resolve()
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -9,7 +9,7 @@ const INCOMING_TX_INTERVAL = 30 * T.seconds
|
|||
const LIVE_INCOMING_TX_INTERVAL = 5 * T.seconds
|
||||
const UNNOTIFIED_INTERVAL = 10 * T.seconds
|
||||
const SWEEP_HD_INTERVAL = T.minute
|
||||
const TRADE_INTERVAL = 10 * T.seconds
|
||||
const TRADE_INTERVAL = 60 * T.seconds
|
||||
const PONG_INTERVAL = 10 * T.seconds
|
||||
const PONG_CLEAR_INTERVAL = 1 * T.day
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue