{-# LANGUAGE DeriveGeneric #-}
module Quant.MatchingEngine.Protocol
  (TradeMessage(..)
  ,TradeResponseMessage(..)
  ) where

import           Data.Aeson                      (FromJSON, ToJSON)
import           Data.Conduit
import           GHC.Generics                    (Generic)
import           Quant.MatchingEngine.BasicTypes

data TradeMessage =
  NewOrder ClientID Side Price ShareCount ClientOrderID
  | CancelOrder ClientID OrderID
  deriving (Show,Read,Generic)

data TradeResponseMessage =
  NewOrderAck ClientID ClientOrderID OrderID
  | NewOrderNack ClientID ClientOrderID
  | CancelOrderAck ClientID OrderID
  | CancelOrderNack ClientID OrderID
  | OrderFill ClientID OrderID Price ShareCount
  | OrderStatus ClientID OrderID Status Price ShareCount ShareCount
  deriving (Show, Read,Generic)

data Status = PendingAdd | Added | PendingCancel | Cancelled | DFD | Complete deriving (Show,Eq,Read,Generic)

instance ToJSON TradeMessage
instance ToJSON TradeResponseMessage
instance ToJSON Status

instance FromJSON TradeMessage
instance FromJSON TradeResponseMessage
instance FromJSON Status
