Logo Search packages:      
Sourcecode: quantlib version File versions  Download package

Real QuantLib::midEquivalent ( const Real  bid,
const Real  ask,
const Real  last,
const Real  close 
)

return the MidEquivalent price, i.e. the mid if available, or a suitable substitute if the proper mid is not available

Definition at line 27 of file prices.cpp.

References QL_REQUIRE.

    {
        if (bid != Null<Real>() && bid > 0.0) {
            if (ask != Null<Real>() && ask > 0.0) return ((bid+ask)/2.0);
            else                                  return bid;
        } else {
            if (ask != Null<Real>() && ask > 0.0)          return ask;
            else if (last != Null<Real>() && last > 0.0)   return last;
            else {
                QL_REQUIRE(close != Null<Real>() && close > 0.0,
                           "all input prices are invalid");
                return close;
            }
        }
    }


Generated by  Doxygen 1.6.0   Back to index