module OANDA.Orders
( openOrders
, Order (..)
) where
import Data.Aeson
import Data.Decimal
import Data.Time (ZonedTime)
import qualified Data.Vector as V
import GHC.Generics (Generic)
import OANDA.Types
import OANDA.Util
openOrders :: OandaEnv -> AccountID -> IO (V.Vector Order)
openOrders od (AccountID aid) =
do let url = baseURL od ++ "/v1/accounts/" ++ show aid ++ "/orders"
opts = constructOpts od []
jsonResponseArray url opts "orders"
data Order = Order
{ orderId :: Integer
, orderInstrument :: InstrumentText
, orderUnits :: Integer
, orderSide :: Side
, orderType :: String
, orderTime :: ZonedTime
, orderPrice :: Decimal
, orderTakeProfit :: Decimal
, orderStopLoss :: Decimal
, orderExpiry :: ZonedTime
, orderUpperBound :: Decimal
, orderLowerBound :: Decimal
, orderTrailingStop :: Decimal
} deriving (Show, Generic)
instance FromJSON Order where
parseJSON = genericParseJSON $ jsonOpts "order"