Browse Source

Tweaks

master
Denis Tereshkin 9 years ago
parent
commit
edcc53b457
  1. 4
      src/ATrade/Types.hs
  2. 2
      stack.yaml

4
src/ATrade/Types.hs

@ -89,7 +89,7 @@ serializeTick tick = header : [rawdata]
rawdata = toLazyByteString $ mconcat [ rawdata = toLazyByteString $ mconcat [
putWord32le 1, putWord32le 1,
putWord64le $ fromIntegral . toSeconds' . timestamp $ tick, putWord64le $ fromIntegral . toSeconds' . timestamp $ tick,
putWord32le $ fromIntegral . floor . (* 1000000) . fracSeconds . timestamp $ tick, putWord32le $ fromIntegral . fracSeconds . timestamp $ tick,
putWord32le $ fromIntegral . fromEnum . datatype $ tick, putWord32le $ fromIntegral . fromEnum . datatype $ tick,
putWord64le $ truncate . value $ tick, putWord64le $ truncate . value $ tick,
putWord32le $ truncate . (* 1000000000) . fractionalPart $ value tick, putWord32le $ truncate . (* 1000000000) . fractionalPart $ value tick,
@ -99,7 +99,7 @@ serializeTick tick = header : [rawdata]
fractionalPart :: (RealFrac a) => a -> a fractionalPart :: (RealFrac a) => a -> a
fractionalPart x = x - fromIntegral (truncate x) fractionalPart x = x - fromIntegral (truncate x)
toSeconds' t = floor $ diffUTCTime t epoch toSeconds' t = floor $ diffUTCTime t epoch
fracSeconds t = floorPart $ diffUTCTime t epoch fracSeconds t = (truncate $ (* 1000000000000) $ diffUTCTime t epoch) `mod` 1000000000000 `div` 1000000
epoch = fromGregorian 1970 1 1 0 0 0 epoch = fromGregorian 1970 1 1 0 0 0

2
stack.yaml

@ -15,7 +15,7 @@
# resolver: # resolver:
# name: custom-snapshot # name: custom-snapshot
# location: "./custom-snapshot.yaml" # location: "./custom-snapshot.yaml"
resolver: lts-7.1 resolver: lts-7.7
# User packages to be built. # User packages to be built.
# Various formats can be used as shown in the example below. # Various formats can be used as shown in the example below.

Loading…
Cancel
Save