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 @@ -40,7 +40,7 @@ library
, ATrade.Quotes.TickerInfoProvider
other-modules: Paths_robocom_zero
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-icu
, lens

4
src/ATrade/Driver/Junction.hs

@ -204,7 +204,7 @@ junctionMain descriptors = do @@ -204,7 +204,7 @@ junctionMain descriptors = do
ordersMap <- newIORef M.empty
handledNotifications <- newIORef S.empty
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
let junctionLogAction = logger h
let env =
@ -254,7 +254,7 @@ junctionMain descriptors = do @@ -254,7 +254,7 @@ junctionMain descriptors = do
stratEnv <- liftIO $ newIORef StrategyEnvironment
{
_seInstanceId = strategyId inst,
_seAccount = "test", -- TODO configure
_seAccount = accountId inst,
_seVolume = 1,
_seLastTimestamp = now
}

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

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

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

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

Loading…
Cancel
Save