iron_warbler 2.0.7.49 → 2.0.7.50
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/assets/stylesheets/iron_warbler/application.css +0 -9
- data/app/assets/stylesheets/iron_warbler/positions.scss +4 -0
- data/app/assets/stylesheets/iron_warbler/positions_gameui.scss +2 -2
- data/app/assets/stylesheets/iron_warbler/purses.scss +2 -1
- data/app/assets/stylesheets/iron_warbler/purses_gameui.scss +13 -0
- data/app/assets/stylesheets/iron_warbler/purses_summary.scss +113 -79
- data/app/assets/stylesheets/iron_warbler/utils.scss +5 -4
- data/app/controllers/iro/positions_controller.rb +83 -22
- data/app/controllers/iro/purses_controller.rb +52 -52
- data/app/controllers/iro/stocks_controller.rb +1 -1
- data/app/views/iro/_main_header.haml +8 -9
- data/app/views/iro/positions/_form_spread.haml +5 -3
- data/app/views/iro/positions/_header.haml +1 -0
- data/app/views/iro/positions/_header_long_credit_put_spread.haml +11 -7
- data/app/views/iro/positions/_header_short_credit_call_spread.haml +10 -8
- data/app/views/iro/positions/_new.haml +2 -2
- data/app/views/iro/positions/_prepare_header_short_credit_call_spread.haml +4 -3
- data/app/views/iro/positions/_table_tr_covered_call.haml +1 -1
- data/app/views/iro/positions/_table_tr_long_credit_put_spread.haml +13 -4
- data/app/views/iro/positions/index.haml +5 -0
- data/app/views/iro/positions/place2.haml +27 -0
- data/app/views/iro/positions/prepare.haml +1 -1
- data/app/views/iro/positions/prepare2.haml +23 -21
- data/app/views/iro/purses/_form_extra_fields.haml +21 -16
- data/app/views/iro/purses/_header.haml +49 -36
- data/app/views/iro/purses/_summary.haml +60 -27
- data/app/views/iro/purses/_summary2.haml +77 -0
- data/app/views/iro/purses/gameui.haml +4 -7
- data/app/views/iro/purses/show.haml +1 -7
- data/app/views/iro/stocks/_form.haml +3 -0
- data/app/views/iro/stocks/index.haml +1 -1
- data/app/views/iro/strategies/_form_spread.haml +11 -10
- data/app/views/iro/strategies/_list.haml +4 -0
- data/app/views/iro/strategies/_show.haml +3 -2
- data/app/views/iro/strategies/_table.haml +8 -4
- data/app/views/layouts/iro/application.haml +1 -2
- data/config/routes.rb +6 -1
- metadata +5 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 34e2545b7c9088e737b36b2436c475bd820e1e0f00c507f84166eca1c616421e
|
|
4
|
+
data.tar.gz: 1e0bb92359a9ebc0c3a0e9cd4dc252e48da5097096f94855a88c2a0dfd41fd10
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3e0ea3ed8e276d87f870f295c61cf5c2119fe9b375d7f12f8b2090a1f161300883361f530d4855949cb2677f4a26d5a43f419efb52bf517d221d6182be2c2f0a
|
|
7
|
+
data.tar.gz: 5236754132aeee57af308c4c86e73fdb4a39de56770a47a0c125444fcc7f437ca544a525fabc0158c064690eb2b4cb478d8167a627f68298015534ae62f96c78
|
|
@@ -8,6 +8,18 @@
|
|
|
8
8
|
|
|
9
9
|
.purses-gameui {
|
|
10
10
|
|
|
11
|
+
.divider-expiry {
|
|
12
|
+
height: 5px;
|
|
13
|
+
width: 100%;
|
|
14
|
+
background: red;
|
|
15
|
+
}
|
|
16
|
+
.divider-ticker {
|
|
17
|
+
height: 2px;
|
|
18
|
+
width: 100%;
|
|
19
|
+
background: red;
|
|
20
|
+
margin-bottom: 20px;
|
|
21
|
+
}
|
|
22
|
+
|
|
11
23
|
.Origin::before {
|
|
12
24
|
position: absolute;
|
|
13
25
|
top: -1em;
|
|
@@ -95,6 +107,7 @@
|
|
|
95
107
|
|
|
96
108
|
// background: var(--iro-color-bg2);
|
|
97
109
|
// border: 1px solid red;
|
|
110
|
+
margin-top: 1em;
|
|
98
111
|
margin-bottom: 2em;
|
|
99
112
|
|
|
100
113
|
position: relative;
|
|
@@ -1,110 +1,144 @@
|
|
|
1
1
|
|
|
2
|
-
.
|
|
3
|
-
position: relative;
|
|
4
|
-
background: rgba(255,255,255, 0.75);
|
|
5
|
-
height: 400px;
|
|
6
|
-
width: 100%;
|
|
7
|
-
z-index: 5;
|
|
8
|
-
}
|
|
9
|
-
.PurseSummary {
|
|
10
|
-
position: absolute;
|
|
11
|
-
top: 200px;
|
|
12
|
-
|
|
2
|
+
.summaries {
|
|
13
3
|
display: flex;
|
|
4
|
+
}
|
|
5
|
+
.purses--summary2 {
|
|
6
|
+
// border: 1px solid yellow;
|
|
14
7
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
8
|
+
label {
|
|
9
|
+
position: absolute;
|
|
10
|
+
}
|
|
18
11
|
|
|
19
12
|
.legendW {
|
|
20
|
-
|
|
21
|
-
|
|
13
|
+
height: 100px;
|
|
14
|
+
margin-left: 60px;
|
|
22
15
|
|
|
23
|
-
|
|
24
|
-
|
|
16
|
+
display: flex;
|
|
17
|
+
}
|
|
25
18
|
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
19
|
+
.PurseSummaryW {
|
|
20
|
+
margin-left: 1em;
|
|
21
|
+
width: 500px;
|
|
22
|
+
z-index: 11;
|
|
23
|
+
height: 400px;
|
|
24
|
+
position: relative;
|
|
25
|
+
background: rgba(255,255,255, 0.75);
|
|
30
26
|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
27
|
+
}
|
|
28
|
+
.PurseSummary {
|
|
29
|
+
position: absolute;
|
|
30
|
+
top: 50%;
|
|
31
|
+
width: 100%;
|
|
32
|
+
height: 0;
|
|
33
|
+
border-bottom: 1px solid black;
|
|
34
34
|
}
|
|
35
35
|
|
|
36
|
+
/* shared */
|
|
37
|
+
.summary-long, .summary-short {
|
|
38
|
+
// border: 1px solid blue;
|
|
39
|
+
position: absolute;
|
|
36
40
|
|
|
37
|
-
|
|
38
|
-
* summary amount and delta
|
|
39
|
-
**/
|
|
40
|
-
.summary-amount {
|
|
41
|
-
position: relative;
|
|
42
|
-
width: 100px;
|
|
43
|
-
margin-right: 2em;
|
|
41
|
+
display: flex;
|
|
44
42
|
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
background: rgba(0,0,0, 0.5);
|
|
48
|
-
}
|
|
43
|
+
width: 100%;
|
|
44
|
+
// height: 300px;
|
|
49
45
|
|
|
50
|
-
.
|
|
46
|
+
.deltaW {
|
|
47
|
+
border: 2px solid black;
|
|
48
|
+
height: 0;
|
|
49
|
+
display: flex;
|
|
50
|
+
align-items: center;
|
|
51
51
|
position: absolute;
|
|
52
|
-
|
|
53
|
-
|
|
52
|
+
top: 50%;
|
|
53
|
+
left: 110px;
|
|
54
54
|
|
|
55
|
-
|
|
56
|
-
border:
|
|
57
|
-
width:
|
|
58
|
-
}
|
|
59
|
-
.begin {
|
|
60
|
-
width: 1em;
|
|
55
|
+
.delta {
|
|
56
|
+
// border: 2px dashed green;
|
|
57
|
+
width: 20px;
|
|
61
58
|
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
59
|
+
display: flex;
|
|
60
|
+
align-items: center;
|
|
61
|
+
|
|
62
|
+
.begin {
|
|
63
|
+
width: 100%;
|
|
64
|
+
background: rgba(0,0,0, 0.25);
|
|
65
|
+
}
|
|
66
|
+
.end {
|
|
67
|
+
width: 50%;
|
|
68
|
+
// background: rgba(0,0,0, 0.75);
|
|
69
|
+
}
|
|
67
70
|
|
|
68
|
-
background: rgba(255,0,0, 0.5);
|
|
69
71
|
}
|
|
70
72
|
}
|
|
71
73
|
|
|
72
|
-
|
|
74
|
+
/* shared */
|
|
75
|
+
.plot {
|
|
76
|
+
background: rgba(255,153,0, 0.5);
|
|
73
77
|
|
|
78
|
+
position: relative;
|
|
74
79
|
|
|
75
|
-
|
|
76
|
-
}
|
|
77
|
-
.gain {
|
|
78
|
-
}
|
|
79
|
-
.max-gl {
|
|
80
|
-
position: absolute;
|
|
81
|
-
width: 100%;
|
|
80
|
+
width: 100px;
|
|
82
81
|
|
|
83
|
-
|
|
84
|
-
|
|
82
|
+
.max-gl {
|
|
83
|
+
width: 100%;
|
|
84
|
+
position: absolute;
|
|
85
|
+
background: rgba(255,255,0, 0.5);
|
|
86
|
+
}
|
|
87
|
+
.net-gl {
|
|
88
|
+
position: absolute;
|
|
89
|
+
width: 90%;
|
|
90
|
+
}
|
|
91
|
+
.gain {
|
|
92
|
+
background: rgba(0,0,0, 0.70);
|
|
93
|
+
}
|
|
94
|
+
.loss {
|
|
95
|
+
background: rgba(255,0,0, 0.5);
|
|
96
|
+
}
|
|
85
97
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
98
|
}
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
.max-gl.short {
|
|
92
|
-
display: flex;
|
|
93
|
-
flex-direction: column-reverse;
|
|
94
|
-
}
|
|
95
|
-
.long {
|
|
96
|
-
position: absolute;
|
|
99
|
+
|
|
100
|
+
.summary-long {
|
|
97
101
|
top: 0;
|
|
98
102
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
103
|
+
.legendW {
|
|
104
|
+
flex-direction: column;
|
|
105
|
+
}
|
|
106
|
+
.plot {
|
|
107
|
+
bottom: 0;
|
|
108
|
+
.gain {
|
|
109
|
+
bottom: 0;
|
|
110
|
+
}
|
|
111
|
+
.max-gl {
|
|
112
|
+
bottom: 0;
|
|
113
|
+
}
|
|
114
|
+
}
|
|
102
115
|
}
|
|
103
|
-
.short {
|
|
104
|
-
background: rgba(255,153,0, 0.5);
|
|
105
|
-
border: 1px solid orange;
|
|
106
116
|
|
|
107
|
-
|
|
117
|
+
.summary-short {
|
|
108
118
|
bottom: 0;
|
|
119
|
+
|
|
120
|
+
display: flex;
|
|
121
|
+
align-items: flex-end;
|
|
122
|
+
|
|
123
|
+
.deltaW {
|
|
124
|
+
left: 140px;
|
|
125
|
+
}
|
|
126
|
+
label {
|
|
127
|
+
bottom: 0;
|
|
128
|
+
}
|
|
129
|
+
.legendW {
|
|
130
|
+
flex-direction: column-reverse;
|
|
131
|
+
}
|
|
132
|
+
.plot {
|
|
133
|
+
background: rgba(255,153,0, 0.5);
|
|
134
|
+
width: 100px;
|
|
135
|
+
|
|
136
|
+
.gain {
|
|
137
|
+
top: 0;
|
|
138
|
+
}
|
|
139
|
+
.loss {
|
|
140
|
+
bottom: 0;
|
|
141
|
+
}
|
|
142
|
+
}
|
|
109
143
|
}
|
|
110
|
-
}
|
|
144
|
+
}
|
|
@@ -70,7 +70,7 @@
|
|
|
70
70
|
/* M */
|
|
71
71
|
|
|
72
72
|
.mini-inputs {
|
|
73
|
-
background: rgba(255,255,255, 0.25);
|
|
73
|
+
// background: rgba(255,255,255, 0.25);
|
|
74
74
|
}
|
|
75
75
|
|
|
76
76
|
.modal-absolute {
|
|
@@ -83,15 +83,16 @@
|
|
|
83
83
|
position: absolute;
|
|
84
84
|
|
|
85
85
|
min-width: 200px;
|
|
86
|
-
width: 400px;
|
|
86
|
+
// width: 400px;
|
|
87
87
|
|
|
88
88
|
min-height: 200px;
|
|
89
|
-
height: 300px;
|
|
89
|
+
// height: 300px;
|
|
90
|
+
|
|
90
91
|
/* overflow: auto; */
|
|
91
92
|
|
|
92
93
|
background: white;
|
|
93
94
|
|
|
94
|
-
z-index:
|
|
95
|
+
z-index: 200;
|
|
95
96
|
|
|
96
97
|
}
|
|
97
98
|
|
|
@@ -1,26 +1,36 @@
|
|
|
1
1
|
|
|
2
2
|
class Iro::PositionsController < Iro::ApplicationController
|
|
3
|
-
|
|
3
|
+
|
|
4
|
+
def check
|
|
5
|
+
@position = Iro::Position.find params[:id]
|
|
6
|
+
authorize! :check, @position
|
|
7
|
+
outs = Tda::Order.check_status @position.schwab_order_id
|
|
8
|
+
@position.update({ schwab_status: outs[:status] })
|
|
9
|
+
puts! outs, 'outs'
|
|
10
|
+
redirect_to request.referrer
|
|
11
|
+
end
|
|
4
12
|
|
|
5
13
|
def create
|
|
6
14
|
@position = Iro::Position.new pos_params
|
|
7
15
|
authorize! :create, @position
|
|
8
16
|
|
|
9
|
-
@position.inner_strike = params[:inner][:strike]
|
|
10
|
-
@position.outer_strike = params[:outer][:strike]
|
|
17
|
+
# @position.inner_strike = params[:inner][:strike]
|
|
18
|
+
# @position.outer_strike = params[:outer][:strike]
|
|
11
19
|
|
|
12
20
|
o_attrs = {
|
|
13
21
|
expires_on: @position.expires_on,
|
|
14
|
-
put_call:
|
|
15
|
-
stock_id:
|
|
22
|
+
put_call: @position.put_call, # I need this. _vp_ 2024-04-26
|
|
23
|
+
stock_id: @position.stock_id,
|
|
16
24
|
}
|
|
17
|
-
@position.inner = Iro::Option.
|
|
18
|
-
@position.inner.
|
|
19
|
-
@position.inner.
|
|
25
|
+
@position.inner = Iro::Option.create!({ strike: params[:position][:inner_strike] }.merge( o_attrs ))
|
|
26
|
+
@position.inner.sync
|
|
27
|
+
@position.inner.begin_price = @position.inner.end_price
|
|
28
|
+
@position.inner.begin_delta = @position.inner.end_delta
|
|
20
29
|
if [ Iro::Strategy::KIND_LONG_CREDIT_PUT_SPREAD, Iro::Strategy::KIND_SHORT_CREDIT_CALL_SPREAD ].include?( @position.strategy.kind )
|
|
21
|
-
@position.outer = Iro::Option.
|
|
22
|
-
@position.outer.
|
|
23
|
-
@position.outer.
|
|
30
|
+
@position.outer = Iro::Option.create!({ strike: params[:position][:outer_strike] }.merge( o_attrs ))
|
|
31
|
+
@position.outer.sync
|
|
32
|
+
@position.outer.begin_price = @position.outer.end_price
|
|
33
|
+
@position.outer.begin_delta = @position.outer.end_delta
|
|
24
34
|
end
|
|
25
35
|
|
|
26
36
|
if @position.save
|
|
@@ -53,6 +63,7 @@ class Iro::PositionsController < Iro::ApplicationController
|
|
|
53
63
|
def edit
|
|
54
64
|
@position = Iro::Position.find params[:id]
|
|
55
65
|
authorize! :edit, @position
|
|
66
|
+
set_position_lists
|
|
56
67
|
end
|
|
57
68
|
|
|
58
69
|
def eval
|
|
@@ -68,6 +79,11 @@ class Iro::PositionsController < Iro::ApplicationController
|
|
|
68
79
|
redirect_to request.referrer
|
|
69
80
|
end
|
|
70
81
|
|
|
82
|
+
def index
|
|
83
|
+
authorize! :index, Iro::Position
|
|
84
|
+
@positions = Iro::Position.active
|
|
85
|
+
end
|
|
86
|
+
|
|
71
87
|
## only callable from _new.haml, with position partially pre-filled
|
|
72
88
|
def new
|
|
73
89
|
authorize! :new, Iro::Position
|
|
@@ -81,6 +97,40 @@ class Iro::PositionsController < Iro::ApplicationController
|
|
|
81
97
|
# outer: Iro::Option.new,
|
|
82
98
|
stock_id: strategy.stock_id,
|
|
83
99
|
}) )
|
|
100
|
+
|
|
101
|
+
set_position_lists
|
|
102
|
+
end
|
|
103
|
+
|
|
104
|
+
## only credit-spread
|
|
105
|
+
def reprice
|
|
106
|
+
@position = Iro::Position.find params[:id]
|
|
107
|
+
authorize! :roll, @position
|
|
108
|
+
@position.update({ pending_price: params[:pending_price] })
|
|
109
|
+
|
|
110
|
+
Tda::Order.cancel_order!( @position.schwab_order_id )
|
|
111
|
+
outs = Tda::Order.place_order!( Tda::Order.credit_spread_q @position )
|
|
112
|
+
|
|
113
|
+
flag = @position.update({
|
|
114
|
+
schwab_order_id: outs[:schwab_order_id],
|
|
115
|
+
schwab_status: outs[:schwab_status],
|
|
116
|
+
status: Iro::Position::STATUS_PENDING,
|
|
117
|
+
})
|
|
118
|
+
|
|
119
|
+
flash_notice flag
|
|
120
|
+
# redirect_to controller: :purses, action: :show, template: 'show', view_status: 'pending', id: @position.purse_id
|
|
121
|
+
redirect_to request.referrer
|
|
122
|
+
end
|
|
123
|
+
|
|
124
|
+
## place2 = credit-spread
|
|
125
|
+
def place2
|
|
126
|
+
@position = Iro::Position.find params[:id]
|
|
127
|
+
authorize! :roll, @position
|
|
128
|
+
@position.inner.sync
|
|
129
|
+
@position.inner.update({ begin_price: @position.inner.end_price })
|
|
130
|
+
@position.outer.sync
|
|
131
|
+
@position.outer.update({ begin_price: @position.outer.end_price })
|
|
132
|
+
@position.update({ pending_price: @position.place2_price })
|
|
133
|
+
@query = Tda::Order.credit_spread_q @position
|
|
84
134
|
end
|
|
85
135
|
|
|
86
136
|
## 2025-10-14 long_credit_put_spread
|
|
@@ -102,11 +152,6 @@ class Iro::PositionsController < Iro::ApplicationController
|
|
|
102
152
|
self.send("_prepare_#{@position.strategy.kind}")
|
|
103
153
|
end
|
|
104
154
|
|
|
105
|
-
## 2026-02-26 continue...
|
|
106
|
-
## short credit call spread
|
|
107
|
-
## covered call ???
|
|
108
|
-
## short credit call spread
|
|
109
|
-
## long credit put spread
|
|
110
155
|
def prepare2
|
|
111
156
|
@position = Iro::Position.find params[:id]
|
|
112
157
|
authorize! :roll, @position
|
|
@@ -136,15 +181,33 @@ class Iro::PositionsController < Iro::ApplicationController
|
|
|
136
181
|
end
|
|
137
182
|
end
|
|
138
183
|
|
|
184
|
+
## credit-spread
|
|
185
|
+
def place3
|
|
186
|
+
@position = Iro::Position.find params[:id]
|
|
187
|
+
@position.update({ pending_price: params[:pending_price] })
|
|
188
|
+
authorize! :place_order, @position
|
|
189
|
+
outs = Tda::Order.place_order!( Tda::Order.credit_spread_q @position )
|
|
190
|
+
|
|
191
|
+
flag = @position.update({
|
|
192
|
+
schwab_order_id: outs[:schwab_order_id],
|
|
193
|
+
schwab_status: outs[:schwab_status],
|
|
194
|
+
status: Iro::Position::STATUS_PENDING,
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
flash_notice flag
|
|
198
|
+
redirect_to controller: :purses, action: :show, template: 'show', view_status: 'pending', id: @position.purse_id
|
|
199
|
+
end
|
|
200
|
+
|
|
139
201
|
## 2026-02-26 continue...
|
|
140
202
|
## short credit call spread
|
|
141
203
|
def prepare3
|
|
142
204
|
@position = Iro::Position.find params[:id]
|
|
143
205
|
authorize! :place_order, @position
|
|
144
|
-
|
|
206
|
+
outs = Tda::Order.place_order!( Tda::Order.roll_credit_call_spread_q @position )
|
|
145
207
|
|
|
146
208
|
flag = @position.update({
|
|
147
|
-
schwab_order_id:
|
|
209
|
+
schwab_order_id: outs[:schwab_order_id],
|
|
210
|
+
schwab_status: outs[:schwab_status],
|
|
148
211
|
status: Iro::Position::STATUS_PENDING,
|
|
149
212
|
})
|
|
150
213
|
|
|
@@ -414,11 +477,9 @@ class Iro::PositionsController < Iro::ApplicationController
|
|
|
414
477
|
)
|
|
415
478
|
end
|
|
416
479
|
|
|
417
|
-
def
|
|
418
|
-
super
|
|
419
|
-
@purses_list = Iro::Purse.list
|
|
420
|
-
@strategies_list = Iro::Strategy.list(params[:long_or_short])
|
|
480
|
+
def set_position_lists
|
|
421
481
|
@stocks_list = Iro::Stock.list
|
|
482
|
+
@strategies_list = ( @position.purse.strategies.list + [[ @position.strategy.to_s, @position.strategy.id.to_s ]] ).uniq
|
|
422
483
|
end
|
|
423
484
|
|
|
424
485
|
end
|
|
@@ -34,52 +34,21 @@ class Iro::PursesController < Iro::ApplicationController
|
|
|
34
34
|
## table or gameui
|
|
35
35
|
def show
|
|
36
36
|
@purse = Iro::Purse.find(params[:id])
|
|
37
|
-
params[:template] = params[:template].presence || 'show'
|
|
38
37
|
authorize! :show, @purse
|
|
39
|
-
|
|
40
|
-
@positions = @purse.positions
|
|
38
|
+
params[:template] ||= 'show'
|
|
41
39
|
params[:view_status] ||= 'active'
|
|
42
|
-
if params[:view_status] && 'all' != params[:view_status]
|
|
43
|
-
@positions = @positions.where( status: params[:view_status] )
|
|
44
|
-
end
|
|
45
|
-
@positions = @positions.includes( :strategy
|
|
46
|
-
).order( expires_on: :asc, ticker: :desc, long_or_short: :asc, inner_strike: :asc )
|
|
47
|
-
|
|
48
|
-
## 2026-05-05 doesn't seem to work.
|
|
49
|
-
# if @positions.length == 0
|
|
50
|
-
# redirect_to new_position_path()
|
|
51
|
-
# return
|
|
52
|
-
# end
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
## lets only sync when I say.
|
|
56
|
-
## 2026-02-24
|
|
57
|
-
=begin
|
|
58
|
-
expiration_dates = @positions.map { |p| p.expires_on.to_s }.sort
|
|
59
|
-
quotes_h = Tda::Option.get_quotes_h({
|
|
60
|
-
contractType: 'ALL',
|
|
61
|
-
ticker: @positions[0].ticker,
|
|
62
|
-
fromDate: expiration_dates.first,
|
|
63
|
-
toDate: expiration_dates.last,
|
|
64
|
-
})
|
|
65
|
-
count = 1
|
|
66
|
-
@positions.each do |pos|
|
|
67
|
-
pos.inner.end_price = quotes_h[pos.expires_on.to_s][pos.put_call][pos.inner.strike][:price]
|
|
68
|
-
pos.inner.end_delta = quotes_h[pos.expires_on.to_s][pos.put_call][pos.inner.strike][:delta]
|
|
69
|
-
pos.inner.save ? print("#{count}^") : print("#{count}X")
|
|
70
|
-
if [ Iro::Strategy::KIND_LONG_CREDIT_PUT_SPREAD, Iro::Strategy::KIND_SHORT_CREDIT_CALL_SPREAD ].include?( pos.strategy.kind )
|
|
71
|
-
pos.outer.end_price = quotes_h[pos.expires_on.to_s][pos.put_call][pos.outer.strike][:price]
|
|
72
|
-
pos.outer.end_delta = quotes_h[pos.expires_on.to_s][pos.put_call][pos.outer.strike][:delta]
|
|
73
|
-
pos.outer.save ? print('^') : print('X')
|
|
74
|
-
end
|
|
75
|
-
count = count+1
|
|
76
|
-
end
|
|
77
|
-
=end
|
|
78
|
-
|
|
79
40
|
@unit = @purse.unit # 12 ## pixels per dollar
|
|
80
41
|
@height = @purse.height # 100 ## pixels
|
|
81
42
|
@n_dollars = 50 ## * unit * 2 = length of the grid
|
|
82
43
|
|
|
44
|
+
@positions = @purse.positions.where( status: params[:view_status]
|
|
45
|
+
).includes( :strategy
|
|
46
|
+
).order_by( expires_on: :asc, ticker: :asc, long_or_short: :asc, inner_strike: :asc )
|
|
47
|
+
|
|
48
|
+
if 'all' == params[:view_status]
|
|
49
|
+
@positions = @positions.unscope( where: :status )
|
|
50
|
+
end
|
|
51
|
+
|
|
83
52
|
calc_summary
|
|
84
53
|
|
|
85
54
|
render params[:template]
|
|
@@ -142,10 +111,10 @@ class Iro::PursesController < Iro::ApplicationController
|
|
|
142
111
|
@gain_long = 0
|
|
143
112
|
@gain_short = 0
|
|
144
113
|
|
|
145
|
-
@
|
|
146
|
-
@
|
|
147
|
-
@
|
|
148
|
-
@
|
|
114
|
+
@delta_long_begin = 0
|
|
115
|
+
@delta_short_begin = 0
|
|
116
|
+
@delta_long_end = 0
|
|
117
|
+
@delta_short_end = 0
|
|
149
118
|
|
|
150
119
|
@positions.each do |pos|
|
|
151
120
|
if Iro::Strategy::LONG == pos.strategy.long_or_short
|
|
@@ -153,22 +122,23 @@ class Iro::PursesController < Iro::ApplicationController
|
|
|
153
122
|
@max_gain_long += pos.max_gain * pos.q * 100
|
|
154
123
|
@gain_long += pos.net_amount * pos.q * 100
|
|
155
124
|
|
|
156
|
-
@
|
|
157
|
-
@
|
|
125
|
+
@delta_long_begin += pos.begin_delta * pos.q
|
|
126
|
+
@delta_long_end += pos.end_delta * pos.q
|
|
158
127
|
end
|
|
159
128
|
if Iro::Strategy::SHORT == pos.strategy.long_or_short
|
|
160
129
|
@max_loss_short += pos.max_loss * pos.q * 100
|
|
161
130
|
@max_gain_short += pos.max_gain * pos.q * 100
|
|
162
131
|
@gain_short += pos.net_amount * pos.q * 100
|
|
163
132
|
|
|
164
|
-
@
|
|
165
|
-
@
|
|
133
|
+
@delta_short_begin += pos.begin_delta * pos.q
|
|
134
|
+
@delta_short_end += pos.end_delta * pos.q
|
|
166
135
|
end
|
|
167
136
|
end
|
|
168
|
-
|
|
169
|
-
# @
|
|
170
|
-
@
|
|
171
|
-
|
|
137
|
+
|
|
138
|
+
# @delta_long_begin *= -1
|
|
139
|
+
# @delta_long_end *= -1
|
|
140
|
+
|
|
141
|
+
## 2026-05-07 being used.
|
|
172
142
|
if @gain_long < 0
|
|
173
143
|
@loss_long = @gain_long
|
|
174
144
|
@gain_long = nil
|
|
@@ -188,3 +158,33 @@ class Iro::PursesController < Iro::ApplicationController
|
|
|
188
158
|
|
|
189
159
|
end
|
|
190
160
|
|
|
161
|
+
|
|
162
|
+
|
|
163
|
+
|
|
164
|
+
|
|
165
|
+
|
|
166
|
+
## lets only sync when I say.
|
|
167
|
+
## 2026-02-24
|
|
168
|
+
=begin
|
|
169
|
+
expiration_dates = @positions.map { |p| p.expires_on.to_s }.sort
|
|
170
|
+
quotes_h = Tda::Option.get_quotes_h({
|
|
171
|
+
contractType: 'ALL',
|
|
172
|
+
ticker: @positions[0].ticker,
|
|
173
|
+
fromDate: expiration_dates.first,
|
|
174
|
+
toDate: expiration_dates.last,
|
|
175
|
+
})
|
|
176
|
+
count = 1
|
|
177
|
+
@positions.each do |pos|
|
|
178
|
+
pos.inner.end_price = quotes_h[pos.expires_on.to_s][pos.put_call][pos.inner.strike][:price]
|
|
179
|
+
pos.inner.end_delta = quotes_h[pos.expires_on.to_s][pos.put_call][pos.inner.strike][:delta]
|
|
180
|
+
pos.inner.save ? print("#{count}^") : print("#{count}X")
|
|
181
|
+
if [ Iro::Strategy::KIND_LONG_CREDIT_PUT_SPREAD, Iro::Strategy::KIND_SHORT_CREDIT_CALL_SPREAD ].include?( pos.strategy.kind )
|
|
182
|
+
pos.outer.end_price = quotes_h[pos.expires_on.to_s][pos.put_call][pos.outer.strike][:price]
|
|
183
|
+
pos.outer.end_delta = quotes_h[pos.expires_on.to_s][pos.put_call][pos.outer.strike][:delta]
|
|
184
|
+
pos.outer.save ? print('^') : print('X')
|
|
185
|
+
end
|
|
186
|
+
count = count+1
|
|
187
|
+
end
|
|
188
|
+
=end
|
|
189
|
+
|
|
190
|
+
|