-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathNotebookOptionChains.h
169 lines (126 loc) · 5.51 KB
/
NotebookOptionChains.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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
/************************************************************************
* Copyright(c) 2017, 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: NotebookOptionChains.h
* Author: [email protected]
*
* Created on July 2, 2017, 8:16 PM
*/
#ifndef WINOPTIONCHAINS_H
#define WINOPTIONCHAINS_H
#include <map>
#include <boost/signals2.hpp>
#include <boost/serialization/version.hpp>
#include <boost/serialization/split_member.hpp>
#include <wx/wx.h>
#include <wx/listbook.h>
#include <TFTrading/TradingEnumerations.h>
#include <TFOptions/Option.h>
#include <TFVuTrading/GridOptionChain.hpp>
#include <TFBitsNPieces/FirstOrDefaultCombiner.h>
// superceded by PanelComboOrder.hpp
namespace ou { // One Unified
namespace tf { // TradeFrame
#define SYMBOL_OPTIONCHAINS_STYLE wxTAB_TRAVERSAL | wxNB_LEFT
#define SYMBOL_OPTIONCHAINS_TITLE _("Notebook Option Chains")
#define SYMBOL_OPTIONCHAINS_IDNAME ID_NOTEBOOK_OPTIONDETAILS
#define SYMBOL_OPTIONCHAINS_SIZE wxSize(-1, -1)
#define SYMBOL_OPTIONCHAINS_POSITION wxDefaultPosition
class NotebookOptionChains:
public wxListbook
{
friend class boost::serialization::access;
public:
NotebookOptionChains();
NotebookOptionChains(
wxWindow* parent, wxWindowID id = SYMBOL_OPTIONCHAINS_IDNAME,
const wxPoint& pos = SYMBOL_OPTIONCHAINS_POSITION,
const wxSize& size = SYMBOL_OPTIONCHAINS_SIZE,
long style = SYMBOL_OPTIONCHAINS_STYLE,
const wxString& name = SYMBOL_OPTIONCHAINS_TITLE );
virtual ~NotebookOptionChains();
bool Create( wxWindow* parent,
wxWindowID id = SYMBOL_OPTIONCHAINS_IDNAME,
const wxPoint& pos = SYMBOL_OPTIONCHAINS_POSITION,
const wxSize& size = SYMBOL_OPTIONCHAINS_SIZE,
long style = SYMBOL_OPTIONCHAINS_STYLE,
const wxString& name = SYMBOL_OPTIONCHAINS_TITLE );
using fOnPageEvent_t = std::function<void(boost::gregorian::date)>;
void Set(
fOnPageEvent_t&& fOnPageChanging // departed
, fOnPageEvent_t&& fOnPageChanged // arrival
);
void SetName( const std::string& sName ); // underlying
virtual void Add( boost::gregorian::date, double strike, ou::tf::OptionSide::EOptionSide, const std::string& sSymbol );
using fOnRowClicked_t = std::function<void(boost::gregorian::date, double, bool bSelected, const ou::tf::option::Delegates& call, const ou::tf::option::Delegates& put )>;
fOnRowClicked_t m_fOnRowClicked; // called when a row is control clicked
using fOnOptionUnderlyingRetrieve_t = std::function<void(const std::string&, boost::gregorian::date, double, GridOptionChain::fOnOptionUnderlyingRetrieveComplete_t )>;
fOnOptionUnderlyingRetrieve_t m_fOnOptionUnderlyingRetrieve;
void SetGridOptionChain_ColumnSaver( ou::tf::GridColumnSizer* );
protected:
private:
enum {
ID_Null=wxID_HIGHEST, ID_NOTEBOOK_OPTIONDETAILS
};
fOnPageEvent_t m_fOnPageChanging; // about to depart page
fOnPageEvent_t m_fOnPageChanged; // new page in place
// put/call at strike
struct Row {
int ixRow;
std::string sCall;
std::string sPut;
explicit Row( int ix = 0 ): ixRow( ix ) {}
};
// the strike list
using mapStrike_t = std::map<double, Row>;
struct Tab {
size_t ixTab;
std::string sDate;
mapStrike_t mapStrike;
wxPanel* pPanel;
GridOptionChain* pWinOptionChain;
Tab( int ix = 0, const std::string& s = "", wxPanel* pPanel_ = nullptr, ou::tf::GridOptionChain* pGrid = nullptr )
: ixTab( ix ), sDate( s ), pPanel( pPanel_ ), pWinOptionChain( pGrid ) {}
Tab( const std::string& s, wxPanel* pPanel_ = nullptr, ou::tf::GridOptionChain* pGrid = nullptr )
: ixTab{}, sDate( s ), pPanel( pPanel_ ), pWinOptionChain( pGrid ) {}
};
using mapOptionExpiry_t = std::map<boost::gregorian::date, Tab>;
mapOptionExpiry_t m_mapOptionExpiry;
bool m_bBound;
std::string m_sName; // should be underlying so can use to lookup in PanelCharts
ou::tf::GridColumnSizer* m_pgcsGridOptionChain;
void OnPageChanged( wxBookCtrlEvent& event );
void OnPageChanging( wxBookCtrlEvent& event );
void Init();
void CreateControls();
void OnDestroy( wxWindowDestroyEvent& event );
wxBitmap GetBitmapResource( const wxString& name );
wxIcon GetIconResource( const wxString& name );
static bool ShowToolTips() { return true; };
void BindEvents();
void UnbindEvents();
template<typename Archive>
void save( Archive& ar, const unsigned int version ) const {
//ar & boost::serialization::base_object<const TreeItemResources>(*this);
}
template<typename Archive>
void load( Archive& ar, const unsigned int version ) {
//ar & boost::serialization::base_object<TreeItemResources>(*this);
}
BOOST_SERIALIZATION_SPLIT_MEMBER()
};
} // namespace tf
} // namespace ou
BOOST_CLASS_VERSION(ou::tf::NotebookOptionChains, 1)
#endif /* WINOPTIONCHAINS_H */