-- GENERATED by C->Haskell Compiler, version 0.28.8 Switcheroo, 25 November 2017 (Haskell)
-- Edit the ORIGNAL .chs file instead!


{-# LINE 1 "./QuantLib/Index.chs" #-}
module QuantLib.Index
  (
    -- * Types
    GenIndex
  , Index
  , HistoricalIndexAnalysis

    -- * Constructors
  , asIndex
  , historicalIndexAnalysis

    -- * Mutators
  , addFixing
  , addFixings
  , clearFixings
  , clearAllFixingHistories

    -- * Inspectors
    -- ** Index fixings
  , name
  , fixingCalendar
  , fixing
  , hasHistoricalFixing
  , isValidFixingDate
  , fixingHistory
  , fixingHistoryNames
    -- ** Historical return analysis
  , skipped
  , mean
  , standardDeviation
  , skewness
  , kurtosis
  , minimumReturn
  , maximumReturn
  , semiVariance
  , semiDeviation
  , downsideVariance
  , downsideDeviation
  , percentile
  , gaussianPercentile
  , valueAtRisk
  , potentialUpside
  , gaussianPotentialUpside
  , regret
  , shortfall
  , gaussianShortfall
  , averageShortfall
  , gaussianAverageShortfall
  , gaussianValueAtRisk
  , expectedShortfall
  , gaussianExpectedShortfall
  , covariance
  , correlation
  ) where
import qualified Foreign.C.Types as C2HSImp
import qualified Foreign.ForeignPtr as C2HSImp
import qualified Foreign.Marshal.Utils as C2HSImp
import qualified Foreign.Ptr as C2HSImp


import QuantLib.Internal
import QuantLib.Internal.Common
import QuantLib.Internal.Type








{-# LINE 65 "./QuantLib/Index.chs" #-}


{-# LINE 66 "./QuantLib/Index.chs" #-}


{-# LINE 67 "./QuantLib/Index.chs" #-}


-- |stores the historical fixing at the given date; the date must be the actual calendar date of the fixing, not a settlement date
addFixing :: (GenIndex idx) -> (Day) -> (Double) -- ^fixing
 -> (Bool) -- ^forceOverwrite
 -> IO ()
addFixing :: forall idx. GenIndex idx -> Day -> Double -> Bool -> IO ()
addFixing GenIndex idx
a1 Day
a2 Double
a3 Bool
a4 =
  GenIndex idx -> (Ptr CIndex' -> IO ()) -> IO ()
forall idx b. GenIndex idx -> (Ptr CIndex' -> IO b) -> IO b
withIndex GenIndex idx
a1 ((Ptr CIndex' -> IO ()) -> IO ())
-> (Ptr CIndex' -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr CIndex'
a1' -> 
  Day -> (CInt -> IO ()) -> IO ()
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a2 ((CInt -> IO ()) -> IO ()) -> (CInt -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \CInt
a2' -> 
  let {a3' :: CDouble
a3' = Double -> CDouble
forall a b. (Real a, Fractional b) => a -> b
realToFrac Double
a3} in 
  let {a4' :: CInt
a4' = Bool -> CInt
forall a. Num a => Bool -> a
C2HSImp.fromBool Bool
a4} in 
  (Ptr (Ptr CChar) -> IO ()) -> IO ()
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO ()) -> IO ())
-> (Ptr (Ptr CChar) -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a5' -> 
  Ptr CIndex' -> CInt -> CDouble -> CInt -> Ptr (Ptr CChar) -> IO ()
addFixing'_ Ptr CIndex'
a1' CInt
a2' CDouble
a3' CInt
a4' Ptr (Ptr CChar)
a5' IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a5'IO () -> IO () -> IO ()
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  () -> IO ()
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ()

{-# LINE 72 "./QuantLib/Index.chs" #-}


-- |The index's own name, as QuantLib builds it -- for an interest-rate index the family name,
-- tenor and day counter, e.g. @\"Euribor6M Actual\/360\"@.  This is the key QuantLib's
-- process-global fixing store uses, so it is the name a stored fixing is filed under.
name :: (GenIndex idx) -> IO ((String))
name a1 =
  withIndex a1 $ \a1' -> 
  name'_ a1' >>= \res ->
  peekDynString res >>= \res' ->
  return (res')

{-# LINE 77 "./QuantLib/Index.chs" #-}


-- |returns the calendar defining valid fixing dates
fixingCalendar :: (GenIndex idx) -> IO ((Calendar))
fixingCalendar a1 =
  withIndex a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  fixingCalendar'_ a1' a2' >>= \res ->
  peekCalendar res >>= \res' ->
  errorCheck  a2'>>
  return (res')

{-# LINE 80 "./QuantLib/Index.chs" #-}


-- |returns the fixing at the given date, forecasting it if not available and /forecastTodaysFixing/ is true
fixing :: (GenIndex idx) -> (Day) -> (Bool) -- ^forecastTodaysFixing
 -> IO ((Double))
fixing a1 a2 a3 =
  withIndex a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  let {a3' = C2HSImp.fromBool a3} in 
  preErrorCheck $ \a4' -> 
  fixing'_ a1' a2' a3' a4' >>= \res ->
  let {res' = realToFrac res} in
  errorCheck  a4'>>
  return (res')

{-# LINE 84 "./QuantLib/Index.chs" #-}


-- |whether a historical fixing has been stored for the given date
hasHistoricalFixing :: (GenIndex idx) -> (Day) -> IO ((Bool))
hasHistoricalFixing a1 a2 =
  withIndex a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  hasHistoricalFixing'_ a1' a2' a3' >>= \res ->
  let {res' = C2HSImp.toBool res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 87 "./QuantLib/Index.chs" #-}


-- |whether the given date is a valid fixing date for this index
isValidFixingDate :: (GenIndex idx) -> (Day) -> IO ((Bool))
isValidFixingDate a1 a2 =
  withIndex a1 $ \a1' -> 
  withDay a2 $ \a2' -> 
  preErrorCheck $ \a3' -> 
  isValidFixingDate'_ a1' a2' a3' >>= \res ->
  let {res' = C2HSImp.toBool res} in
  errorCheck  a3'>>
  return (res')

{-# LINE 90 "./QuantLib/Index.chs" #-}


-- |Stores historical fixings as @(date, value)@ pairs; the date is the actual fixing date.
addFixings :: GenIndex idx -> [(Day, Double)] -> Bool -> IO ()
addFixings idx fixings forceOverwrite = qlIndexAddFixings idx dates values forceOverwrite
  where (dates, values) = unzip fixings
qlIndexAddFixings :: (GenIndex idx) -> ([Day]) -> ([Double]) -> (Bool) -- ^forceOverwrite
 -> IO ()
qlIndexAddFixings a1 a2 a3 a4 =
  withIndex a1 $ \a1' -> 
  withDayArray a2 $ \(a2'1, a2'2) -> 
  withDoubleArrayRaw a3 $ \a3' -> 
  let {a4' = C2HSImp.fromBool a4} in 
  preErrorCheck $ \a5' -> 
  qlIndexAddFixings'_ a1' a2'1  a2'2 a3' a4' a5' >>
  errorCheck  a5'>>
  return ()

{-# LINE 97 "./QuantLib/Index.chs" #-}


-- |clears all stored historical fixings for this index
clearFixings :: (GenIndex idx) -> IO ()
clearFixings a1 =
  withIndex a1 $ \a1' -> 
  preErrorCheck $ \a2' -> 
  clearFixings'_ a1' a2' >>
  errorCheck  a2'>>
  return ()

{-# LINE 100 "./QuantLib/Index.chs" #-}


-- |Returns every stored native fixing for this index, in ascending date order.  This is a
-- snapshot copied out of QuantLib's process-global fixing store; it has no forecasting behavior.
fixingHistory :: GenIndex idx -> IO [(Day, Double)]
fixingHistory i = do
  (ds, vs) <- qlIndexFixingHistory i
  return $ zip ds vs
qlIndexFixingHistory :: (GenIndex idx) -> IO (([Day]), ([Double]))
qlIndexFixingHistory :: forall idx. GenIndex idx -> IO ([Day], [Double])
qlIndexFixingHistory GenIndex idx
a1 =
  GenIndex idx
-> (Ptr CIndex' -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall idx b. GenIndex idx -> (Ptr CIndex' -> IO b) -> IO b
withIndex GenIndex idx
a1 ((Ptr CIndex' -> IO ([Day], [Double])) -> IO ([Day], [Double]))
-> (Ptr CIndex' -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \Ptr CIndex'
a1' -> 
  ((Ptr CUInt, Ptr (Ptr CInt)) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. ((Ptr CUInt, Ptr (Ptr a)) -> IO b) -> IO b
preArray (((Ptr CUInt, Ptr (Ptr CInt)) -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> ((Ptr CUInt, Ptr (Ptr CInt)) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \(Ptr CUInt
a2'1, Ptr (Ptr CInt)
a2'2) -> 
  ((Ptr CUInt, Ptr (Ptr CDouble)) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. ((Ptr CUInt, Ptr (Ptr a)) -> IO b) -> IO b
preArray (((Ptr CUInt, Ptr (Ptr CDouble)) -> IO ([Day], [Double]))
 -> IO ([Day], [Double]))
-> ((Ptr CUInt, Ptr (Ptr CDouble)) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \(Ptr CUInt
a3'1, Ptr (Ptr CDouble)
a3'2) -> 
  (Ptr (Ptr CChar) -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall a b. (Ptr (Ptr a) -> IO b) -> IO b
preErrorCheck ((Ptr (Ptr CChar) -> IO ([Day], [Double])) -> IO ([Day], [Double]))
-> (Ptr (Ptr CChar) -> IO ([Day], [Double]))
-> IO ([Day], [Double])
forall a b. (a -> b) -> a -> b
$ \Ptr (Ptr CChar)
a4' -> 
  Ptr CIndex'
-> Ptr CUInt
-> Ptr (Ptr CInt)
-> Ptr CUInt
-> Ptr (Ptr CDouble)
-> Ptr (Ptr CChar)
-> IO ()
qlIndexFixingHistory'_ Ptr CIndex'
a1' Ptr CUInt
a2'1  Ptr (Ptr CInt)
a2'2 Ptr CUInt
a3'1  Ptr (Ptr CDouble)
a3'2 Ptr (Ptr CChar)
a4' IO () -> IO [Day] -> IO [Day]
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  Ptr CUInt -> Ptr (Ptr CInt) -> IO [Day]
peekDayArray  Ptr CUInt
a2'1  Ptr (Ptr CInt)
a2'2IO [Day] -> ([Day] -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Day]
a2'' -> 
  Ptr CUInt -> Ptr (Ptr CDouble) -> IO [Double]
peekDoubleArray  Ptr CUInt
a3'1  Ptr (Ptr CDouble)
a3'2IO [Double]
-> ([Double] -> IO ([Day], [Double])) -> IO ([Day], [Double])
forall a b. IO a -> (a -> IO b) -> IO b
forall (m :: * -> *) a b. Monad m => m a -> (a -> m b) -> m b
>>= \[Double]
a3'' -> 
  Ptr (Ptr CChar) -> IO ()
errorCheck  Ptr (Ptr CChar)
a4'IO () -> IO ([Day], [Double]) -> IO ([Day], [Double])
forall a b. IO a -> IO b -> IO b
forall (m :: * -> *) a b. Monad m => m a -> m b -> m b
>>
  ([Day], [Double]) -> IO ([Day], [Double])
forall a. a -> IO a
forall (m :: * -> *) a. Monad m => a -> m a
return ([Day]
a2'', [Double]
a3'')

{-# LINE 110 "./QuantLib/Index.chs" #-}


-- |Returns the names with an entry in QuantLib's process-global fixing store.  Names are
-- case-insensitive in that store and can be shared by separate index instances.
fixingHistoryNames :: IO (([String]))
fixingHistoryNames =
  preArray $ \(a1'1, a1'2) -> 
  preErrorCheck $ \a2' -> 
  fixingHistoryNames'_ a1'1  a1'2 a2' >>
  peekCStringArray  a1'1  a1'2>>= \a1'' -> 
  errorCheck  a2'>>
  return (a1'')

{-# LINE 114 "./QuantLib/Index.chs" #-}


-- |Clears every native fixing history in QuantLib's process-global store, for all index names.
-- This affects other index instances and is intended for explicit session or test cleanup.
clearAllFixingHistories :: IO ()
clearAllFixingHistories =
  preErrorCheck $ \a1' -> 
  clearAllFixingHistories'_ a1' >>
  errorCheck  a1'>>
  return ()

{-# LINE 118 "./QuantLib/Index.chs" #-}


-- |Computes 'SequenceStatistics' (mean\/standard deviation\/skewness\/kurtosis\/min\/max\/semi-
-- and downside-variance and -deviation\/percentiles\/value-at-risk\/expected shortfall,
-- empirical and gaussian-assumption\/covariance\/correlation) over historical fixings of the
-- given indexes, sampled every @step@ between @startDate@ and @endDate@. A date/index pair whose
-- fixing is unavailable is recorded in 'skipped' rather than failing the whole analysis.
-- 'SequenceStatistics' is only the accumulator filled internally by this constructor, so its
-- risk-statistics surface is exposed directly through these accessors.
historicalIndexAnalysis :: (Day) -- ^startDate
 -> (Day) -- ^endDate
 -> ((Int,TimeUnit)) -- ^step
 -> ([Index]) -> IO ((HistoricalIndexAnalysis))
historicalIndexAnalysis :: Day
-> Day -> (Int, TimeUnit) -> [Index] -> IO HistoricalIndexAnalysis
historicalIndexAnalysis Day
a1 Day
a2 (Int, TimeUnit)
a3 [Index]
a4 =
  Day
-> (CInt -> IO HistoricalIndexAnalysis)
-> IO HistoricalIndexAnalysis
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a1 ((CInt -> IO HistoricalIndexAnalysis)
 -> IO HistoricalIndexAnalysis)
-> (CInt -> IO HistoricalIndexAnalysis)
-> IO HistoricalIndexAnalysis
forall a b. (a -> b) -> a -> b
$ \CInt
a1' -> 
  Day
-> (CInt -> IO HistoricalIndexAnalysis)
-> IO HistoricalIndexAnalysis
forall a. Day -> (CInt -> IO a) -> IO a
withDay Day
a2 ((CInt -> IO HistoricalIndexAnalysis)
 -> IO HistoricalIndexAnalysis)
-> (CInt -> IO HistoricalIndexAnalysis)
-> IO HistoricalIndexAnalysis
forall a b. (a -> b) -> a -> b
$ \CInt
a2' -> 
  let {(CInt
a3'1, CInt
a3'2) = (Int, TimeUnit) -> (CInt, CInt)
forall a b c.
(Enum a, Integral b, Integral c) =>
(b, a) -> (CInt, c)
fromEnumQuantity (Int, TimeUnit)
a3} in 
  withIndexArray a4 $ \(a4'1, a4'2) -> 
  preErrorCheck $ \a5' -> 
  historicalIndexAnalysis'_ a1' a2' a3'1  a3'2 a4'1  a4'2 a5' >>= \res ->
  peekHistoricalIndexAnalysis res >>= \res' ->
  errorCheck  a5'>>
  return (res')

{-# LINE 131 "./QuantLib/Index.chs" #-}


-- |Skipped fixing dates paired with the reason no complete fixing vector was available.
skipped :: HistoricalIndexAnalysis -> IO [(Day, String)]
skipped analysis = do
  dates <- qlHistoricalIndexAnalysisSkippedDates analysis
  messages <- qlHistoricalIndexAnalysisSkippedMessages analysis
  pure (zip dates messages)
qlHistoricalIndexAnalysisSkippedDates :: (HistoricalIndexAnalysis) -> IO (([Day]))
qlHistoricalIndexAnalysisSkippedDates a1 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  qlHistoricalIndexAnalysisSkippedDates'_ a1' a2'1  a2'2 a3' >>
  peekDayArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 139 "./QuantLib/Index.chs" #-}

qlHistoricalIndexAnalysisSkippedMessages :: (HistoricalIndexAnalysis) -> IO (([String]))
qlHistoricalIndexAnalysisSkippedMessages a1 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  qlHistoricalIndexAnalysisSkippedMessages'_ a1' a2'1  a2'2 a3' >>
  peekCStringArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

skewness :: HistoricalIndexAnalysis -> IO [Double]
{-# LINE 140 "./QuantLib/Index.chs" #-}


-- |Per-index mean of the historical relative returns actually sampled.
mean :: (HistoricalIndexAnalysis) -> IO (([Double]))
mean a1 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  mean'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 143 "./QuantLib/Index.chs" #-}


-- |Per-index standard deviation of the historical relative returns actually sampled.
standardDeviation :: (HistoricalIndexAnalysis) -> IO (([Double]))
standardDeviation a1 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  standardDeviation'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 146 "./QuantLib/Index.chs" #-}


-- |Per-index skewness of the historical relative returns actually sampled.
skewness :: (HistoricalIndexAnalysis) -> IO (([Double]))
skewness a1 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  skewness'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 149 "./QuantLib/Index.chs" #-}


-- |Per-index (excess) kurtosis of the historical relative returns actually sampled.
kurtosis :: (HistoricalIndexAnalysis) -> IO (([Double]))
kurtosis a1 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  kurtosis'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 152 "./QuantLib/Index.chs" #-}


-- |Per-index minimum of the historical relative returns actually sampled.
minimumReturn :: (HistoricalIndexAnalysis) -> IO (([Double]))
minimumReturn a1 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  minimumReturn'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 155 "./QuantLib/Index.chs" #-}


-- |Per-index maximum of the historical relative returns actually sampled.
maximumReturn :: (HistoricalIndexAnalysis) -> IO (([Double]))
maximumReturn a1 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  maximumReturn'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 158 "./QuantLib/Index.chs" #-}


-- |Per-index variance of the historical relative returns falling below the mean.
semiVariance :: (HistoricalIndexAnalysis) -> IO (([Double]))
semiVariance a1 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  semiVariance'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 161 "./QuantLib/Index.chs" #-}


-- |Per-index square root of 'semiVariance'.
semiDeviation :: (HistoricalIndexAnalysis) -> IO (([Double]))
semiDeviation a1 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  semiDeviation'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 164 "./QuantLib/Index.chs" #-}


-- |Per-index variance of the historical relative returns falling below zero.
downsideVariance :: (HistoricalIndexAnalysis) -> IO (([Double]))
downsideVariance a1 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  downsideVariance'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 167 "./QuantLib/Index.chs" #-}


-- |Per-index square root of 'downsideVariance'.
downsideDeviation :: (HistoricalIndexAnalysis) -> IO (([Double]))
downsideDeviation a1 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  preArray $ \(a2'1, a2'2) -> 
  preErrorCheck $ \a3' -> 
  downsideDeviation'_ a1' a2'1  a2'2 a3' >>
  peekDoubleArray  a2'1  a2'2>>= \a2'' -> 
  errorCheck  a3'>>
  return (a2'')

{-# LINE 170 "./QuantLib/Index.chs" #-}


-- |Per-index empirical @y@-th percentile of the historical relative returns actually sampled;
-- @y@ must lie in @[0.9, 1.0)@.
percentile :: (HistoricalIndexAnalysis) -> (Double) -- ^y
 -> IO (([Double]))
percentile a1 a2 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  preArray $ \(a3'1, a3'2) -> 
  preErrorCheck $ \a4' -> 
  percentile'_ a1' a2' a3'1  a3'2 a4' >>
  peekDoubleArray  a3'1  a3'2>>= \a3'' -> 
  errorCheck  a4'>>
  return (a3'')

{-# LINE 176 "./QuantLib/Index.chs" #-}


-- |Per-index @y@-th percentile assuming the historical relative returns are gaussian; @y@ must lie in @[0.9, 1.0)@.
gaussianPercentile :: (HistoricalIndexAnalysis) -> (Double) -- ^y
 -> IO (([Double]))
gaussianPercentile a1 a2 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  preArray $ \(a3'1, a3'2) -> 
  preErrorCheck $ \a4' -> 
  gaussianPercentile'_ a1' a2' a3'1  a3'2 a4' >>
  peekDoubleArray  a3'1  a3'2>>= \a3'' -> 
  errorCheck  a4'>>
  return (a3'')

{-# LINE 181 "./QuantLib/Index.chs" #-}


-- |Per-index empirical value-at-risk at the given @centile@, which must lie in @[0.9, 1.0)@.
valueAtRisk :: (HistoricalIndexAnalysis) -> (Double) -- ^centile
 -> IO (([Double]))
valueAtRisk a1 a2 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  preArray $ \(a3'1, a3'2) -> 
  preErrorCheck $ \a4' -> 
  valueAtRisk'_ a1' a2' a3'1  a3'2 a4' >>
  peekDoubleArray  a3'1  a3'2>>= \a3'' -> 
  errorCheck  a4'>>
  return (a3'')

{-# LINE 186 "./QuantLib/Index.chs" #-}


-- |Per-index value-at-risk at the given @centile@ assuming the historical relative returns are gaussian; @centile@ must lie in @[0.9, 1.0)@.
gaussianValueAtRisk :: (HistoricalIndexAnalysis) -> (Double) -- ^centile
 -> IO (([Double]))
gaussianValueAtRisk a1 a2 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  preArray $ \(a3'1, a3'2) -> 
  preErrorCheck $ \a4' -> 
  gaussianValueAtRisk'_ a1' a2' a3'1  a3'2 a4' >>
  peekDoubleArray  a3'1  a3'2>>= \a3'' -> 
  errorCheck  a4'>>
  return (a3'')

{-# LINE 191 "./QuantLib/Index.chs" #-}


-- |Per-index empirical expected shortfall at the given @centile@, which must lie in @[0.9, 1.0)@.
-- Throws if no sampled return falls below the value-at-risk threshold.
expectedShortfall :: (HistoricalIndexAnalysis) -> (Double) -- ^centile
 -> IO (([Double]))
expectedShortfall a1 a2 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  preArray $ \(a3'1, a3'2) -> 
  preErrorCheck $ \a4' -> 
  expectedShortfall'_ a1' a2' a3'1  a3'2 a4' >>
  peekDoubleArray  a3'1  a3'2>>= \a3'' -> 
  errorCheck  a4'>>
  return (a3'')

{-# LINE 197 "./QuantLib/Index.chs" #-}


-- |Per-index expected shortfall at the given @centile@ assuming the historical relative returns
-- are gaussian; @centile@ must lie in @[0.9, 1.0)@.
gaussianExpectedShortfall :: (HistoricalIndexAnalysis) -> (Double) -- ^centile
 -> IO (([Double]))
gaussianExpectedShortfall a1 a2 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  preArray $ \(a3'1, a3'2) -> 
  preErrorCheck $ \a4' -> 
  gaussianExpectedShortfall'_ a1' a2' a3'1  a3'2 a4' >>
  peekDoubleArray  a3'1  a3'2>>= \a3'' -> 
  errorCheck  a4'>>
  return (a3'')

{-# LINE 203 "./QuantLib/Index.chs" #-}


-- |Per-index empirical potential upside at the given @centile@, which must lie in @[0.9, 1.0)@ --
-- the upside counterpart of 'valueAtRisk'.
potentialUpside :: (HistoricalIndexAnalysis) -> (Double) -- ^centile
 -> IO (([Double]))
potentialUpside a1 a2 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  preArray $ \(a3'1, a3'2) -> 
  preErrorCheck $ \a4' -> 
  potentialUpside'_ a1' a2' a3'1  a3'2 a4' >>
  peekDoubleArray  a3'1  a3'2>>= \a3'' -> 
  errorCheck  a4'>>
  return (a3'')

{-# LINE 209 "./QuantLib/Index.chs" #-}


-- |Per-index potential upside at the given @centile@ assuming the historical relative returns
-- are gaussian; @centile@ must lie in @[0.9, 1.0)@.
gaussianPotentialUpside :: (HistoricalIndexAnalysis) -> (Double) -- ^centile
 -> IO (([Double]))
gaussianPotentialUpside a1 a2 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  preArray $ \(a3'1, a3'2) -> 
  preErrorCheck $ \a4' -> 
  gaussianPotentialUpside'_ a1' a2' a3'1  a3'2 a4' >>
  peekDoubleArray  a3'1  a3'2>>= \a3'' -> 
  errorCheck  a4'>>
  return (a3'')

{-# LINE 215 "./QuantLib/Index.chs" #-}


-- |Per-index regret at the given @target@: expected loss below target, conditional on being below it.
regret :: (HistoricalIndexAnalysis) -> (Double) -- ^target
 -> IO (([Double]))
regret a1 a2 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  preArray $ \(a3'1, a3'2) -> 
  preErrorCheck $ \a4' -> 
  regret'_ a1' a2' a3'1  a3'2 a4' >>
  peekDoubleArray  a3'1  a3'2>>= \a3'' -> 
  errorCheck  a4'>>
  return (a3'')

{-# LINE 220 "./QuantLib/Index.chs" #-}


-- |Per-index empirical probability of falling below @target@.
shortfall :: (HistoricalIndexAnalysis) -> (Double) -- ^target
 -> IO (([Double]))
shortfall a1 a2 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  preArray $ \(a3'1, a3'2) -> 
  preErrorCheck $ \a4' -> 
  shortfall'_ a1' a2' a3'1  a3'2 a4' >>
  peekDoubleArray  a3'1  a3'2>>= \a3'' -> 
  errorCheck  a4'>>
  return (a3'')

{-# LINE 225 "./QuantLib/Index.chs" #-}


-- |Per-index probability of falling below @target@ assuming the historical relative returns are gaussian.
gaussianShortfall :: (HistoricalIndexAnalysis) -> (Double) -- ^target
 -> IO (([Double]))
gaussianShortfall a1 a2 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  preArray $ \(a3'1, a3'2) -> 
  preErrorCheck $ \a4' -> 
  gaussianShortfall'_ a1' a2' a3'1  a3'2 a4' >>
  peekDoubleArray  a3'1  a3'2>>= \a3'' -> 
  errorCheck  a4'>>
  return (a3'')

{-# LINE 230 "./QuantLib/Index.chs" #-}


-- |Per-index empirical average shortfall (expected loss below @target@, unconditional) at the given @target@.
averageShortfall :: (HistoricalIndexAnalysis) -> (Double) -- ^target
 -> IO (([Double]))
averageShortfall a1 a2 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  preArray $ \(a3'1, a3'2) -> 
  preErrorCheck $ \a4' -> 
  averageShortfall'_ a1' a2' a3'1  a3'2 a4' >>
  peekDoubleArray  a3'1  a3'2>>= \a3'' -> 
  errorCheck  a4'>>
  return (a3'')

{-# LINE 235 "./QuantLib/Index.chs" #-}


-- |Per-index average shortfall at the given @target@ assuming the historical relative returns are gaussian.
gaussianAverageShortfall :: (HistoricalIndexAnalysis) -> (Double) -- ^target
 -> IO (([Double]))
gaussianAverageShortfall a1 a2 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  let {a2' = realToFrac a2} in 
  preArray $ \(a3'1, a3'2) -> 
  preErrorCheck $ \a4' -> 
  gaussianAverageShortfall'_ a1' a2' a3'1  a3'2 a4' >>
  peekDoubleArray  a3'1  a3'2>>= \a3'' -> 
  errorCheck  a4'>>
  return (a3'')

{-# LINE 240 "./QuantLib/Index.chs" #-}


toMatrixDouble :: (Word, Word, [Double]) -> Matrix Double
toMatrixDouble (r, c, d) = Matrix r c d

-- |Covariance matrix of the historical relative returns across indexes.
covariance :: HistoricalIndexAnalysis -> IO (Matrix Double)
covariance hra = toMatrixDouble <$> qlHistoricalIndexAnalysisCovariance hra
qlHistoricalIndexAnalysisCovariance :: (HistoricalIndexAnalysis) -> IO ((Word), (Word), ([Double]))
qlHistoricalIndexAnalysisCovariance a1 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  prePtr $ \a2' -> 
  prePtr $ \a3' -> 
  preArray $ \(a4'1, a4'2) -> 
  preErrorCheck $ \a5' -> 
  qlHistoricalIndexAnalysisCovariance'_ a1' a2' a3' a4'1  a4'2 a5' >>
  peekWord  a2'>>= \a2'' -> 
  peekWord  a3'>>= \a3'' -> 
  peekDoubleArray  a4'1  a4'2>>= \a4'' -> 
  errorCheck  a5'>>
  return (a2'', a3'', a4'')

{-# LINE 250 "./QuantLib/Index.chs" #-}


-- |Correlation matrix of the historical relative returns across indexes.
correlation :: HistoricalIndexAnalysis -> IO (Matrix Double)
correlation hra = toMatrixDouble <$> qlHistoricalIndexAnalysisCorrelation hra
qlHistoricalIndexAnalysisCorrelation :: (HistoricalIndexAnalysis) -> IO ((Word), (Word), ([Double]))
qlHistoricalIndexAnalysisCorrelation a1 =
  withHistoricalIndexAnalysis a1 $ \a1' -> 
  prePtr $ \a2' -> 
  prePtr $ \a3' -> 
  preArray $ \(a4'1, a4'2) -> 
  preErrorCheck $ \a5' -> 
  qlHistoricalIndexAnalysisCorrelation'_ a1' a2' a3' a4'1  a4'2 a5' >>
  peekWord  a2'>>= \a2'' -> 
  peekWord  a3'>>= \a3'' -> 
  peekDoubleArray  a4'1  a4'2>>= \a4'' -> 
  errorCheck  a5'>>
  return (a2'', a3'', a4'')

{-# LINE 257 "./QuantLib/Index.chs" #-}


-- vim: set ff=unix ts=8 sts=2 sw=2 et:

foreign import ccall safe "QuantLib/Index.chs.h qlIndexAddFixing"
  addFixing'_ :: ((C2HSImp.Ptr (CIndex')) -> (C2HSImp.CInt -> (C2HSImp.CDouble -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))))

foreign import ccall safe "QuantLib/Index.chs.h qlIndexName"
  name'_ :: ((C2HSImp.Ptr (CIndex')) -> (IO (C2HSImp.Ptr C2HSImp.CChar)))

foreign import ccall safe "QuantLib/Index.chs.h qlIndexFixingCalendar"
  fixingCalendar'_ :: ((C2HSImp.Ptr (CIndex')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CCalendar)))))

foreign import ccall safe "QuantLib/Index.chs.h qlIndexFixing"
  fixing'_ :: ((C2HSImp.Ptr (CIndex')) -> (C2HSImp.CInt -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CDouble)))))

foreign import ccall safe "QuantLib/Index.chs.h qlIndexHasHistoricalFixing"
  hasHistoricalFixing'_ :: ((C2HSImp.Ptr (CIndex')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt))))

foreign import ccall safe "QuantLib/Index.chs.h qlIndexIsValidFixingDate"
  isValidFixingDate'_ :: ((C2HSImp.Ptr (CIndex')) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO C2HSImp.CInt))))

foreign import ccall safe "QuantLib/Index.chs.h qlIndexAddFixings"
  qlIndexAddFixings'_ :: ((C2HSImp.Ptr (CIndex')) -> (C2HSImp.CUInt -> ((C2HSImp.Ptr C2HSImp.CInt) -> ((C2HSImp.Ptr C2HSImp.CDouble) -> (C2HSImp.CInt -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))))

foreign import ccall safe "QuantLib/Index.chs.h qlIndexClearFixings"
  clearFixings'_ :: ((C2HSImp.Ptr (CIndex')) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))

foreign import ccall safe "QuantLib/Index.chs.h qlIndexFixingHistory"
  qlIndexFixingHistory'_ :: ((C2HSImp.Ptr (CIndex')) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))))

foreign import ccall safe "QuantLib/Index.chs.h qlIndexManagerHistories"
  fixingHistoryNames'_ :: ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar))) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))

foreign import ccall safe "QuantLib/Index.chs.h qlIndexManagerClearHistories"
  clearAllFixingHistories'_ :: ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysis"
  historicalIndexAnalysis'_ :: (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CInt -> (C2HSImp.CUInt -> ((C2HSImp.Ptr (C2HSImp.Ptr (CIndex'))) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO (C2HSImp.Ptr (CHistoricalIndexAnalysis))))))))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisSkippedDates"
  qlHistoricalIndexAnalysisSkippedDates'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CInt)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisSkippedDatesErrorMessage"
  qlHistoricalIndexAnalysisSkippedMessages'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar))) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisMean"
  mean'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisStandardDeviation"
  standardDeviation'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisSkewness"
  skewness'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisKurtosis"
  kurtosis'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisMin"
  minimumReturn'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisMax"
  maximumReturn'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisSemiVariance"
  semiVariance'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisSemiDeviation"
  semiDeviation'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisDownsideVariance"
  downsideVariance'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisDownsideDeviation"
  downsideDeviation'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisPercentile"
  percentile'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisGaussianPercentile"
  gaussianPercentile'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisValueAtRisk"
  valueAtRisk'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisGaussianValueAtRisk"
  gaussianValueAtRisk'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisExpectedShortfall"
  expectedShortfall'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisGaussianExpectedShortfall"
  gaussianExpectedShortfall'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisPotentialUpside"
  potentialUpside'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisGaussianPotentialUpside"
  gaussianPotentialUpside'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisRegret"
  regret'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisShortfall"
  shortfall'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisGaussianShortfall"
  gaussianShortfall'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisAverageShortfall"
  averageShortfall'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisGaussianAverageShortfall"
  gaussianAverageShortfall'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> (C2HSImp.CDouble -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ()))))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisCovariance"
  qlHistoricalIndexAnalysisCovariance'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))))

foreign import ccall safe "QuantLib/Index.chs.h qlHistoricalIndexAnalysisCorrelation"
  qlHistoricalIndexAnalysisCorrelation'_ :: ((C2HSImp.Ptr (CHistoricalIndexAnalysis)) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr C2HSImp.CUInt) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CDouble)) -> ((C2HSImp.Ptr (C2HSImp.Ptr C2HSImp.CChar)) -> (IO ())))))))