Skip to content

Commit

Permalink
change timeMatched in matching engine to match exberry
Browse files Browse the repository at this point in the history
  • Loading branch information
alexgraham-da committed May 19, 2021
1 parent cc9f447 commit b7df781
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions triggers/daml/MatchingEngine.daml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ module MatchingEngine where
import DA.Finance.Types

import DA.Action
import DA.Date
import DA.Time
import DA.Foldable hiding (elem, null)
import DA.Next.Set (fromList)
import DA.List
Expand All @@ -18,6 +20,9 @@ import Utils

type CurrentOrderId = Int

getUnixTimestamp : TriggerA CurrentOrderId Int
getUnixTimestamp = convertRelTimeToMicroseconds . (flip subTime) (time (date 1970 Jan 1) 0 0 0) <$> getTime

handleMatching : Trigger CurrentOrderId
handleMatching = Trigger
{ initialize = return 0
Expand Down Expand Up @@ -125,19 +130,19 @@ handleOrder party orders (orderCid, order) = do
let fillQty = min passive.qty aggressive.qty
fillPrice = passive.price

time <- getTime
nanoTimestamp <- (* 1000) <$> getUnixTimestamp

emitExerciseCmd aggressiveCid Order_Fill with
fillQty, fillPrice
counterOrderId = passive.orderId
counterParty = passive.exchParticipant
timeMatched = show time
timeMatched = show nanoTimestamp

emitExerciseCmd passiveCid Order_Fill with
fillQty, fillPrice
counterOrderId = aggressive.orderId
counterParty = aggressive.exchParticipant
timeMatched = show time
timeMatched = show nanoTimestamp

return ()

Expand Down Expand Up @@ -192,7 +197,7 @@ handleClearedOrder party orders (orderCid, order) = do
let fillQty = min passive.qty aggressive.qty
fillPrice = passive.price

time <- getTime
nanoTimestamp <- (* 1000) <$> getUnixTimestamp

emitExerciseCmd aggressiveCid ClearedOrder_Fill with
fillQty, fillPrice
Expand All @@ -210,7 +215,7 @@ handleClearedOrder party orders (orderCid, order) = do
instrument = instrumentId
exchange = party
eventId = -1
timeMatched = (show time)
timeMatched = show nanoTimestamp
pair = order.pair
trackingNumber = -1
buyer = buyer.exchParticipant
Expand Down

0 comments on commit b7df781

Please sign in to comment.