Browse Source

Update for new libatrade

master
Denis Tereshkin 11 months ago
parent
commit
fefd0974d0
  1. 8
      src/ATrade/Driver/Junction.hs
  2. 6
      src/ATrade/Driver/Junction/BrokerService.hs
  3. 5
      src/ATrade/Driver/Junction/JunctionMonad.hs

8
src/ATrade/Driver/Junction.hs

@ -162,8 +162,7 @@ junctionMain descriptors = do @@ -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 @@ -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

6
src/ATrade/Driver/Junction/BrokerService.hs

@ -40,7 +40,7 @@ submitOrder service identity order = do @@ -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 -> @@ -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 @@ -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

5
src/ATrade/Driver/Junction/JunctionMonad.hs

@ -18,8 +18,7 @@ import ATrade.Broker.Client (BrokerClientHandle @@ -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, @@ -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,

Loading…
Cancel
Save