-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathBuildSymbolName.h
60 lines (53 loc) · 2.95 KB
/
BuildSymbolName.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
/************************************************************************
* Copyright(c) 2015, 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. *
************************************************************************/
// started 2015/11/15
#pragma once
#include <cstdint>
#include <string>
#include <cassert>
namespace ou { // One Unified
namespace tf { // TradeFrame
namespace iqfeed { // IQFeed
struct NameParts {
InstrumentType::EInstrumentType it;
const std::string& sRootName;
uint16_t year;
uint16_t month;
uint16_t day;
double strike;
ou::tf::OptionSide::EOptionSide side;
NameParts(InstrumentType::EInstrumentType it_, const std::string& sRootName_)
: it( it_ ), sRootName( sRootName_), year(0), month(0), day(0), strike(0.0),
side( ou::tf::OptionSide::Unknown) {}
NameParts(InstrumentType::EInstrumentType it_, const std::string& sRootName_,
uint16_t year_, uint16_t month_, uint16_t day_,
double strike_, ou::tf::OptionSide::EOptionSide side_ )
: it( it_ ), sRootName( sRootName_ ), year( year_ ), month( month_ ), day( day_ ),
strike( strike_ ), side( side_ )
{ assert( 0 < month ); assert( 12 >= month ); }
NameParts(InstrumentType::EInstrumentType it_, const std::string& sRootName_,
uint16_t year_, uint16_t month_, uint16_t day_ )
: it( it_ ), sRootName( sRootName_ ), year( year_ ), month( month_ ), day( day_ ),
strike(0.0), side( ou::tf::OptionSide::Unknown)
{ assert( 0 < month ); assert( 12 >= month ); }
};
// months are 1 .. 12
const std::string BuildName( const NameParts& parts );
const std::string BuildOptionName( const std::string& sUnderlying, uint16_t year, uint16_t month, uint16_t day, double strike, ou::tf::OptionSide::EOptionSide side );
const std::string BuildFuturesName( const std::string& sUnderlying, uint16_t year, uint16_t month );
const std::string BuildFuturesOptionName( const std::string& sUnderlying, uint16_t year, uint16_t month, double strike, ou::tf::OptionSide::EOptionSide side );
const std::string BuildFuturesOptionName( const std::string& sUnderlying, uint16_t year, uint16_t month, uint16_t day, double strike, ou::tf::OptionSide::EOptionSide side );
} // namespace iqfeed
} // namespace tf
} // namespace ou