denarius-exchange / denarius

An open-source financial exchange
Other
35 stars 5 forks source link

Observe time in order execution #6

Closed analyticbastard closed 10 years ago

analyticbastard commented 10 years ago

In engine.clj, the function match-once does not take into account order arrival time:

(defn match-once [book cross]
  (let [market-ask (:market-ask book)
        market-bid (:market-bid book)
        ask        (:ask book)
        bid        (:bid book)]
    (dosync
      (let [order-ref (if-not (empty? @market-ask)
                        (last @market-ask)
                        (if-not (empty? @market-bid)
                          (last @market-bid)
                          (if (> (apply + (map second (market-depth book :ask))) 0)
                            (last @(best-price-level-ref book :ask))
                            nil)))]
        (if order-ref
          (match-order book order-ref cross)
          )))))

My suggestion is taking both bid and ask order side orders, compare a timestamp, then execute (match).

analyticbastard commented 10 years ago

I consider the issue closed as per the previous commits.