QuantLib: Quantity Class Reference

A free/open-source library for quantitative finance Reference manual - version 1.12

Friends | Related Functions | List of all members
Quantity Class Reference

Amount of a commodity. More...

`#include <ql/experimental/commodities/quantity.hpp>`

## Public Member Functions
Constructors
| Quantity ()
| Quantity (const CommodityType &commodityType, const UnitOfMeasure &unitOfMeasure, Real amount)
Inspectors
const CommodityType & | commodityType () const
const UnitOfMeasure & | unitOfMeasure () const
Real | amount () const
Quantity | rounded () const
Quantity arithmetics
See below for non-member functions and for settings which determine the behavior of the operators.
Quantity | operator+ () const
Quantity | operator- () const
Quantity & | operator+= (const Quantity &)
Quantity & | operator-= (const Quantity &)
Quantity & | operator*= (Real)
Quantity & | operator/= (Real)

## Friends
std::ostream & | operator<< (std::ostream &, const Quantity &)

## Related Functions
(Note that these are not member functions.)
Quantity | operator+ (const Quantity &, const Quantity &)
Quantity | operator- (const Quantity &, const Quantity &)
Quantity | operator* (const Quantity &, Real)
Quantity | operator* (Real, const Quantity &)
Quantity | operator/ (const Quantity &, Real)
Real | operator/ (const Quantity &, const Quantity &)
bool | operator== (const Quantity &, const Quantity &)
bool | operator!= (const Quantity &, const Quantity &)
bool | operator< (const Quantity &, const Quantity &)
bool | operator<= (const Quantity &, const Quantity &)
bool | operator> (const Quantity &, const Quantity &)
bool | operator>= (const Quantity &, const Quantity &)
bool | close (const Quantity &, const Quantity &, Size n=42)
bool | close_enough (const Quantity &, const Quantity &, Size n=42)

## Conversion settings
These parameters are used for combining quantity amounts in different currencies
enum | ConversionType { NoConversion, BaseUnitOfMeasureConversion, AutomatedConversion }
static ConversionType | conversionType
static UnitOfMeasure | baseUnitOfMeasure

## Detailed Description

Amount of a commodity.

## Member Enumeration Documentation

## ◆ ConversionType

enum ConversionType

Enumerator
NoConversion | do not perform conversions
BaseUnitOfMeasureConversion | convert both operands to the base unitOfMeasure before converting
AutomatedConversion | return the result in the unitOfMeasure of the first operand

## Friends And Related Function Documentation

## ◆ operator+()

Quantity operator+ | ( | const Quantity & | ,
|  | const Quantity & |
| ) |  |
| related

## ◆ operator-()

Quantity operator- | ( | const Quantity & | ,
|  | const Quantity & |
| ) |  |
| related

## ◆ operator*() [1/2]

Quantity operator* | ( | const Quantity & | ,
|  | Real |
| ) |  |
| related

## ◆ operator*() [2/2]

Quantity operator* | ( | Real | ,
|  | const Quantity & |
| ) |  |
| related

## ◆ operator/() [1/2]

Quantity operator/ | ( | const Quantity & | ,
|  | Real |
| ) |  |
| related

## ◆ operator/() [2/2]

Real operator/ | ( | const Quantity & | ,
|  | const Quantity & |
| ) |  |
| related

## ◆ operator==()

bool operator== | ( | const Quantity & | ,
|  | const Quantity & |
| ) |  |
| related

## ◆ operator!=()

bool operator!= | ( | const Quantity & | ,
|  | const Quantity & |
| ) |  |
| related

## ◆ operator<()

bool operator< | ( | const Quantity & | ,
|  | const Quantity & |
| ) |  |
| related

## ◆ operator<=()

bool operator<= | ( | const Quantity & | ,
|  | const Quantity & |
| ) |  |
| related

## ◆ operator>()

bool operator> | ( | const Quantity & | ,
|  | const Quantity & |
| ) |  |
| related

## ◆ operator>=()

bool operator>= | ( | const Quantity & | ,
|  | const Quantity & |
| ) |  |
| related

## ◆ close()

bool close | ( | const Quantity & | ,
|  | const Quantity & | ,
|  | Size | n = `42`
| ) |  |
| related

## ◆ close_enough()

bool close_enough | ( | const Quantity & | ,
|  | const Quantity & | ,
|  | Size | n = `42`
| ) |  |
| related