-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathBarHistory.h
80 lines (64 loc) · 2.55 KB
/
BarHistory.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
/************************************************************************
* 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: BarHistory.h
* Author: [email protected]
* Project: lib/TFIQFeed
* Created: August 7, 2021, 19:06
*/
#pragma once
#include <string>
#include <functional>
#include <TFIQFeed/HistoryQuery.h>
#include <TFTimeSeries/DatedDatum.h>
namespace ou {
namespace tf {
namespace iqfeed {
class BarHistory: HistoryQuery<BarHistory> {
friend HistoryQuery<BarHistory>;
public:
using fConnected_t = std::function<void()>;
using fBar_t = std::function<void(const ou::tf::Bar&)>;
using fDone_t = std::function<void()>;
using pBarHistory_t = std::unique_ptr<BarHistory>;
static pBarHistory_t Construct( fConnected_t&& fConnected ) {
return std::make_unique<BarHistory>( std::move( fConnected ) );
}
BarHistory();
BarHistory( fConnected_t&& ); // multiple requests
BarHistory( fConnected_t&&, fBar_t&&, fDone_t&& ); // single request
virtual ~BarHistory();
void Set( fBar_t&&, fDone_t&& );
void Set( fConnected_t&&, fBar_t&&, fDone_t&& );
void Connect();
void RequestNBars( const std::string& sSymbol, unsigned int nSeconds, unsigned int nBars );
void RequestNDaysOfBars( const std::string& sSymbol, unsigned int nSeconds, unsigned int nDays );
void RequestNEndOfDay( const std::string& sSymbol, unsigned int nDays );
void Disconnect();
protected:
void OnHistoryConnected();
void OnHistoryDisconnected();
void OnHistoryIntervalData( Interval* pDP );
void OnHistoryEndOfDayData( EndOfDay* pDP );
void OnHistoryRequestDone( bool );
void OnHistorySendDone();
void OnHistoryError( size_t e );
private:
bool m_bConnected;
fConnected_t m_fConnected;
fBar_t m_fBar;
fDone_t m_fDone;
};
} // namespace iqfeed
} // namespace tf
} // namespace ou