-
Notifications
You must be signed in to change notification settings - Fork 96
/
Copy pathfair_value.cpp
53 lines (47 loc) · 1.06 KB
/
fair_value.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
#include <iostream>
#include "doctest.h"
#include "json.hpp"
#include "fair_value.h"
#include "models.h"
#include "market_filtration.h"
#include "bitmex_gateway.h"
#include "Poco/Delegate.h"
class TestMarketFiltration : public MarketFiltrationBase
{
public:
Models::MarketQuote get_latest() override
{
std::string symbol = "XBTUSD";
Poco::DateTime time;
Models::MarketQuote mq(9500.5, 0.0, 9500.0, 100.0, symbol, time);
this->filtered_quote(this, mq);
return mq;
}
};
class FairValueListener
{
private:
FairValue &fv;
public:
FairValueListener(FairValue &fv)
: fv(fv)
{
fv.fair_value_changed += Poco::delegate(this, &FairValueListener::on_fair_value);
}
~FairValueListener()
{
fv.fair_value_changed -= Poco::delegate(this, &FairValueListener::on_fair_value);
}
void on_fair_value(const void *, Models::FairValue &fv)
{
CHECK(fv.price == 9500.5);
}
};
TEST_CASE("fair value")
{
TestMarketFiltration mf;
BitmexDetailsGateway details;
FairValue fv(mf, details);
FairValueListener fvl(fv);
mf.get_latest();
}