|
|
|
@ -6,6 +6,8 @@ import ATrade (libatrade_gitrev, |
|
|
|
import ATrade.Broker.Protocol (NotificationSqnum (NotificationSqnum)) |
|
|
|
import ATrade.Broker.Protocol (NotificationSqnum (NotificationSqnum)) |
|
|
|
import ATrade.Broker.Server (startBrokerServer, |
|
|
|
import ATrade.Broker.Server (startBrokerServer, |
|
|
|
stopBrokerServer) |
|
|
|
stopBrokerServer) |
|
|
|
|
|
|
|
import ATrade.Broker.TradeSinks.MQTTTradeSink (withMQTTTradeSink) |
|
|
|
|
|
|
|
import ATrade.Broker.TradeSinks.ZMQTradeSink (withZMQTradeSink) |
|
|
|
import ATrade.Logging (Message (..), Severity (Debug, Error, Info, Trace, Warning), |
|
|
|
import ATrade.Logging (Message (..), Severity (Debug, Error, Info, Trace, Warning), |
|
|
|
fmtMessage, logWith) |
|
|
|
fmtMessage, logWith) |
|
|
|
import ATrade.QuoteSource.Server (startQuoteSourceServer, |
|
|
|
import ATrade.QuoteSource.Server (startQuoteSourceServer, |
|
|
|
@ -25,8 +27,10 @@ import qualified Data.Text as T |
|
|
|
import Data.Version (showVersion) |
|
|
|
import Data.Version (showVersion) |
|
|
|
import Debug.EventCounters (initEventCounters) |
|
|
|
import Debug.EventCounters (initEventCounters) |
|
|
|
import HistoryProviderServer (withHistoryProviderServer) |
|
|
|
import HistoryProviderServer (withHistoryProviderServer) |
|
|
|
|
|
|
|
import Network.URI (parseURI) |
|
|
|
import Prelude hiding (log) |
|
|
|
import Prelude hiding (log) |
|
|
|
import System.IO (Handle, IOMode (AppendMode), |
|
|
|
import System.IO (Handle, |
|
|
|
|
|
|
|
IOMode (AppendMode), |
|
|
|
withFile) |
|
|
|
withFile) |
|
|
|
import System.ZMQ4 (withContext) |
|
|
|
import System.ZMQ4 (withContext) |
|
|
|
import TickerInfoServer (withTickerInfoServer) |
|
|
|
import TickerInfoServer (withTickerInfoServer) |
|
|
|
@ -66,6 +70,10 @@ main = do |
|
|
|
(quotesourceEndpoint cfg) |
|
|
|
(quotesourceEndpoint cfg) |
|
|
|
defaultServerSecurityParams) |
|
|
|
defaultServerSecurityParams) |
|
|
|
stopQuoteSourceServer $ \_ -> withTickerInfoServer logger ctx (tisEndpoint cfg) $ \tisH -> do |
|
|
|
stopQuoteSourceServer $ \_ -> withTickerInfoServer logger ctx (tisEndpoint cfg) $ \tisH -> do |
|
|
|
|
|
|
|
withZMQTradeSink ctx (tradesinkDashboard cfg) $ \tsDashboard -> |
|
|
|
|
|
|
|
case parseURI (T.unpack $ mqttUri cfg) of |
|
|
|
|
|
|
|
Just uri -> do |
|
|
|
|
|
|
|
withMQTTTradeSink uri mqttTradeSinkTopic $ \tsMqtt -> do |
|
|
|
txml <- Connector.start logger cfg qssChannel tisH |
|
|
|
txml <- Connector.start logger cfg qssChannel tisH |
|
|
|
bracket (startBrokerServer |
|
|
|
bracket (startBrokerServer |
|
|
|
[Connector.makeBrokerBackend txml (account cfg)] |
|
|
|
[Connector.makeBrokerBackend txml (account cfg)] |
|
|
|
@ -73,7 +81,7 @@ main = do |
|
|
|
(brokerEndpoint cfg) |
|
|
|
(brokerEndpoint cfg) |
|
|
|
(brokerNotificationsEndpoint cfg) |
|
|
|
(brokerNotificationsEndpoint cfg) |
|
|
|
(NotificationSqnum 1) |
|
|
|
(NotificationSqnum 1) |
|
|
|
[] |
|
|
|
[tsDashboard, tsMqtt] |
|
|
|
defaultServerSecurityParams |
|
|
|
defaultServerSecurityParams |
|
|
|
logger) (\x -> do |
|
|
|
logger) (\x -> do |
|
|
|
stopBrokerServer x |
|
|
|
stopBrokerServer x |
|
|
|
@ -81,6 +89,9 @@ main = do |
|
|
|
Connector.stop txml) $ \_ -> do |
|
|
|
Connector.stop txml) $ \_ -> do |
|
|
|
withHistoryProviderServer ctx (historyProviderEndpoint cfg) txml tisH logger id $ \_ -> do |
|
|
|
withHistoryProviderServer ctx (historyProviderEndpoint cfg) txml tisH logger id $ \_ -> do |
|
|
|
forever $ threadDelay 1000000 |
|
|
|
forever $ threadDelay 1000000 |
|
|
|
|
|
|
|
Nothing -> log Warning "main" "Can't parse MQTT URI" |
|
|
|
log Info "main" "Shutting down" |
|
|
|
log Info "main" "Shutting down" |
|
|
|
|
|
|
|
where |
|
|
|
|
|
|
|
mqttTradeSinkTopic = "/atrade/trades" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|