-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathSymbol.h
139 lines (108 loc) · 4.25 KB
/
Symbol.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
129
130
131
132
133
134
135
136
137
138
139
/************************************************************************
* Copyright(c) 2009, One Unified. All rights reserved. *
* email: [email protected] *
* *
* 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. *
************************************************************************/
#pragma once
#include <vector>
#include <string>
#include <OUCommon/Delegate.h>
#include <TFTrading/Symbol.h>
#include <TFSimulation/SimulateOrderExecution.h>
#include "Messages.h"
#include "Fundamentals.h"
namespace ou { // One Unified
namespace tf { // TradeFrame
namespace iqfeed { // IQFeed
class Provider;
class IQFeedSymbol
: public Symbol<IQFeedSymbol>
{
friend class Provider;
public:
using inherited_t = Symbol<IQFeedSymbol>;
using pInstrument_t = inherited_t::pInstrument_t;
// Public for RowKeyValues. Pass in a structure sometime.
// Public for VuChartArmsIntraDay. Pass in structure sometime.
// Update/Summary
struct Summary {
ptime dtLastTrade;
double dblTrade;
double dblChange; // last - close
int nTotalVolume;
int nTradeSize;
double dblHigh;
double dblLow;
double dblBid;
double dblAsk;
int nBidSize;
int nAskSize;
int nOpenInterest;
double dblOpen;
double dblClose;
int cntTrades;
bool bNewTrade;
bool bNewQuote;
bool bNewOpen;
Summary()
: dblTrade {}, dblChange {},
nTotalVolume {}, nTradeSize {},
dblHigh {}, dblLow {},
dblBid {}, dblAsk {}, nBidSize( -1 ), nAskSize( -1 ),
nOpenInterest {},
dblOpen {}, dblClose {},
cntTrades {}, bNewTrade( false ), bNewQuote( false ), bNewOpen( false )
{}
};
IQFeedSymbol( const std::string &symbol, pInstrument_t pInstrument );
virtual ~IQFeedSymbol();
using pFundamentals_t = std::shared_ptr<Fundamentals>;
using pSummary_t = std::shared_ptr<Summary>;
ou::Delegate<pFundamentals_t> OnFundamentalMessage;
ou::Delegate<pSummary_t> OnUpdateMessage;
ou::Delegate<pSummary_t> OnSummaryMessage;
ou::Delegate<IQFeedSymbol&> OnNewsMessage;
pFundamentals_t GetFundamentals() { assert( m_pFundamentals ); return m_pFundamentals; }
void SubmitMarketDepthByMM( const ou::tf::DepthByMM& );
void SubmitMarketDepthByOrder( const ou::tf::DepthByOrder& );
protected:
unsigned short m_cnt; // used for watch/unwatch
enum enumQStatus { qUnknown, qFound, qNotFound } m_QStatus;
enum WatchState {
None, WSQuote, WSTrade, Both
};
void SetWatchState( WatchState state ) { m_stateWatch = state; };
WatchState GetWatchState() const { return m_stateWatch; };
using fLookupSecurityType_t = std::function<ESecurityType(int)>;
using fLookupListedMarket_t = std::function<std::string(std::string)>;
void HandleFundamentalMessage(
IQFFundamentalMessage* pMsg,
fLookupSecurityType_t&&,
fLookupListedMarket_t&&
);
void HandleUpdateMessage( IQFUpdateMessage* pMsg );
void HandleSummaryMessage( IQFSummaryMessage* pMsg );
void HandleDynamicFeedUpdateMessage( IQFDynamicFeedUpdateMessage* pMsg );
void HandleDynamicFeedSummaryMessage( IQFDynamicFeedSummaryMessage* pMsg );
void HandleNewsMessage( IQFNewsMessage* pMsg );
template <typename T>
void DecodePricingMessage( IQFPricingMessage<T>* pMsg );
template <typename T>
void DecodeDynamicFeedMessage( IQFDynamicFeedMessage<T>* pMsg );
private:
WatchState m_stateWatch;
bool m_bWaitForFirstQuote;
pFundamentals_t m_pFundamentals;
pSummary_t m_pSummary;
};
} // namespace iqfeed
} // namespace tf
} // namespace ou