You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
25 lines
976 B
25 lines
976 B
|
|
module Test.Mock.HistoryProvider |
|
( |
|
mkMockHistoryProvider |
|
) where |
|
|
|
import ATrade.Quotes.HistoryProvider |
|
import ATrade.RoboCom.Types (BarSeriesId (BarSeriesId), Bars) |
|
import ATrade.Types (Bar (Bar, barTimestamp), |
|
BarTimeframe (BarTimeframe), |
|
TickerId) |
|
import qualified Data.Map.Strict as M |
|
import Data.Time (UTCTime) |
|
|
|
mkMockHistoryProvider :: M.Map BarSeriesId [Bar] -> HistoryProvider |
|
mkMockHistoryProvider bars = HistoryProvider $ mockGetHistory bars |
|
|
|
mockGetHistory :: M.Map BarSeriesId [Bar] -> TickerId -> BarTimeframe -> UTCTime -> UTCTime -> IO [Bar] |
|
mockGetHistory bars tid tf from to = |
|
case M.lookup (BarSeriesId tid tf) bars of |
|
Just series -> return $ filter (\bar -> (barTimestamp bar >= from) && (barTimestamp bar <= to)) series |
|
Nothing -> return [] |
|
|
|
|
|
|
|
|