Skip to content

Commit

Permalink
feat: add maker/taker Fee cost fields to trade message
Browse files Browse the repository at this point in the history
  • Loading branch information
thaaddeus committed Mar 5, 2022
1 parent 8c4d0d1 commit c8355ec
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 13 deletions.
24 changes: 15 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,9 @@ Up to 100 recent trades pushed immediately after successful subscription confirm
"size": "4.53",
"eventTimestamp": "2021-12-14T12:32:59.000Z",
"takerAccount": "AAddgLu9reZCUWW1bNQFaXrCMAtwQpMRvmeusgk4pCM6",
"makerAccount": "EpAdzaqV13Es3x4dukfjFoCrKVXnZ7y9Y76whgMHo5qx"
"makerAccount": "EpAdzaqV13Es3x4dukfjFoCrKVXnZ7y9Y76whgMHo5qx",
"takerFeeCost": 0.04854859999988685,
"makerFeeCost": -0.02912915999993211
}
]
}
Expand Down Expand Up @@ -403,13 +405,15 @@ Pushed real-time for each trade as it happens on a DEX (decoded from the `eventQ
"side": "buy" | "sell",
"price": string,
"size": string,
"eventTimestamp": string
"takerAccount": string
"makerAccount": string
"takerOrderId": string
"makerOrderId": string
"takerClientId": string
"makerClientId": string
"eventTimestamp": string,
"takerAccount": string,
"makerAccount": string,
"takerOrderId": string,
"makerOrderId": string,
"takerClientId": string,
"makerClientId": string,
"takerFeeCost": number,
"makerFeeCost": number
}
```

Expand All @@ -432,7 +436,9 @@ Pushed real-time for each trade as it happens on a DEX (decoded from the `eventQ
"takerOrderId": "169580918269611952651370",
"makerOrderId": "173897456382859898438567",
"takerClientId": "864345997654345666",
"makerClientId": "7067091222090985486"
"makerClientId": "7067091222090985486",
"takerFeeCost": 0.04854859999988685,
"makerFeeCost": -0.02912915999993211
}
```

Expand Down
8 changes: 4 additions & 4 deletions src/data_mapper.ts
Original file line number Diff line number Diff line change
Expand Up @@ -389,8 +389,6 @@ export class DataMapper {

const makerFillOrderId = matchingMakerFill !== undefined ? matchingMakerFill.orderId : undefined

const makerFillAccount = matchingMakerFill !== undefined ? matchingMakerFill.account : undefined

if (makerFillOrderId === undefined) {
logger.log('warn', 'Trade without matching maker fill order', {
market: this._options.symbol,
Expand All @@ -414,11 +412,13 @@ export class DataMapper {
size: message.size,
eventTimestamp: message.eventTimestamp,
takerAccount: message.account,
makerAccount: makerFillAccount!,
makerAccount: matchingMakerFill?.account!,
takerOrderId: message.orderId,
makerOrderId: makerFillOrderId!,
takerClientId: message.clientId,
makerClientId: matchingMakerFill?.clientId!
makerClientId: matchingMakerFill?.clientId!,
takerFeeCost: message.feeCost,
makerFeeCost: matchingMakerFill?.feeCost!
}

yield this._putInEnvelope(tradeMessage, true)
Expand Down
2 changes: 2 additions & 0 deletions src/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ export interface Trade extends DataMessage, WithEventTimestamp {
readonly makerOrderId: string
readonly takerClientId: string
readonly makerClientId: string
readonly takerFeeCost: number
readonly makerFeeCost: number
}

export interface Fill extends DataMessage, OrderItem {
Expand Down

0 comments on commit c8355ec

Please sign in to comment.