-
Notifications
You must be signed in to change notification settings - Fork 157
/
ComposeInstrument.hpp
104 lines (78 loc) · 3.18 KB
/
ComposeInstrument.hpp
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
/************************************************************************
* Copyright(c) 2022, 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. *
************************************************************************/
/*
* File: ComposeInstrument.h
* Author: [email protected]
* Project: TFTrading
* Created: 2022/11/14 10:37:56
*/
// distinguish between futures & equities
// turn a continuous future into the appropriate front month
#pragma once
#include <unordered_map>
#include "BuildInstrument.h"
namespace ou { // One Unified
namespace tf { // TradeFrame
namespace iqfeed { // IQFeed
class OptionChainQuery;
} // namespace iqfeed
class ComposeInstrument {
public:
using pInstrument_t = ou::tf::Instrument::pInstrument_t;
using fInstrument_t = ou::tf::BuildInstrument::fInstrument_t;
using pProviderIBTWS_t = ou::tf::ib::TWS::pProvider_t;
using pProviderIQFeed_t = ou::tf::iqfeed::Provider::pProvider_t;
using fInitDone_t = std::function<void()>;
ComposeInstrument( pProviderIQFeed_t, fInitDone_t&& );
ComposeInstrument( pProviderIQFeed_t, pProviderIBTWS_t, fInitDone_t&& );
~ComposeInstrument();
void Compose( const std::string& sIQFeedSymbol, fInstrument_t&& );
// any threading issues here?
using pOptionChainQuery_t = std::shared_ptr<ou::tf::iqfeed::OptionChainQuery>;
pOptionChainQuery_t OptionChainQuery() { return m_pOptionChainQuery; }
protected:
private:
struct Query {
bool bConstructed;
fInstrument_t fInstrument;
pInstrument_t pInstrument;
size_t cntInstrumentsProcessed;
Query( fInstrument_t&& fInstrument_ )
: bConstructed( false )
, fInstrument( std::move( fInstrument_ ) )
, cntInstrumentsProcessed {}
{}
Query( Query&& query )
: bConstructed( false )
, fInstrument( std::move( query.fInstrument ) )
, pInstrument( std::move( query.pInstrument ) )
, cntInstrumentsProcessed( query.cntInstrumentsProcessed )
{}
};
std::mutex m_mutexMap;
using pMapQuery_t = std::unordered_map<std::string,Query>;
pMapQuery_t m_pMapQuery;
using pBuildInstrument_t = std::unique_ptr<BuildInstrument>;
pProviderIQFeed_t m_pProviderIQFeed;
pProviderIBTWS_t m_pProviderIBTWS;
fInitDone_t m_fInitDone;
pBuildInstrument_t m_pBuildInstrumentIQFeed;
pBuildInstrument_t m_pBuildInstrumentBoth;
pOptionChainQuery_t m_pOptionChainQuery;
void Initialize();
void ConstructChainQuery();
void Finish( pMapQuery_t::iterator );
};
} // namespace tf
} // namespace ou