Skip to content

Commit

Permalink
theocean parseOrder status = failed case
Browse files Browse the repository at this point in the history
  • Loading branch information
kroitor committed Oct 19, 2018
1 parent 55cd315 commit 0c431d1
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions js/theocean.js
Original file line number Diff line number Diff line change
Expand Up @@ -942,11 +942,15 @@ module.exports = class theocean extends Exchange {
let lastTradeTimestamp = undefined;
let timeline = this.safeValue (order, 'timeline');
let trades = undefined;
let status = undefined;
if (timeline !== undefined) {
let numEvents = timeline.length;
if (numEvents > 0) {
// status = this.parseOrderStatus (this.safeString (timeline[numEvents - 1], 'action'));
let timelineEventsGroupedByAction = this.groupBy (timeline, 'action');
if ('error' in timelineEventsGroupedByAction) {
status = 'failed';
}
if ('placed' in timelineEventsGroupedByAction) {
let placeEvents = this.safeValue (timelineEventsGroupedByAction, 'placed');
if (amount === undefined) {
Expand Down Expand Up @@ -1014,13 +1018,14 @@ module.exports = class theocean extends Exchange {
'сurrency': feeCurrency,
};
}
let status = undefined;
let amountPrecision = market ? market['precision']['amount'] : 8;
if (remaining !== undefined) {
status = 'open';
const rest = remaining - failedAmount - deadAmount - prunedAmount;
if (rest < Math.pow (10, -amountPrecision)) {
status = (filled < amount) ? 'canceled' : 'closed';
if (status === undefined) {
status = 'open';
const rest = remaining - failedAmount - deadAmount - prunedAmount;
if (rest < Math.pow (10, -amountPrecision)) {
status = (filled < amount) ? 'canceled' : 'closed';
}
}
}
let result = {
Expand Down

0 comments on commit 0c431d1

Please sign in to comment.