Skip to content
This repository has been archived by the owner on Feb 15, 2022. It is now read-only.

Commit

Permalink
setRawMode is not supported on some remote consoles (no tty) (#380)
Browse files Browse the repository at this point in the history
  • Loading branch information
dulacp authored and DeviaVir committed Jul 18, 2017
1 parent 21e2133 commit d8f21fc
Showing 1 changed file with 30 additions and 28 deletions.
58 changes: 30 additions & 28 deletions commands/trade.js
Original file line number Diff line number Diff line change
Expand Up @@ -154,34 +154,36 @@ module.exports = function container (get, set, clear) {
forwardScan()
setInterval(forwardScan, c.poll_trades)
readline.emitKeypressEvents(process.stdin)
process.stdin.setRawMode(true)
process.stdin.on('keypress', function (key, info) {
if (key === 'b' && !info.ctrl ) {
engine.executeSignal('buy')
}
else if (key === 'B' && !info.ctrl) {
engine.executeSignal('buy', null, null, false, true)
}
else if (key === 's' && !info.ctrl) {
engine.executeSignal('sell')
}
else if (key === 'S' && !info.ctrl) {
engine.executeSignal('sell', null, null, false, true)
}
else if ((key === 'c' || key === 'C') && !info.ctrl) {
delete s.buy_order
delete s.sell_order
}
else if ((key === 'm' || key === 'M') && !info.ctrl) {
so.manual = !so.manual
console.log('\nmanual mode: ' + (so.manual ? 'ON' : 'OFF') + '\n')
}
else if (info.name === 'c' && info.ctrl) {
// @todo: cancel open orders before exit
console.log()
process.exit()
}
})
if (process.stdin.setRawMode) {
process.stdin.setRawMode(true)
process.stdin.on('keypress', function (key, info) {
if (key === 'b' && !info.ctrl ) {
engine.executeSignal('buy')
}
else if (key === 'B' && !info.ctrl) {
engine.executeSignal('buy', null, null, false, true)
}
else if (key === 's' && !info.ctrl) {
engine.executeSignal('sell')
}
else if (key === 'S' && !info.ctrl) {
engine.executeSignal('sell', null, null, false, true)
}
else if ((key === 'c' || key === 'C') && !info.ctrl) {
delete s.buy_order
delete s.sell_order
}
else if ((key === 'm' || key === 'M') && !info.ctrl) {
so.manual = !so.manual
console.log('\nmanual mode: ' + (so.manual ? 'ON' : 'OFF') + '\n')
}
else if (info.name === 'c' && info.ctrl) {
// @todo: cancel open orders before exit
console.log()
process.exit()
}
})
}
})
})
return
Expand Down

0 comments on commit d8f21fc

Please sign in to comment.