-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathAcquireFundamentals.cpp
76 lines (66 loc) · 3.93 KB
/
AcquireFundamentals.cpp
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
/************************************************************************
* Copyright(c) 2021, 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: AcquireFundamentals.cpp
* Author: [email protected]
* Project: BasketTrading
* Created on September 18, 2021, 14:21
*/
#include "AcquireFundamentals.h"
namespace ou { // One Unified
namespace tf { // TradeFrame
AcquireFundamentals::AcquireFundamentals( pWatch_t&& pWatch, fDone_t&& fDone )
: m_pWatch( std::move( pWatch ) ), m_fDone( std::move( fDone ) ) {
assert( ou::tf::keytypes::EProviderIQF == m_pWatch->GetProvider()->ID() );
//std::cout << "AcquireFundamentals::AcquireFundamentals(): " << m_pWatch->GetInstrumentName() << std::endl;
}
AcquireFundamentals::~AcquireFundamentals() {
//std::cout << "AcquireFundamentals::~AcquireFundamentals(): " << m_pWatch->GetInstrumentName() << std::endl;
}
void AcquireFundamentals::Start() {
//std::cout << "AcquireFundamentals::Start(): " << m_pWatch->GetInstrumentName() << std::endl;
m_pWatch->OnFundamentals.Add( MakeDelegate( this, &AcquireFundamentals::HandleFundamentals) );
m_pWatch->OnTrade.Add( MakeDelegate( this, &AcquireFundamentals::HandleTrade ) );
m_pWatch->OnSummary.Add( MakeDelegate( this, &AcquireFundamentals::HandleSummary ) );
m_pWatch->StartWatch();
}
void AcquireFundamentals::HandleFundamentals( const ou::tf::Watch::Fundamentals& fundamentals ) {
// the watch will retain variables from the fundamentals message
//std::cout << "AcquireFundamentals::HandleFundamentals() enter: " << m_pWatch->GetInstrumentName() << std::endl;
//m_pWatch->StopWatch();
//m_pWatch->OnSummary.Remove( MakeDelegate( this, &AcquireFundamentals::HandleSummary ) );
//m_pWatch->OnTrade.Remove( MakeDelegate(this, &AcquireFundamentals::HandleTrade ) );
//m_pWatch->OnFundamentals.Remove( MakeDelegate( this, &AcquireFundamentals::HandleFundamentals) );
//m_fDone( m_pWatch ); // fundamentals reside in watch
//std::cout << "AcquireFundamentals::HandleFundamentals() exit: " << m_pWatch->GetInstrumentName() << std::endl;
}
void AcquireFundamentals::HandleSummary( const ou::tf::Watch::Summary& summary ) {
// summary comes after fundamentals, so this should ensure both are obtained
//std::cout << "AcquireFundamentals::HandleSummary() enter: " << m_pWatch->GetInstrumentName() << std::endl;
//if ( 0 < summary.nOpenInterest ) {
// std::cout << "acquire " << m_pWatch->GetInstrumentName() << " open interest " << summary.nOpenInterest << std::endl;
//}
m_pWatch->StopWatch();
m_pWatch->OnSummary.Remove( MakeDelegate( this, &AcquireFundamentals::HandleSummary ) );
m_pWatch->OnTrade.Remove( MakeDelegate(this, &AcquireFundamentals::HandleTrade ) );
m_pWatch->OnFundamentals.Remove( MakeDelegate( this, &AcquireFundamentals::HandleFundamentals) );
m_fDone( m_pWatch ); // fundamentals reside in watch
//std::cout << "AcquireFundamentals::HandleSummary() exit: " << m_pWatch->GetInstrumentName() << std::endl;
}
void AcquireFundamentals::HandleTrade( const ou::tf::Trade& trade ) {
// a watch is required in order to obtain the fundamental
// no action required, just a placeholder
}
} // namespace tf
} // namespace ou