Skip to content
This repository has been archived by the owner on Feb 16, 2020. It is now read-only.

Gekko Broker error bubbling #2324

Merged
merged 2 commits into from
Jul 18, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion exchange/orders/states.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ const states = {
CANCELLED: 'CANCELLED',

// Order was rejected by the exchange
REJECTED: 'REJECTED'
REJECTED: 'REJECTED',

ERROR: 'ERROR'
}

module.exports = states;
18 changes: 10 additions & 8 deletions exchange/orders/sticky.js
Original file line number Diff line number Diff line change
Expand Up @@ -127,13 +127,13 @@ class StickyOrder extends BaseOrder {
}

handleCreate(err, id) {
if(err) {
console.log('handleCreate', err.message);
throw err;
if(this.handleError(err)) {
return;
}

if(!id)
if(!id) {
console.log('BLUP! no id...');
}

// potentailly clean up old order
if(
Expand Down Expand Up @@ -180,9 +180,8 @@ class StickyOrder extends BaseOrder {
this.sticking = true;

this.api.checkOrder(this.id, (err, result) => {
if(err) {
console.log(new Date, 'error creating:', err.message);
throw err;
if(this.handleError(err)) {
return;
}

if(result.open) {
Expand Down Expand Up @@ -244,8 +243,11 @@ class StickyOrder extends BaseOrder {

console.log(new Date, '[sticky order] FATAL ERROR', error.message);
console.log(new Date, error);
this.emit('error', error);
this.status = states.ERROR;
this.emitStatus();
this.error = error;

this.emit('error', error);
return true;
}

Expand Down
2 changes: 1 addition & 1 deletion exchange/wrappers/poloniex.js
Original file line number Diff line number Diff line change
Expand Up @@ -325,7 +325,7 @@ Trader.prototype.getOrder = function(order, callback) {
});

const fees = {};
const feePercent = _.first(result).fee;
const feePercent = _.first(result).fee * 100;

if(_.first(result).type === 'sell') {
const fee = price * amount * _.first(result).fee;
Expand Down