Files
spark/src/lib/md/UserSymbol.h
T
2017-09-21 16:51:48 -04:00

56 lines
1.6 KiB
C++

#pragma once
#include "common.h"
namespace bts {
namespace md2 {
struct UserSymbol {
UserSymbol() : _symbol(), _exchange(), _type() {}
UserSymbol(const std::string& s, api::Venue e, SecurityType t) :
_symbol(s), _exchange(e), _type(t) {}
UserSymbol(const UserSymbol& other) :
_symbol(other._symbol), _exchange(other._exchange), _type(other._type) {}
const std::string& symbol() const { return _symbol; }
api::Venue exchange() const { return _exchange; }
SecurityType type() const { return _type; }
bool operator== (const UserSymbol& other) const {
return _type == other.type() && _exchange == other.exchange() && _symbol == other.symbol();
}
bool operator< (const UserSymbol& other) const {
if (_type < other.type()) {
return true;
}
else {
if (_type == other.type()) {
if (_exchange < other.exchange()) {
return true;
}
else {
if (_exchange == other.exchange()) {
return _symbol < other.symbol();
}
}
return false;
}
return false;
}
}
std::string to_string() const {
return symbol() + "-" + SecurityType_Name(type());
}
// No move constructor -
// because in this case the std::string will be a stock symbol which should be
// small enough to be inlined in both msvsc and gcc/clang
private:
std::string _symbol;
api::Venue _exchange;
SecurityType _type;
};
std::ostream& operator<<(std::ostream& os, const UserSymbol& sym);
}}