WIP
This commit is contained in:
parent
45e6e2b82d
commit
2779dcd6f3
5 changed files with 34 additions and 20 deletions
|
|
@ -335,6 +335,7 @@ function plugins (settings, deviceId) {
|
|||
|
||||
const market = [fiatCode, cryptoCode].join('')
|
||||
|
||||
console.log('DEBUG505')
|
||||
if (!exchange.active(settings, cryptoCode)) return
|
||||
|
||||
logger.debug('[%s] Pushing trade: %d', market, cryptoAtoms)
|
||||
|
|
@ -351,6 +352,7 @@ function plugins (settings, deviceId) {
|
|||
const market = [fiatCode, cryptoCode].join('')
|
||||
|
||||
const marketTradesQueues = tradesQueues[market]
|
||||
console.log('DEBUG504: %j', marketTradesQueues)
|
||||
if (!marketTradesQueues || marketTradesQueues.length === 0) return null
|
||||
|
||||
logger.debug('[%s] tradesQueues size: %d', market, marketTradesQueues.length)
|
||||
|
|
@ -391,6 +393,7 @@ function plugins (settings, deviceId) {
|
|||
}
|
||||
|
||||
function executeTrades () {
|
||||
console.log('DEBUG500')
|
||||
return machineLoader.getMachines()
|
||||
.then(devices => {
|
||||
const deviceIds = devices.map(device => device.deviceId)
|
||||
|
|
@ -411,6 +414,7 @@ function plugins (settings, deviceId) {
|
|||
}
|
||||
|
||||
function executeTradesForMarket (settings, fiatCode, cryptoCode) {
|
||||
console.log('DEBUG501: %s, %j', cryptoCode, exchange.active(settings, cryptoCode))
|
||||
if (!exchange.active(settings, cryptoCode)) return
|
||||
|
||||
const market = [fiatCode, cryptoCode].join('')
|
||||
|
|
@ -418,6 +422,8 @@ function plugins (settings, deviceId) {
|
|||
|
||||
if (tradeEntry === null || tradeEntry.cryptoAtoms.eq(0)) return
|
||||
|
||||
console.log('DEBUG502')
|
||||
|
||||
return executeTradeForType(tradeEntry)
|
||||
.catch(err => {
|
||||
tradesQueues[market].push(tradeEntry)
|
||||
|
|
@ -435,6 +441,8 @@ function plugins (settings, deviceId) {
|
|||
const tradeEntry = expand(_tradeEntry)
|
||||
const execute = tradeEntry.type === 'buy' ? exchange.buy : exchange.sell
|
||||
|
||||
console.log('DEBUG503')
|
||||
|
||||
return execute(settings, tradeEntry.cryptoAtoms, tradeEntry.fiatCode, tradeEntry.cryptoCode)
|
||||
.then(() => recordTrade(tradeEntry))
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue