-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathMarketSymbol.h
149 lines (122 loc) · 5.19 KB
/
MarketSymbol.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
140
141
142
143
144
145
146
147
148
149
/************************************************************************
* Copyright(c) 2012, 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 <bitset>
#include <string>
#include <boost/date_time/gregorian/greg_date.hpp>
#include <boost/archive/binary_oarchive.hpp>
#include <boost/archive/binary_iarchive.hpp>
#include <OUSQL/Functions.h>
#include <TFTrading/TradingEnumerations.h>
#include "SecurityType.h"
#include "Fundamentals.h"
namespace ou { // One Unified
namespace tf { // TradeFrame
namespace iqfeed { // IQFeed
// Coding for writing to a sqlite database was stopped as it appeared to take about four to five hours to update
// about a million records. A bit too long for instant gratification.
// 2013/10/09 Will need to try it in release mode.
class MarketSymbol {
public:
struct TableRowDef {
std::string sSymbol;
std::string sDescription;
std::string sExchange;
std::string sListedMarket;
ESecurityType sc;
boost::uint16_t nMultiplier;
boost::uint32_t nSIC;
boost::uint32_t nNAICS;
std::string sUnderlying;
ou::tf::OptionSide::EOptionSide eOptionSide;
double dblStrike;
boost::uint16_t nYear;
boost::uint8_t nMonth;
boost::uint8_t nDay;
bool bFrontMonth;
bool bHasOptions;
template<class A>
void Fields( A& a) {
ou::db::Field( a, "symbol", sSymbol );
ou::db::Field( a, "description", sDescription );
ou::db::Field( a, "exchange", sExchange );
ou::db::Field( a, "market", sListedMarket );
ou::db::Field( a, "symbolclass", sc );
ou::db::Field( a, "multiplier", nMultiplier ); // 2014/10/11 new field, parsers need to be changed to update this field
ou::db::Field( a, "sic", nSIC );
ou::db::Field( a, "naics", nNAICS );
ou::db::Field( a, "underlying", sUnderlying );
ou::db::Field( a, "optionside", eOptionSide );
ou::db::Field( a, "strike", dblStrike );
ou::db::Field( a, "year", nYear );
ou::db::Field( a, "month", nMonth );
ou::db::Field( a, "day", nDay );
ou::db::Field( a, "frontmonth", bFrontMonth );
ou::db::Field( a, "hasoptions", bHasOptions );
}
TableRowDef(void): dblStrike( 0 ), nYear( 0 ), nMonth( 0 ), nDay( 0 ),
sc( ESecurityType::Unknown ), bFrontMonth( false ), bHasOptions( false ), nSIC( 0 ), nNAICS( 0 ), nMultiplier( 1 ),
eOptionSide( ou::tf::OptionSide::Unknown ) {};
private:
/* serialization support */
friend class boost::serialization::access;
template<class Archive>
void serialize(Archive& ar,const unsigned int) {
ar
& BOOST_SERIALIZATION_NVP(sSymbol)
& BOOST_SERIALIZATION_NVP(sDescription)
& BOOST_SERIALIZATION_NVP(sExchange)
& BOOST_SERIALIZATION_NVP(sListedMarket)
& BOOST_SERIALIZATION_NVP(sc)
& BOOST_SERIALIZATION_NVP(nSIC)
& BOOST_SERIALIZATION_NVP(nNAICS)
& BOOST_SERIALIZATION_NVP(sUnderlying)
& BOOST_SERIALIZATION_NVP(eOptionSide)
& BOOST_SERIALIZATION_NVP(dblStrike)
& BOOST_SERIALIZATION_NVP(nYear)
& BOOST_SERIALIZATION_NVP(nMonth)
& BOOST_SERIALIZATION_NVP(nDay)
& BOOST_SERIALIZATION_NVP(bFrontMonth)
& BOOST_SERIALIZATION_NVP(bHasOptions)
;
}
};
struct TableCreateDef: TableRowDef {
template<class A>
void Fields( A& a ) {
TableRowDef::Fields( a );
ou::db::Key( a, "symbol" );
}
};
MarketSymbol();
MarketSymbol( const TableRowDef& row ) : m_row( row ) {};
~MarketSymbol();
const TableRowDef& GetRow( void ) const { return m_row; };
using Date = boost::gregorian::date;
// equity, ieoption (from trd)
const std::string static BuildGenericName( const std::string& sBaseName, const TableRowDef& );
// equity, ieoption, future, futures option (from fundamentals)
const std::string static BuildGenericName( const std::string& sBaseName, const TableRowDef&, Date );
// use fundamentals directly
const std::string static BuildGenericName( const TableRowDef&, const Fundamentals& );
// use fundamentals only
const std::string static BuildGenericName( const Fundamentals& );
const std::string static OptionBaseName( const Fundamentals& );
protected:
private:
TableRowDef m_row;
};
} // namespace iqfeed
} // namespace tf
} // namespace ou