Code readability and added the forgotten mocks
This commit is contained in:
parent
134eaaa518
commit
7accdaa84f
12 changed files with 126 additions and 96 deletions
|
|
@ -1,5 +1,6 @@
|
|||
const configManager = require('./new-config-manager')
|
||||
const ccxt = require('./plugins/exchange/ccxt')
|
||||
const mockExchange = require('./plugins/exchange/mock-exchange')
|
||||
|
||||
function lookupExchange (settings, cryptoCode) {
|
||||
const exchange = configManager.getWalletSettings(cryptoCode, settings.config).exchange
|
||||
|
|
@ -20,12 +21,22 @@ function fetchExchange (settings, cryptoCode) {
|
|||
|
||||
function buy (settings, cryptoAtoms, fiatCode, cryptoCode) {
|
||||
return fetchExchange(settings, cryptoCode)
|
||||
.then(r => ccxt.trade('buy', r.account, cryptoAtoms, fiatCode, cryptoCode, r.exchangeName))
|
||||
.then(r => {
|
||||
if (r.exchangeName === 'mock-exchange') {
|
||||
return mockExchange.buy(cryptoAtoms, fiatCode, cryptoCode)
|
||||
}
|
||||
return ccxt.trade('buy', r.account, cryptoAtoms, fiatCode, cryptoCode, r.exchangeName)
|
||||
})
|
||||
}
|
||||
|
||||
function sell (settings, cryptoAtoms, fiatCode, cryptoCode) {
|
||||
return fetchExchange(settings, cryptoCode)
|
||||
.then(r => ccxt.trade('sell', r.account, cryptoAtoms, fiatCode, cryptoCode, r.exchangeName))
|
||||
.then(r => {
|
||||
if (r.exchangeName === 'mock-exchange') {
|
||||
return mockExchange.sell(cryptoAtoms, fiatCode, cryptoCode)
|
||||
}
|
||||
return ccxt.trade('sell', r.account, cryptoAtoms, fiatCode, cryptoCode, r.exchangeName)
|
||||
})
|
||||
}
|
||||
|
||||
function active (settings, cryptoCode) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue