refactor: exchanges config validation and error handling

This commit is contained in:
José Oliveira 2021-05-11 18:57:46 +01:00 committed by Josh Harvey
parent 60a19af1a8
commit dabe21f834
6 changed files with 34 additions and 20 deletions

View file

@ -25,6 +25,7 @@ function trade (side, account, cryptoAtoms, fiatCode, cryptoCode, exchangeName)
if (ORDER_TYPE === ORDER_TYPES.MARKET) {
return exchange.createOrder(symbol, ORDER_TYPES.MARKET, side, amount, null, options)
}
return exchange.fetchOrderBook(symbol)
.then(orderBook => {
const price = calculatePrice(side, amount, orderBook).toFixed(DEFAULT_PRICE_PRECISION)