-
Notifications
You must be signed in to change notification settings - Fork 165
/
Copy pathAggregate.h
95 lines (73 loc) · 3.34 KB
/
Aggregate.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
/************************************************************************
* 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: Aggregate.h
* Author: [email protected]
* Project: TFOptions
* Created on May 29, 2021, 20:09
*/
// Testing / Proof of concept that GEX might be useful in some capacity
// Relies on iqfeed trade-only message, reduces traffic, therefore more symbols available
// the problem: needs recent quotes to recalculate greeks at current pricing level
// might be ok, f<symbol> returns F, and P, responses, with P having the latest quote
// TODO: attempt to understand option combinations transacted (if transactions are sparse)
#pragma once
#include <TFTimeSeries/DatedDatum.h>
#include <TFTimeSeries/TimeSeries.h>
#include <TFOptions/Option.h>
#include <TFOptions/GatherOptions.h>
#include "Chain.h"
namespace ou { // One Unified
namespace tf { // TradeFrame
namespace option { // options
class Aggregate {
public:
using pWatch_t = ou::tf::Watch::pWatch_t;
using pOption_t = ou::tf::option::Option::pOption_t;
using fDate_t = std::function<void(boost::gregorian::date)>;
Aggregate(
pWatch_t pWatchUnderlying
);
void LoadChains( fGatherOptions_t&& ); // start in constructor?
void FilterChains();
void WalkChains( fDate_t&& ) const;
void WalkChains( fOption_t&& ) const;
void WalkChain( boost::gregorian::date, fOption_t&& ) const;
// TODO:
// constructor needs engine add/remove
// will require registration to P message for current quote
// NOTE: a start watch in Watch activates both quote & trade
// need to change that, or issue watch directly to the iqfeed provider
protected:
private:
using volume_t = ou::tf::DatedDatum::volume_t;
pWatch_t m_pWatchUnderlying;
struct OptionWithStats: public ou::tf::option::chain::OptionName {
// should volumes net out? seems they will monotonically increase
// without input from open interest numbers. does it matter?
// gamma calculation, serialize buy/sell for inter-session updates
volume_t sell; // total sell side options for gex calc
volume_t buy; // total buy side options for gex calc
pOption_t pOption; // might as well keep the fully decorated option around as well
OptionWithStats()
: sell {}, buy {} {}
};
using chain_t = ou::tf::option::Chain<OptionWithStats>;
using mapChains_t = std::map<boost::gregorian::date, chain_t>;
using mapChains_iterator_t = mapChains_t::iterator;
mapChains_t m_mapChains;
};
} // namespace option
} // namespace tf
} // namespace ou