From 7a337d0a6a99f35e157c64eb915607db6d6d6a72 Mon Sep 17 00:00:00 2001 From: Stefan Dresselhaus Date: Tue, 18 Jul 2023 01:20:57 +0200 Subject: [PATCH] made things work with current stackage. --- deps/dear-implot.hs | 2 +- ibhelper.cabal | 6 +++--- src/AppFiller.hs | 9 ++++----- src/Chart.hs | 15 ++++++++------- src/Types.hs | 2 +- stack.yaml | 2 +- 6 files changed, 18 insertions(+), 18 deletions(-) diff --git a/deps/dear-implot.hs b/deps/dear-implot.hs index da2b394..2998707 160000 --- a/deps/dear-implot.hs +++ b/deps/dear-implot.hs @@ -1 +1 @@ -Subproject commit da2b394f827c001cc3b51e0188be1007f40fa3d9 +Subproject commit 29987079151199d22d23b99f9d461ccedf573b0c diff --git a/ibhelper.cabal b/ibhelper.cabal index af4a455..b23276b 100644 --- a/ibhelper.cabal +++ b/ibhelper.cabal @@ -99,7 +99,7 @@ library build-depends: StateVar , aeson - , base >=4.11 && <10 + , base >=4.11 , binary , bytestring , data-default @@ -176,7 +176,7 @@ executable ibhelper-exe build-depends: StateVar , aeson - , base >=4.11 && <10 + , base >=4.11 , binary , bytestring , data-default @@ -257,7 +257,7 @@ test-suite ibhelper-test build-depends: StateVar , aeson - , base >=4.11 && <10 + , base >=4.11 , binary , bytestring , data-default diff --git a/src/AppFiller.hs b/src/AppFiller.hs index 61dd20e..773d4a2 100644 --- a/src/AppFiller.hs +++ b/src/AppFiller.hs @@ -1,5 +1,5 @@ {-# LANGUAGE DuplicateRecordFields #-} -{-# LANGUAGE TypeApplications #-} +{-# LANGUAGE OverloadedRecordDot #-} module AppFiller where import Import @@ -46,10 +46,9 @@ appFiller app = runRIO app $ withRunInIO $ \run -> do -- let action = HM.update (\ai -> Just $ ai & accountInfo . accountLastUpdate %~ const t) n -- atomically $ modifyTVar' (Types.accounts currentAppData) action (Msg_IB_IN (IB_PortfolioValue c p mp mv ac u r n)) -> do - let cid = conId :: IBContract -> Int - updateAction (a@IBPortfolioValue{..}:as) - | cid _contract == cid c = IBPortfolioValue c p mp mv ac u r:as - | otherwise = a:updateAction as + let updateAction (a:as) + | a._contract.conId == c.conId = IBPortfolioValue c p mp mv ac u r:as + | otherwise = a:updateAction as updateAction [] = [IBPortfolioValue c p mp mv ac u r] action = HM.update (\ai -> Just $ ai & accountPortfolio %~ updateAction) n atomically $ modifyTVar' (Types.accounts currentAppData) action diff --git a/src/Chart.hs b/src/Chart.hs index 7a6bfd5..fd67476 100644 --- a/src/Chart.hs +++ b/src/Chart.hs @@ -1,5 +1,6 @@ {-# LANGUAGE NoImplicitPrelude #-} {-# LANGUAGE OverloadedStrings #-} +{-# LANGUAGE OverloadedRecordDot #-} {-# LANGUAGE DerivingVia #-} {-# LANGUAGE TupleSections #-} {-# OPTIONS_GHC -Wno-unrecognised-pragmas #-} @@ -29,7 +30,7 @@ import qualified Data.List as L import qualified Data.Text as T import qualified Data.Vector.Storable as VS -import qualified Debug.Trace as D +-- import qualified Debug.Trace as D data FillerException = QuitFiller deriving stock Show @@ -39,15 +40,15 @@ instance Exception FillerException newChart :: IBContract -> RIO App () newChart contract = do app <- ask - let sym = (symbol :: IBContract -> Text) contract - con = (conId :: IBContract -> Int) contract + let sym = contract.symbol + con = contract.conId hmVar = appCharts . appRefs $ app hm <- liftIO . readTVarIO $ hmVar unless (sym `HM.member` hm) $ do today <- liftIO getCurrentDay :: RIO App Day (cacheErrors, cacheData) <- do ifM (fmap not $ liftIO $ doesDirectoryExist $ "cache" show con) - (return $ (["no data-chache found for " <> show con], [])) $ do + (return (["no data-chache found for " <> show con], [])) $ do files <- liftIO $ listDirectory $ "cache" show con res <- forM files $ \cacheFileName -> do let fname = "cache" show con cacheFileName @@ -77,8 +78,8 @@ newChart contract = do fillChart :: App -> IBContract -> TVar Chart -> IO () fillChart app contract cVar = runRIO app $ do - let sym = (symbol :: IBContract -> Text) contract - (tickerMapVar :: TVar (HashMap Int Text)) <- tickerIdToSymbol. appRefs <$> ask + let sym = contract.symbol + (tickerMapVar :: TVar (HashMap Int Text)) <- tickerIdToSymbol . appRefs <$> ask alreadyAdded <- (sym `elem`) . HM.elems <$> liftIO (readTVarIO tickerMapVar) unless alreadyAdded $ do tickerId <- (+1) . foldl' max 1000 . HM.keys <$> liftIO (readTVarIO tickerMapVar) @@ -257,7 +258,7 @@ getUpdatedChartCache Chart{..} chartCacheSettings' = do (Nothing, Nothing) -> Nothing -- new data, update fillRange (mima, Just lastDP) -> let lastBlock = let d = timeOfDay lastDP in (intervalTo d + intervalFrom d) `div` 2 - in case timePointToIndex' $ lastBlock of + in case timePointToIndex' lastBlock of Left err -> error $ "impossible #1 Chart.hs - " <> err Right ma -> if ma < cTicks then case mima of -- check if we rotated out or have no fill-range set. diff --git a/src/Types.hs b/src/Types.hs index bd53d95..f626bd0 100644 --- a/src/Types.hs +++ b/src/Types.hs @@ -163,7 +163,7 @@ data ChartSettings = ChartSettings } deriving stock (Show, Eq) defChartSettings :: ChartSettings -defChartSettings = ChartSettings 60 Nothing Nothing [ChartStudyTypeDirect] +defChartSettings = ChartSettings 60 Nothing Nothing [ChartStudyTypeDirect, ChartStudyTypeVolume, ChartStudyTypeOpen] updateChartStudySettings :: Chart -> [ChartStudyType] -> Chart updateChartStudySettings Chart{..} s = diff --git a/stack.yaml b/stack.yaml index 04209a1..59b6456 100644 --- a/stack.yaml +++ b/stack.yaml @@ -17,7 +17,7 @@ # # resolver: ./custom-snapshot.yaml # resolver: https://example.com/snapshots/2018-01-01.yaml -resolver: lts-18.24 +resolver: lts-21.2 # User packages to be built. # Various formats can be used as shown in the example below.