-
Notifications
You must be signed in to change notification settings - Fork 163
/
Copy pathMargin.h
148 lines (116 loc) · 8.12 KB
/
Margin.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
/************************************************************************
* Copyright(c) 2013, 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. *
************************************************************************/
// started 2013-05-25
#pragma once
#include <assert.h>
#include <TFTrading/Instrument.h>
namespace ou { // One Unified
namespace tf { // TradeFrame
namespace option { // options
namespace margin { // options
// need to add ability to do stock options, index options, world currency options, cash basket option
// need validation function for each style
// margin requirements not correct, need option contract multiplier
typedef ou::tf::Instrument::pInstrument_cref pInstrument_cref;
struct MarginRequirement {
double margin;
MarginRequirement( void ): margin {} {};
};
struct RegT: MarginRequirement {};
//struct RegTInitialOrMaintenance: RegT {};
struct RegTInitial: RegT {};
struct RegTMaintenance: RegT {};
struct RegTEndOfDay: RegT {};
struct CashOrRegTIra: MarginRequirement {};
struct Cash: CashOrRegTIra {};
struct RegTIra: CashOrRegTIra {};
struct Source {
pInstrument_cref pInstrument;
unsigned int quantity;
double price;
};
struct Underlying: Source {};
struct ZeroUnderlying: Source {};
struct ShortUnderlying: Underlying {};
struct LongUnderlying: Underlying {};
struct Option: Source {};
struct LongOption: Option {};
struct ShortOption: Option {};
struct LongCall: LongOption {};
struct LongPut: LongOption {};
struct ShortCall: ShortOption {};
struct ShortPut: ShortOption {};
void Calc( RegTInitial&, const LongUnderlying& src );
void Calc( RegTMaintenance&, const LongUnderlying& src );
void Calc( RegTEndOfDay&, const LongUnderlying& src );
void Calc( CashOrRegTIra&, const LongUnderlying& src );
void Calc( RegTInitial&, const ShortUnderlying& src );
void Calc( RegTMaintenance&, const ShortUnderlying& src );
void Calc( RegTEndOfDay&, const ShortUnderlying& src );
void Calc( CashOrRegTIra&, const ShortUnderlying& src );
void Calc( MarginRequirement& mr, const LongOption& src ); // long call or put
void Calc( RegT& mr, const ZeroUnderlying& under, const ShortCall& call ); // naked short call
void Calc( CashOrRegTIra& mr, const ZeroUnderlying& under, const ShortCall& call );
void Calc( RegT& mr, const ZeroUnderlying& under, const ShortPut& put ); // naked short put
void Calc( CashOrRegTIra& mr, const ZeroUnderlying& under, const ShortPut& put );
void Calc( RegT& mr, const LongUnderlying& under, const ShortCall& call ); // covered call
void Calc( Cash& mr, const LongUnderlying& under, const ShortCall& call );
void Calc( RegTIra& mr, const LongUnderlying& under, const ShortCall& call );
void Calc( RegT& mr, const LongUnderlying& under, const ShortPut& put ); // covered put
void Calc( CashOrRegTIra& mr, const LongUnderlying& under, const ShortPut& put );
void Calc( RegT& mr, const LongCall& longc, const ShortCall& shortc ); // call spread
void Calc( Cash& mr, const LongCall& longc, const ShortCall& shortc );
void Calc( RegTIra& mr, const LongCall& longc, const ShortCall& shortc );
void Calc( RegT& mr, const LongPut& longp, const ShortPut& shortp ); // put spread
void Calc( Cash& mr, const LongPut& longp, const ShortPut& shortp );
void Calc( RegTIra& mr, const LongPut& longp, const ShortPut& shortp );
void Calc( RegTInitial& mr, const LongUnderlying& under, const ShortCall& call, const LongPut& put ); // collar, conversion
void Calc( RegTMaintenance& mr, const LongUnderlying& under, const ShortCall& call, const LongPut& put ); // collar, conversion
void Calc( RegTEndOfDay& mr, const LongUnderlying& under, const ShortCall& call, const LongPut& put ); // collar, conversion
void Calc( CashOrRegTIra& mr, const LongUnderlying& under, const ShortCall& call, const LongPut& put ); // collar, conversion
void Calc( MarginRequirement& mr, const LongCall& call, const LongPut& put ); // long call and long put
void Calc( RegT& mr, const ZeroUnderlying& under, const ShortCall& call, const ShortPut& put ); // short call and short put
void Calc( CashOrRegTIra& mr, const ZeroUnderlying& under, const ShortCall& call, const ShortPut& put );
void Calc( RegT& mr, const LongOption& opt1, const ShortOption& opt2, const LongOption& opt3 ); // long butterfly
void Calc( Cash& mr, const LongOption& opt1, const ShortOption& opt2, const LongOption& opt3 ); // long butterfly
void Calc( RegTIra& mr, const LongOption& opt1, const ShortOption& opt2, const LongOption& opt3 ); // long butterfly
void Calc( RegT& mr, const ShortPut& put1, const LongPut& put2, const ShortPut& put3 ); // short butterfly put
void Calc( CashOrRegTIra& mr, const ShortPut& put1, const LongPut& put2, const ShortPut& put3 );
void Calc( RegT& mr, const ShortCall& call1, const LongCall& call2, const ShortCall& call3 ); // short butterfly call
void Calc( CashOrRegTIra& mr, const ShortCall& call1, const LongCall& call2, const ShortCall& call3 );
void Calc( RegT& mr, const LongCall& call1, const ShortPut& put1, const LongPut& put2, const ShortCall& call2 ); // long box spread
void Calc( Cash& mr, const LongCall& call1, const ShortPut& put1, const LongPut& put2, const ShortCall& call2 );
void Calc( RegTIra& mr, const LongCall& call1, const ShortPut& put1, const LongPut& put2, const ShortCall& call2 );
void Calc( RegT& mr, const LongPut& lput, const ShortCall& scall, const ShortPut& sput, const LongCall& lcall ); // short box spread
void Calc( Cash& mr, const LongPut& lput, const ShortCall& scall, const ShortPut& sput, const LongCall& lcall );
void Calc( RegTIra& mr, const LongPut& lput, const ShortCall& scall, const ShortPut& sput, const LongCall& lcall );
void Calc( RegTInitial& mr, const ShortUnderlying& under, const LongCall& call, const ShortPut& put ); // reverse conversion
void Calc( RegTMaintenance& mr, const ShortUnderlying& under, const LongCall& call, const ShortPut& put ); // reverse conversion
void Calc( RegTEndOfDay& mr, const ShortUnderlying& under, const LongCall& call, const ShortPut& put ); // reverse conversion
void Calc( CashOrRegTIra& mr, const ShortUnderlying& under, const LongCall& call, const ShortPut& put );
void Calc( RegTInitial& mr, const LongUnderlying& under, const LongPut& put ); // protective put
void Calc( RegTMaintenance& mr, const LongUnderlying& under, const LongPut& put ); // protective put
void Calc( RegTEndOfDay& mr, const LongUnderlying& under, const LongPut& put ); // protective put
void Calc( CashOrRegTIra& mr, const LongUnderlying& under, const LongPut& put ); // protective put
void Calc( RegTInitial& mr, const ShortUnderlying& under, const LongCall& call ); // protective call
void Calc( RegTMaintenance& mr, const ShortUnderlying& under, const LongCall& call ); // protective call
void Calc( RegTEndOfDay& mr, const ShortUnderlying& under, const LongCall& call ); // protective call
void Calc( CashOrRegTIra& mr, const ShortUnderlying& under, const LongCall& call ); // protective call
void Calc( RegT& mr, const ShortPut& sput, const LongPut& lput, const ShortCall& scall, const LongCall& lcall ); // iron condor
void Calc( Cash& mr, const ShortPut& sput, const LongPut& lput, const ShortCall& scall, const LongCall& lcall ); // iron condor
void Calc( RegTIra& mr, const ShortPut& sput, const LongPut& lput, const ShortCall& scall, const LongCall& lcall ); // iron condor
} // namespace margin
} // namespace option
} // namespace tf
} // namespace ou