-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathSymbolLookup.h
128 lines (98 loc) · 3.56 KB
/
SymbolLookup.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
/************************************************************************
* Copyright(c) 2021, One Unified. All rights reserved. *
* *
* This file is provided as is WITHOUT ANY WARRANTY *
* without even the implied warranty of *
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. *
* *
* This software may not be used nor distributed without proper license *
* agreement. *
* *
* See the file LICENSE.txt for redistribution information. *
************************************************************************/
/*
* File: SymbolLookup.h
* Author: [email protected]
* Project: TFIQFeed
* Created: Novemeber 2, 2021, 11:09
*/
#pragma once
#include <map>
#include <set>
#include <string>
#include <functional>
#include <OUCommon/Network.h>
#include <OUCommon/KeyWordMatch.h>
#include "SecurityType.h"
namespace ou { // One Unified
namespace tf { // TradeFrame
namespace iqfeed { // IQFeed
class SymbolLookup
: public ou::Network<SymbolLookup> {
friend ou::Network<SymbolLookup>;
public:
using key_t = uint16_t;
using inherited_t = ou::Network<SymbolLookup>;
using linebuffer_t = inherited_t::linebuffer_t;
struct ListedMarket {
//key_t idListedMarket;
std::string sShortName;
std::string sLongName;
std::string idGroup;
std::string sGroupName;
};
using mapListedMarket_t = std::map<key_t,ListedMarket>; // key = idListedMarket
struct SecurityType {
//key_t idSecurityType;
ESecurityType eSecurityType;
std::string sShortName;
std::string sLongName;
};
using mapSecurityType_t = std::map<key_t,SecurityType>; // key = idSecurityType
struct TradeCondition {
// key_t idTradeCondition
std::string sShortName;
std::string sLongName;
};
using mapTradeCondition_t = std::map<key_t,TradeCondition>; // key = idTradeCondition
using fDone_t = std::function<void()>;
SymbolLookup(
mapListedMarket_t&,
mapSecurityType_t&,
mapTradeCondition_t&,
fDone_t&&
);
virtual ~SymbolLookup();
void Connect();
void Disconnect();
using setNames_t = std::set<std::string>;
using fSymbol_t = std::function<void(const std::string&,key_t)>;
void SymbolList(
const setNames_t& setExchangeFilter, const setNames_t& setSecurityTypeFilter,
fSymbol_t&&, fDone_t&&
);
protected:
// called by Network via CRTP
void OnNetworkConnected();
void OnNetworkDisconnected();
void OnNetworkError( size_t e );
void OnNetworkSendDone();
void OnNetworkLineBuffer( linebuffer_t* ); // new line available for processing
private:
ou::KeyWordMatch<key_t> m_kwmListedMarket;
ou::KeyWordMatch<key_t> m_kwmSecurityType;
ou::KeyWordMatch<key_t> m_kwmTradeCondition;
mapListedMarket_t& m_mapListedMarket;
mapSecurityType_t& m_mapSecurityType;
mapTradeCondition_t& m_mapTradeCondition;
using setIdSecurityType_t = std::set<key_t>;
setIdSecurityType_t m_setIdSecurityType; // computed for each SBF query
fSymbol_t m_fSymbol;
fDone_t m_fDoneConnection;
fDone_t m_fDoneSymbolList;
void MapSecurityTypes();
void BuildKeyWords();
};
} // namespace iqfeed
} // namespace tf
} // namespace ou