Browse Source

junction: account configuration

junction
Denis Tereshkin 4 years ago
parent
commit
4d82a19cc6
  1. 2
      robocom-zero.cabal
  2. 4
      src/ATrade/Driver/Junction.hs
  3. 12
      src/ATrade/Driver/Junction/QuoteThread.hs
  4. 1
      src/ATrade/Driver/Junction/Types.hs

2
robocom-zero.cabal

@ -40,7 +40,7 @@ library
, ATrade.Quotes.TickerInfoProvider , ATrade.Quotes.TickerInfoProvider
other-modules: Paths_robocom_zero other-modules: Paths_robocom_zero
build-depends: base >= 4.7 && < 5 build-depends: base >= 4.7 && < 5
, libatrade >= 0.11.0.0 && < 0.12.0.0 , libatrade >= 0.12.0.0 && < 0.13.0.0
, text , text
, text-icu , text-icu
, lens , lens

4
src/ATrade/Driver/Junction.hs

@ -204,7 +204,7 @@ junctionMain descriptors = do
ordersMap <- newIORef M.empty ordersMap <- newIORef M.empty
handledNotifications <- newIORef S.empty handledNotifications <- newIORef S.empty
withBroker cfg ctx robotsMap ordersMap handledNotifications (logger h) $ \bro -> withBroker cfg ctx robotsMap ordersMap handledNotifications (logger h) $ \bro ->
withQThread downloaderEnv barsMap cfg ctx $ \qt -> do withQThread downloaderEnv barsMap cfg ctx (logger h) $ \qt -> do
broService <- mkBrokerService bro ordersMap broService <- mkBrokerService bro ordersMap
let junctionLogAction = logger h let junctionLogAction = logger h
let env = let env =
@ -254,7 +254,7 @@ junctionMain descriptors = do
stratEnv <- liftIO $ newIORef StrategyEnvironment stratEnv <- liftIO $ newIORef StrategyEnvironment
{ {
_seInstanceId = strategyId inst, _seInstanceId = strategyId inst,
_seAccount = "test", -- TODO configure _seAccount = accountId inst,
_seVolume = 1, _seVolume = 1,
_seLastTimestamp = now _seLastTimestamp = now
} }

12
src/ATrade/Driver/Junction/QuoteThread.hs

@ -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 =

1
src/ATrade/Driver/Junction/Types.hs

@ -56,6 +56,7 @@ instance (FromDhall c) => FromDhall (BigConfig c)
data StrategyInstanceDescriptor = data StrategyInstanceDescriptor =
StrategyInstanceDescriptor StrategyInstanceDescriptor
{ {
accountId :: T.Text,
strategyId :: T.Text, strategyId :: T.Text,
strategyBaseName :: T.Text, strategyBaseName :: T.Text,
configKey :: T.Text, configKey :: T.Text,

Loading…
Cancel
Save