hquantlib 0.0.4.0 → 0.0.5.0
raw patch · 6 files changed
+11/−139 lines, 6 filesdep +hquantlib-timedep ~hmatrixdep ~hmatrix-gsldep ~hmatrix-specialPVP: major bump suggested
API removals or changes: PVP suggests a major version bump
Dependencies added: hquantlib-time
Dependency ranges changed: hmatrix, hmatrix-gsl, hmatrix-special
API changes (from Hackage documentation)
- QuantLib.Time: Following :: BusinessDayConvention
- QuantLib.Time: Friday :: WeekDay
- QuantLib.Time: ModifiedFollowing :: BusinessDayConvention
- QuantLib.Time: ModifiedPreceding :: BusinessDayConvention
- QuantLib.Time: Monday :: WeekDay
- QuantLib.Time: Preceding :: BusinessDayConvention
- QuantLib.Time: Saturday :: WeekDay
- QuantLib.Time: Sunday :: WeekDay
- QuantLib.Time: ThirtyEuropean :: Thirty360
- QuantLib.Time: ThirtyItalian :: Thirty360
- QuantLib.Time: ThirtyUSA :: Thirty360
- QuantLib.Time: Thursday :: WeekDay
- QuantLib.Time: Tuesday :: WeekDay
- QuantLib.Time: Unadjusted :: BusinessDayConvention
- QuantLib.Time: Wednesday :: WeekDay
- QuantLib.Time: class DayCounter m
- QuantLib.Time: class Holiday m where isBusinessDay m d = not (isHoliday m $ toGregorian d) hBusinessDayBetween m (fd, td) = foldl countDays 0 listOfDates where countDays counter x = counter + fromEnum (isBusinessDay m x) listOfDates = getDaysBetween (fd, td)
- QuantLib.Time: data BusinessDayConvention
- QuantLib.Time: data Thirty360
- QuantLib.Time: data WeekDay
- QuantLib.Time: dcCount :: DayCounter m => m -> Date -> Date -> Int
- QuantLib.Time: dcName :: DayCounter m => m -> String
- QuantLib.Time: dcYearFraction :: DayCounter m => m -> Date -> Date -> Double
- QuantLib.Time: getDaysBetween :: (Day, Day) -> [Day]
- QuantLib.Time: getNextBusinessDay :: Holiday a => a -> Date -> Date
- QuantLib.Time: getWeekDay :: Date -> WeekDay
- QuantLib.Time: hBusinessDayBetween :: Holiday m => m -> (Date, Date) -> Int
- QuantLib.Time: intGregorian :: Day -> (Int, Int, Int)
- QuantLib.Time: isBusinessDay :: Holiday m => m -> Date -> Bool
- QuantLib.Time: isHoliday :: Holiday m => m -> (Integer, Int, Int) -> Bool
- QuantLib.Time: isWeekEnd :: Date -> Bool
- QuantLib.Time: type Date = Day
+ QuantLib.Currencies: Currency :: String -> String -> Integer -> Integer -> Currency
+ QuantLib.Currencies: [cCode] :: Currency -> String
+ QuantLib.Currencies: [cFracsPerUnit] :: Currency -> Integer
+ QuantLib.Currencies: [cIsoCode] :: Currency -> Integer
+ QuantLib.Currencies: [cName] :: Currency -> String
+ QuantLib.Currencies: cad :: Currency
+ QuantLib.Currencies: chf :: Currency
+ QuantLib.Currencies: czk :: Currency
+ QuantLib.Currencies: data Currency
+ QuantLib.Currencies: dkk :: Currency
+ QuantLib.Currencies: eur :: Currency
+ QuantLib.Currencies: gbp :: Currency
+ QuantLib.Currencies: usd :: Currency
+ QuantLib.Stochastic: BlackScholesProcess :: (Double -> Double) -> (Double -> Double) -> (Dot -> Double) -> BlackScholesProcess
+ QuantLib.Stochastic: Dot :: {-# UNPACK #-} !Double -> {-# UNPACK #-} !Double -> Dot
+ QuantLib.Stochastic: EndEuler :: Double -> EndEuler
+ QuantLib.Stochastic: Euler :: Double -> Euler
+ QuantLib.Stochastic: GeometricBrownian :: Double -> Double -> GeometricBrownian
+ QuantLib.Stochastic: ItoProcess :: (Dot -> Double) -> (Dot -> Double) -> ItoProcess
+ QuantLib.Stochastic: OrnsteinUhlenbeckProcess :: Double -> Double -> Double -> OrnsteinUhlenbeckProcess
+ QuantLib.Stochastic: SquareRootProcess :: Double -> Double -> Double -> SquareRootProcess
+ QuantLib.Stochastic: [bspBlackVol] :: BlackScholesProcess -> Dot -> Double
+ QuantLib.Stochastic: [bspDividend] :: BlackScholesProcess -> Double -> Double
+ QuantLib.Stochastic: [bspRiskFree] :: BlackScholesProcess -> Double -> Double
+ QuantLib.Stochastic: [eDt] :: Euler -> Double
+ QuantLib.Stochastic: [eeDt] :: EndEuler -> Double
+ QuantLib.Stochastic: [gbDiff] :: GeometricBrownian -> Double
+ QuantLib.Stochastic: [gbDrift] :: GeometricBrownian -> Double
+ QuantLib.Stochastic: [getT] :: Dot -> {-# UNPACK #-} !Double
+ QuantLib.Stochastic: [getX] :: Dot -> {-# UNPACK #-} !Double
+ QuantLib.Stochastic: [ipDiff] :: ItoProcess -> Dot -> Double
+ QuantLib.Stochastic: [ipDrift] :: ItoProcess -> Dot -> Double
+ QuantLib.Stochastic: [oupLevel] :: OrnsteinUhlenbeckProcess -> Double
+ QuantLib.Stochastic: [oupSigma] :: OrnsteinUhlenbeckProcess -> Double
+ QuantLib.Stochastic: [oupSpeed] :: OrnsteinUhlenbeckProcess -> Double
+ QuantLib.Stochastic: [srpMean] :: SquareRootProcess -> Double
+ QuantLib.Stochastic: [srpSigma] :: SquareRootProcess -> Double
+ QuantLib.Stochastic: [srpSpeed] :: SquareRootProcess -> Double
+ QuantLib.Stochastic: class Discretize b
+ QuantLib.Stochastic: class NormalGenerator a
+ QuantLib.Stochastic: class StochasticProcess a
+ QuantLib.Stochastic: dDiff :: (Discretize b, StochasticProcess a) => a -> b -> Dot -> Double
+ QuantLib.Stochastic: dDrift :: (Discretize b, StochasticProcess a) => a -> b -> Dot -> Double
+ QuantLib.Stochastic: dDt :: (Discretize b, StochasticProcess a) => a -> b -> Dot -> Double
+ QuantLib.Stochastic: data BlackScholesProcess
+ QuantLib.Stochastic: data BoxMuller a
+ QuantLib.Stochastic: data Dot
+ QuantLib.Stochastic: data EndEuler
+ QuantLib.Stochastic: data Euler
+ QuantLib.Stochastic: data GeometricBrownian
+ QuantLib.Stochastic: data InverseNormal a
+ QuantLib.Stochastic: data ItoProcess
+ QuantLib.Stochastic: data OrnsteinUhlenbeckProcess
+ QuantLib.Stochastic: data PureMT
+ QuantLib.Stochastic: data SquareRootProcess
+ QuantLib.Stochastic: diff :: StochasticProcess a => a -> Dot -> Double
+ QuantLib.Stochastic: drift :: StochasticProcess a => a -> Dot -> Double
+ QuantLib.Stochastic: evolve :: (StochasticProcess a, Discretize b) => b -> a -> Dot -> Double -> Dot
+ QuantLib.Stochastic: generatePath :: (StochasticProcess a, NormalGenerator b, Discretize c) => b -> c -> a -> Int -> Dot -> Path
+ QuantLib.Stochastic: mkInverseNormal :: RandomGenerator a => IO (InverseNormal a)
+ QuantLib.Stochastic: mkNormalGen :: RandomGenerator a => IO (BoxMuller a)
+ QuantLib.Stochastic: newPureMT :: IO PureMT
+ QuantLib.Stochastic: ngGetNext :: NormalGenerator a => a -> (Double, a)
+ QuantLib.Stochastic: ngMkNew :: NormalGenerator a => a -> IO a
+ QuantLib.Stochastic: ngSplit :: NormalGenerator a => a -> (a, a)
+ QuantLib.Stochastic: ngSplitWithSeed :: NormalGenerator a => Integer -> a -> (a, a)
+ QuantLib.Stochastic: randomDouble :: PureMT -> (Double, PureMT)
+ QuantLib.Stochastic: splitMT :: PureMT -> (PureMT, PureMT)
+ QuantLib.Stochastic: splitMTwithSeed :: Integer -> PureMT -> (PureMT, PureMT)
+ QuantLib.Stochastic: type Path = [Dot]
- QuantLib.Event: class Event a where evOccured event date = evDate event < date evOccuredInclude event date = evDate event <= date evCompare x y | evDate x == evDate y = EQ | evDate x <= evDate y = LT | otherwise = GT evEqual x y = evDate x == evDate y
+ QuantLib.Event: class Event a
- QuantLib.Instruments: CompositeInstrument :: (Map a Double) -> CompositeInstrument
+ QuantLib.Instruments: CompositeInstrument :: Map a Double -> CompositeInstrument
- QuantLib.Math.Copulas: class Copula a where copula t = precheckRange (copulaFunc t)
+ QuantLib.Math.Copulas: class Copula a
- QuantLib.Quotes: SimpleQuote :: (Maybe Double) -> SimpleQuote
+ QuantLib.Quotes: SimpleQuote :: Maybe Double -> SimpleQuote
- QuantLib.Quotes: class Quote a where pureValue x = fromMaybe 0.0 (qValue x)
+ QuantLib.Quotes: class Quote a
Files
- hquantlib.cabal +9/−10
- src/QuantLib.hs +1/−0
- src/QuantLib/Time.hs +0/−8
- src/QuantLib/Time/Date.hs +0/−60
- src/QuantLib/Time/DayCounter.hs +0/−60
- src/Tests/McTest.hs +1/−1
hquantlib.cabal view
@@ -1,12 +1,12 @@ name: hquantlib-version: 0.0.4.0+version: 0.0.5.0 license: LGPL license-file: LICENSE author: Pavel Ryzhov maintainer: Pavel Ryzhov <pavel.ryzhov@gmail.com> category: Finance synopsis: HQuantLib is a port of essencial parts of QuantLib to Haskell-description: HQuantLib is intended to be a functional style port of QuantLib (http://quantlib.org)+description: HQuantLib is intended to be a functional style port of QuantLib (<http://quantlib.org>) build-type: Simple stability: alpha homepage: http://github.com/paulrzcz/hquantlib.git@@ -37,7 +37,6 @@ QuantLib.PricingEngines QuantLib.PricingEngines.BlackFormula QuantLib.Quotes- QuantLib.Time QuantLib.TimeSeries QuantLib.Money QuantLib.Math@@ -59,24 +58,23 @@ QuantLib.Stochastic.Process QuantLib.Stochastic.Random QuantLib.Currency- QuantLib.Time.Date- QuantLib.Time.DayCounter QuantLib.Math.InverseNormal QuantLib.Stochastic.PureMT build-depends: base >3 && <5, random >= 1.0 && < 2.0,- time >= 1.4.0.0 && < 1.7.0.0,+ time >= 1.4.0.0 && < 1.9.0.0, containers >= 0.5.0.0 && < 0.6.0.0,- hmatrix >= 0.17.0.0 && < 0.19.0.0,- hmatrix-gsl >= 0.17.0.0 && < 0.19.0.0,- hmatrix-special >= 0.4.0 && < 0.5.0,+ hmatrix >= 0.19.0.0 && < 0.20.0.0,+ hmatrix-gsl >= 0.19.0.0 && < 0.20.0.0,+ hmatrix-special >= 0.19.0 && < 0.20.0, parallel >= 3.2.0.0 && < 3.3.0.0, mersenne-random-pure64 >= 0.2.0.0 && < 0.3.0.0, statistics >= 0.13.0.0 && < 0.15.0.0, vector >= 0.11.0.0 && < 0.13.0.0,- vector-algorithms >= 0.7.0.0 && < 0.8.0.0+ vector-algorithms >= 0.7.0.0 && < 0.8.0.0,+ hquantlib-time >= 0.0.4.0 && < 0.0.6.0 hs-source-dirs: src ghc-options: -Wall@@ -95,6 +93,7 @@ QuantLib.Stochastic.Discretize QuantLib.Stochastic.Process QuantLib.Stochastic.Random+ QuantLib.Stochastic.PureMT build-depends : base, hquantlib, parallel,
src/QuantLib.hs view
@@ -6,3 +6,4 @@ import QuantLib.TimeSeries as Q import QuantLib.Prices as Q import QuantLib.Math as Q+import QuantLib.Time as Q
− src/QuantLib/Time.hs
@@ -1,8 +0,0 @@-module QuantLib.Time- ( module QuantLib.Time.Date- , module QuantLib.Time.DayCounter- ) where--import QuantLib.Time.Date-import QuantLib.Time.DayCounter-
− src/QuantLib/Time/Date.hs
@@ -1,60 +0,0 @@-module QuantLib.Time.Date- ( module QuantLib.Time.Date- ) where--import Data.Time-import Data.Time.Calendar.WeekDate--{- | Business Day conventions- - These conventions specify the algorithm used to adjust a date in case it is not a valid business day.- -}-data BusinessDayConvention = Following - | ModifiedFollowing - | Preceding- | ModifiedPreceding- | Unadjusted- deriving (Show, Eq, Enum)---- | Week days-data WeekDay = Monday | Tuesday | Wednesday | Thursday | Friday | Saturday | Sunday- deriving (Show, Eq, Enum)---- | Date-type Date = Day---- | Defines a holidays for given calendar. Corresponds to calendar class in QuantLib-class Holiday m where- isHoliday :: m->(Integer, Int, Int)->Bool- - isBusinessDay :: m->Date->Bool- isBusinessDay m d = not (isHoliday m $ toGregorian d)-- hBusinessDayBetween :: m->(Date, Date)->Int- hBusinessDayBetween m (fd, td) = foldl countDays 0 listOfDates- where countDays counter x = counter + fromEnum (isBusinessDay m x)- listOfDates = getDaysBetween (fd, td)---- | Gets a week day -getWeekDay :: Date->WeekDay-getWeekDay d = toEnum (weekDay - 1)- where (_, _, weekDay) = toWeekDate d---- | Generate a list of all dates inbetween-getDaysBetween :: (Day, Day) -> [Day]-getDaysBetween (fd, td) = reverse $ generator fd []- where generator date x- | date < td = generator nextDate (nextDate : x)- | otherwise = x- where nextDate = addDays 1 date---- | Checks if the day is a weekend, i.e. Saturday or Sunday-isWeekEnd :: Date->Bool-isWeekEnd d = (weekday == Saturday) || (weekday == Sunday)- where weekday = getWeekDay d---- | Gets the next working day-getNextBusinessDay :: Holiday a => a->Date->Date-getNextBusinessDay m d- | isBusinessDay m nextDay = nextDay- | otherwise = getNextBusinessDay m nextDay- where nextDay = addDays 1 d
− src/QuantLib/Time/DayCounter.hs
@@ -1,60 +0,0 @@-module QuantLib.Time.DayCounter- ( module QuantLib.Time.DayCounter- ) where--import QuantLib.Time.Date-import Data.Time.Calendar---- | Day counter type class-class DayCounter m where- -- | Name of day counter- dcName :: m->String- -- | Number of business days inbetween- dcCount :: m->Date->Date->Int- -- | Year fraction- dcYearFraction :: m->Date->Date->Double--{--data SimpleDayCounter = SimpleDayCounter--instance DayCounter SimpleDayCounter where- dcName _ = "Simple"- dcCount = undefined- dcYearFraction = undefined--}---- | Thirty day counters as in QuantLib-data Thirty360 = ThirtyUSA | ThirtyEuropean | ThirtyItalian--instance DayCounter Thirty360 where- dcName ThirtyUSA = "Thirty USA"- dcName ThirtyEuropean = "Thirty Euro"- dcName ThirtyItalian = "Thirty Italian"-- dcYearFraction dc fromDate toDate = fromIntegral (dcCount dc fromDate toDate) / 360.0-- dcCount ThirtyUSA fd td = 360*(yy2-yy1) + 30*(mm2-mm1-1) + max 0 (30-dd1) + min 30 dd2- where (yy1, mm1, dd1) = intGregorian fd- (yy2, m2, d2) = intGregorian td- (dd2, mm2) = adjust dd1 d2 m2- adjust x1 x2 z2- | x2 == 31 && x1 < 30 = (1, z2+1)- | otherwise = (x2, z2)--- dcCount ThirtyEuropean fd td = 360*(yy2-yy1) + 30*(m2-m1-1) + max 0 (30-d1) + min 30 d2- where (yy1, m1, d1) = intGregorian fd- (yy2, m2, d2) = intGregorian td-- dcCount ThirtyItalian fd td = 360*(yy2-yy1) + 30*(mm2-mm1-1) + max 0 (30-dd1) + min 30 dd2- where (yy1, mm1, d1) = intGregorian fd- (yy2, mm2, d2) = intGregorian td- dd1 = adjust d1 mm1- dd2 = adjust d2 mm2- adjust x1 z1- | z1 == 2 && x1 > 27 = 30- | otherwise = x1--intGregorian :: Day -> (Int, Int, Int)-intGregorian date = (fromIntegral y, m, d)- where (y, m, d) = toGregorian date
src/Tests/McTest.hs view
@@ -45,6 +45,6 @@ rng <- mkInverseNormal :: IO (InverseNormal PureMT) let pg = ProcessGenerator start 1000 sp rng discrete let pmc = PathMonteCarlo summary mmcp pg- let s = monteCarlo pmc 100000+ let s = monteCarlo pmc 1000 printMap s print (getHsSize s)