-
Notifications
You must be signed in to change notification settings - Fork 2
/
stock.h
61 lines (51 loc) · 1.13 KB
/
stock.h
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
54
55
56
57
58
59
60
61
#pragma once
#include <cstdint>
#include <map>
#include <string>
enum class Property
{
Ticker,
Name,
Exchange,
Last,
Change,
ChangePercent,
Open,
Low,
High,
High52,
Low52,
Eps,
Pe,
Dividend,
Yield,
Shares,
Volume,
AvgVolume
};
const char* ToString(Property prop);
class Stock
{
static Property sort_;
static bool sort_forward_;
bool is_exchange_;
bool is_valid_;
std::string ticker_;
std::string name_;
std::string exchange_;
std::map<Property, double> stats_;
public:
Stock(const std::string& ticker = "", bool is_exchange = false);
static void set_sort(Property property);
static void set_sort_mode(bool forward);
static void toggle_sort_mode();
bool operator<(const Stock& r) const;
bool is_valid() const;
inline void set_valid() { is_valid_ = true; }
const std::string& get_ticker() const;
const std::string& get_name() const;
const std::string& get_exchange() const;
double get(Property prop) const;
void set(Property prop, std::string value);
void set(Property prop, double value);
};