Skip to content

Commit

Permalink
fix(okx.ws-private): fill event
Browse files Browse the repository at this point in the history
  • Loading branch information
iam4x committed Apr 20, 2023
1 parent 0d34072 commit 02f94f1
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions src/exchanges/okx/okx.ws-private.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import createHmac from 'create-hmac';
import { sumBy } from 'lodash';

import { roundUSD } from '../../utils/round-usd';
import { subtract } from '../../utils/safe-math';
import { multiply, subtract } from '../../utils/safe-math';
import { virtualClock } from '../../utils/virtual-clock';
import { BaseWebSocket } from '../base.ws';

Expand Down Expand Up @@ -132,12 +132,16 @@ export class OKXPrivateWebsocket extends BaseWebSocket<OKXExchange> {
}

if (o.state === 'filled' || o.state === 'partially_filled') {
this.emitter.emit('fill', {
side: orders[0].side,
symbol: orders[0].symbol,
price: orders[0].price,
amount: orders[0].amount,
});
const market = this.store.markets.find((m) => m.id === o.instId);

if (market) {
this.emitter.emit('fill', {
side: orders[0].side,
symbol: orders[0].symbol,
price: parseFloat(o.fillPx),
amount: multiply(parseFloat(o.fillSz), market.precision.amount),
});
}
}
}
}
Expand Down

0 comments on commit 02f94f1

Please sign in to comment.