refactor: add trade id to trade entry object

This commit is contained in:
José Oliveira 2021-06-29 13:59:37 +01:00 committed by Josh Harvey
parent 700244e45b
commit 9b4bae4097
3 changed files with 10 additions and 8 deletions

View file

@ -19,25 +19,25 @@ function fetchExchange (settings, cryptoCode) {
})
}
function buy (settings, tradeEntry, tradeId) {
function buy (settings, tradeEntry) {
const { cryptoAtoms, fiatCode, cryptoCode } = tradeEntry
return fetchExchange(settings, cryptoCode)
.then(r => {
if (r.exchangeName === 'mock-exchange') {
return mockExchange.buy(cryptoAtoms, fiatCode, cryptoCode)
}
return ccxt.trade('buy', r.account, cryptoAtoms, fiatCode, cryptoCode, r.exchangeName, tradeId)
return ccxt.trade('buy', r.account, tradeEntry, r.exchangeName)
})
}
function sell (settings, tradeEntry, tradeId) {
function sell (settings, tradeEntry) {
const { cryptoAtoms, fiatCode, cryptoCode } = tradeEntry
return fetchExchange(settings, cryptoCode)
.then(r => {
if (r.exchangeName === 'mock-exchange') {
return mockExchange.sell(cryptoAtoms, fiatCode, cryptoCode)
}
return ccxt.trade('sell', r.account, cryptoAtoms, fiatCode, cryptoCode, r.exchangeName, tradeId)
return ccxt.trade('sell', r.account, tradeEntry, r.exchangeName)
})
}