|
|
|
@ -92,11 +92,12 @@ startQuoteThread :: (MonadIO m, |
|
|
|
T.Text -> |
|
|
|
T.Text -> |
|
|
|
ClientSecurityParams -> |
|
|
|
ClientSecurityParams -> |
|
|
|
(m1 () -> IO ()) -> |
|
|
|
(m1 () -> IO ()) -> |
|
|
|
|
|
|
|
LogAction IO Message -> |
|
|
|
m QuoteThreadHandle |
|
|
|
m QuoteThreadHandle |
|
|
|
startQuoteThread barsRef ctx ep secparams downloadThreadRunner = do |
|
|
|
startQuoteThread barsRef ctx ep secparams downloadThreadRunner logger = do |
|
|
|
chan <- liftIO $ newBoundedChan 2000 |
|
|
|
chan <- liftIO $ newBoundedChan 2000 |
|
|
|
dChan <- liftIO $ newBoundedChan 2000 |
|
|
|
dChan <- liftIO $ newBoundedChan 2000 |
|
|
|
qsc <- liftIO $ startQuoteSourceClient chan [] ctx ep secparams |
|
|
|
qsc <- liftIO $ startQuoteSourceClient chan [] ctx ep secparams logger |
|
|
|
env <- liftIO $ QuoteThreadEnv barsRef <$> newIORef HM.empty <*> pure qsc <*> newIORef M.empty <*> pure dChan |
|
|
|
env <- liftIO $ QuoteThreadEnv barsRef <$> newIORef HM.empty <*> pure qsc <*> newIORef M.empty <*> pure dChan |
|
|
|
tid <- liftIO . forkIO $ quoteThread env chan |
|
|
|
tid <- liftIO . forkIO $ quoteThread env chan |
|
|
|
downloaderTid <- liftIO . forkIO $ downloadThreadRunner (downloaderThread env dChan) |
|
|
|
downloaderTid <- liftIO . forkIO $ downloadThreadRunner (downloaderThread env dChan) |
|
|
|
@ -199,8 +200,8 @@ instance TickerInfoProvider DownloaderM where |
|
|
|
(fromInteger $ tiLotSize ti) |
|
|
|
(fromInteger $ tiLotSize ti) |
|
|
|
(tiTickSize ti) |
|
|
|
(tiTickSize ti) |
|
|
|
|
|
|
|
|
|
|
|
withQThread :: DownloaderEnv -> IORef Bars -> ProgramConfiguration -> Context -> (QuoteThreadHandle -> IO ()) -> IO () |
|
|
|
withQThread :: DownloaderEnv -> IORef Bars -> ProgramConfiguration -> Context -> LogAction IO Message -> (QuoteThreadHandle -> IO ()) -> IO () |
|
|
|
withQThread env barsMap cfg ctx f = do |
|
|
|
withQThread env barsMap cfg ctx logger f = do |
|
|
|
securityParameters <- loadSecurityParameters |
|
|
|
securityParameters <- loadSecurityParameters |
|
|
|
bracket |
|
|
|
bracket |
|
|
|
(startQuoteThread |
|
|
|
(startQuoteThread |
|
|
|
@ -208,7 +209,8 @@ withQThread env barsMap cfg ctx f = do |
|
|
|
ctx |
|
|
|
ctx |
|
|
|
(quotesourceEndpoint cfg) |
|
|
|
(quotesourceEndpoint cfg) |
|
|
|
securityParameters |
|
|
|
securityParameters |
|
|
|
(runDownloaderM env)) |
|
|
|
(runDownloaderM env) |
|
|
|
|
|
|
|
logger) |
|
|
|
stopQuoteThread f |
|
|
|
stopQuoteThread f |
|
|
|
where |
|
|
|
where |
|
|
|
loadSecurityParameters = |
|
|
|
loadSecurityParameters = |
|
|
|
|