Browse Source

Price: fix fromDouble conversion

master
Denis Tereshkin 6 years ago
parent
commit
b1dbc88d9e
  1. 2
      src/ATrade/Price.hs

2
src/ATrade/Price.hs

@ -45,7 +45,7 @@ toDouble :: Price -> Double
toDouble p = fromIntegral (priceQuants p) / fromIntegral mega toDouble p = fromIntegral (priceQuants p) / fromIntegral mega
fromDouble :: Double -> Price fromDouble :: Double -> Price
fromDouble d = Price { priceQuants = truncate (d * fromIntegral mega) } fromDouble d = Price { priceQuants = truncate ((d * fromIntegral mega) + 0.5) }
toScientific :: Price -> Scientific toScientific :: Price -> Scientific
toScientific p = normalize $ scientific (toInteger $ priceQuants p) (-6) toScientific p = normalize $ scientific (toInteger $ priceQuants p) (-6)

Loading…
Cancel
Save