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

@ -517,8 +517,9 @@ function plugins (settings, deviceId) {
const execute = tradeEntry.type === 'buy' ? exchange.buy : exchange.sell
return recordTrade(tradeEntry)
.then(newEntry =>
execute(settings, tradeEntry, newEntry.id)
.then(newEntry => {
tradeEntry.tradeId = newEntry.id
return execute(settings, tradeEntry)
.catch(err => {
updateTradeEntry(tradeEntry, newEntry, err)
.then(() => {
@ -526,7 +527,7 @@ function plugins (settings, deviceId) {
throw err
})
})
)
})
}
function updateTradeEntry (tradeEntry, newEntry, err) {