I'm not an F# programmer. I'm modifying an existing library.
I'm trying and slowly picking it up.
What I'm trying to do is divide two functions.
I can see it done through the rest of the library so I know it's possible however when i try and divide i get the error
"Expecting a type supporting the operator '/' but given a function type. You may be missing an argument to a function"
This is where the errors occurring
let sharpeRatio2 pfRets bmkRets x =
let top pfRets bmkRets = excessReturns2 pfRets bmkRets
let bottom pfRets x = volatilty pfRets false x
let result = top / bottom
result
The sub functions called i think are all good, with the only question mark on the volatility one which i created it should multiply the std result by sqrt(12)
Top (Returns)
let excessReturns2 (pfRets: seq<float>) bmkRets =
Seq.zip pfRets bmkRets |> Seq.map activeReturn
|> Seq.zip
let inline activeReturn (ret, bmkRet) = ret - bmkRet
Bottom (Volatility)
let var xs nmethod =
match Seq.fold (fun (i, s, sumsq) x -> i + 1, s + x, sumsq + x * x) (0, 0., 0.) xs with
| 0, _, _ -> 0.
| 1, _, _ when not nmethod -> 0.
| n, xsum, xsumsq ->
// denominator is (n-1) or n
let d = if nmethod then float n else float n - 1.
(xsumsq - xsum * xsum / float n) / d
let std xs nmethod = sqrt (var xs nmethod)
let volatilty xs nmethod x = (std xs nmethod) * sqrt (x)
Any thoughts welcome please
Thanks gws
topandbottomfunctions? You can just copy it from the REPL if necessary. - s952163