xo-unit: example: + ex4 .. ex6
This commit is contained in:
parent
7c7373427e
commit
ba31d2c112
7 changed files with 116 additions and 0 deletions
23
example/ex5/ex5.cpp
Normal file
23
example/ex5/ex5.cpp
Normal file
|
|
@ -0,0 +1,23 @@
|
|||
/** @file ex5.cpp **/
|
||||
|
||||
#include "xo/unit/quantity.hpp"
|
||||
#include <iostream>
|
||||
|
||||
int
|
||||
main () {
|
||||
namespace u = xo::unit::units;
|
||||
namespace qty = xo::unit::qty;
|
||||
using namespace std;
|
||||
|
||||
/* 20% volatility over 250 days (approx number of trading days in one year) */
|
||||
auto q1 = qty::volatility250d(0.2);
|
||||
/* 10% volatility over 30 days */
|
||||
auto q2 = qty::volatility30d(0.1);
|
||||
|
||||
auto sum = q1 + q2;
|
||||
auto prod = q1 * q2;
|
||||
|
||||
cerr << "q1: " << q1 << ", q2: " << q2 << ", q1+q2: " << sum << ", q1*q2: " << prod << endl;
|
||||
}
|
||||
|
||||
/** end ex5.cpp */
|
||||
Loading…
Add table
Add a link
Reference in a new issue