From fefd0974d0a5f595be6b6b9b6f9689ae624413f3 Mon Sep 17 00:00:00 2001 From: Denis Tereshkin Date: Mon, 20 Jan 2025 20:14:48 +0700 Subject: [PATCH] Update for new libatrade --- src/ATrade/Driver/Junction.hs | 8 ++------ src/ATrade/Driver/Junction/BrokerService.hs | 6 +++--- src/ATrade/Driver/Junction/JunctionMonad.hs | 5 ++--- 3 files changed, 7 insertions(+), 12 deletions(-) diff --git a/src/ATrade/Driver/Junction.hs b/src/ATrade/Driver/Junction.hs index 8ddebb1..2d75ea2 100644 --- a/src/ATrade/Driver/Junction.hs +++ b/src/ATrade/Driver/Junction.hs @@ -162,8 +162,7 @@ junctionMain descriptors = do handleRemoteControl 1000 where startRobots :: ProgramConfiguration -> JunctionM () - startRobots cfg = forM_ (instances cfg) $ \inst -> do - startRobot inst + startRobots cfg = forM_ (instances cfg) startRobot withJunction :: JunctionEnv -> JunctionM () -> IO () withJunction env = (`runReaderT` env) . unJunctionM @@ -200,12 +199,9 @@ junctionMain descriptors = do securityParameters <- loadBrokerSecurityParameters cfg bracket (startBrokerClient - (encodeUtf8 $ brokerIdentity cfg) - ctx + (brokerIdentity cfg) (brokerEndpoint cfg) - (brokerNotificationEndpoint cfg) [handleBrokerNotification robotsMap ordersMap handled logger'] - securityParameters logger') stopBrokerClient f diff --git a/src/ATrade/Driver/Junction/BrokerService.hs b/src/ATrade/Driver/Junction/BrokerService.hs index ab07ba0..5462f7e 100644 --- a/src/ATrade/Driver/Junction/BrokerService.hs +++ b/src/ATrade/Driver/Junction/BrokerService.hs @@ -40,7 +40,7 @@ submitOrder service identity order = do liftIO $ atomicModifyIORef' (orderMap service) (\s -> (M.insert oid identity s, ())) r <- liftIO $ Bro.submitOrder (broker service) order { orderId = oid } case r of - Left err -> logWarning "BrokerServer" $ "Submit order error: " <> err + Left err -> logWarning "BrokerService" $ "Submit order error: " <> err _ -> return () return oid where @@ -50,7 +50,7 @@ cancelOrder :: (MonadIO m, WithLog env Message m) => BrokerService -> OrderId -> cancelOrder service oid = do r <- liftIO $ Bro.cancelOrder (broker service) oid case r of - Left err -> logWarning "BrokerServer" $ "Submit order error: " <> err + Left err -> logWarning "BrokerServer" $ "Cancel order error: " <> err _ -> return () return () @@ -59,6 +59,6 @@ getNotifications service = do v <- liftIO $ Bro.getNotifications (broker service) case v of Left err -> do - logWarning "BrokerServer" $ "Submit order error: " <> err + logWarning "BrokerServer" $ "Get notifications order error: " <> err return [] Right n -> return n diff --git a/src/ATrade/Driver/Junction/JunctionMonad.hs b/src/ATrade/Driver/Junction/JunctionMonad.hs index 4666638..31c2e69 100644 --- a/src/ATrade/Driver/Junction/JunctionMonad.hs +++ b/src/ATrade/Driver/Junction/JunctionMonad.hs @@ -18,8 +18,7 @@ import ATrade.Broker.Client (BrokerClientHandle import ATrade.Driver.Junction.BrokerService (BrokerService) import ATrade.Driver.Junction.ProgramConfiguration (ProgramConfiguration (logBasePath)) import ATrade.Driver.Junction.QuoteStream (QuoteStream (addSubscription, removeSubscription), - QuoteSubscription (QuoteSubscription), - SubscriptionId (SubscriptionId)) + QuoteSubscription (QuoteSubscription)) import ATrade.Driver.Junction.QuoteThread (QuoteThreadHandle) import qualified ATrade.Driver.Junction.QuoteThread as QT import ATrade.Driver.Junction.RobotDriverThread (RobotDriverHandle, RobotEnv (RobotEnv), @@ -89,9 +88,9 @@ import Prelude hiding (log, readFile) import System.IO (BufferMode (LineBuffering), IOMode (AppendMode), + hClose, hSetBuffering, openFile) -import System.IO (hClose) import System.ZMQ4 (Router, Socket) import UnliftIO (MonadUnliftIO) import UnliftIO.Exception (catchAny,