iron_warbler 2.0.7.19 → 2.0.7.21
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascript/iron_warbler/application.js +2 -0
- data/app/assets/javascript/iron_warbler/gameui.js +9 -0
- data/app/assets/stylesheets/iron_warbler/application.css +13 -3
- data/app/assets/stylesheets/iron_warbler/positions.scss +24 -5
- data/app/assets/stylesheets/iron_warbler/purses_gameui.scss +214 -0
- data/app/assets/stylesheets/iron_warbler/purses_gameui.scss-bk +112 -0
- data/app/assets/stylesheets/iron_warbler/utils.scss +81 -0
- data/app/controllers/iro/api/stocks_controller.rb +87 -0
- data/app/controllers/iro/api_controller.rb +19 -0
- data/app/controllers/iro/positions_controller.rb +35 -4
- data/app/controllers/iro/purses_controller.rb +11 -4
- data/app/controllers/iro/strategies_controller.rb +7 -7
- data/app/helpers/iro/application_helper.rb +5 -2
- data/app/jobs/tda_job.rb +14 -0
- data/app/models/iro/datapoint.rb +48 -8
- data/app/models/iro/position.rb +55 -14
- data/app/models/iro/price_item.rb +51 -1
- data/app/models/iro/purse.rb +4 -0
- data/app/models/iro/stock.rb +5 -2
- data/app/models/iro/strategy.rb +84 -10
- data/app/models/iro/trash/position_covered_call.rb +4 -0
- data/app/models/iro/trash/position_debit_spread.rb +251 -0
- data/app/models/tda/option.rb +7 -7
- data/app/views/iro/_main_header.haml +18 -17
- data/app/views/iro/api/stocks/show.jbuilder +11 -0
- data/app/views/iro/positions/_form.haml +11 -38
- data/app/views/iro/positions/_formpart_4data.haml +46 -0
- data/app/views/iro/positions/_gameui_covered_call.haml +44 -0
- data/app/views/iro/positions/_gameui_covered_call.haml-bk +59 -0
- data/app/views/iro/positions/_gameui_long_debit_call_spread.haml +37 -0
- data/app/views/iro/positions/_gameui_short_debit_put_spread.haml +39 -0
- data/app/views/iro/positions/_header.haml +6 -0
- data/app/views/iro/positions/_header_covered_call.haml +6 -0
- data/app/views/iro/positions/_header_long_debit_call_spread.haml +14 -0
- data/app/views/iro/positions/_header_short_debit_put_spread.haml +1 -0
- data/app/views/iro/positions/_table.haml +120 -123
- data/app/views/iro/positions/roll.haml +83 -0
- data/app/views/iro/positions/trash/_header_short_debit_put_spread.haml +9 -0
- data/app/views/iro/purses/_form.haml +1 -0
- data/app/views/iro/purses/_form_extra_fields.haml +14 -0
- data/app/views/iro/purses/_header.haml +22 -0
- data/app/views/iro/purses/gameui.haml +19 -0
- data/app/views/iro/purses/gameui.haml-bk +44 -0
- data/app/views/iro/purses/gameui.haml-bk2 +89 -0
- data/app/views/iro/purses/show.haml +1 -7
- data/app/views/iro/stocks/_grid_is_long.haml +16 -0
- data/app/views/iro/stocks/_grid_is_short.haml +16 -0
- data/app/views/iro/strategies/_form.haml +12 -5
- data/app/views/iro/strategies/_show.haml +3 -2
- data/app/views/iro/strategies/_table.haml +16 -10
- data/app/views/iro/strategies/index.haml +8 -0
- data/app/views/layouts/iro/application.haml +1 -1
- data/config/routes.rb +15 -1
- data/lib/iro/engine.rb +2 -0
- data/lib/tasks/db_tasks.rake +9 -3
- metadata +31 -8
- data/app/assets/stylesheets/iron_warbler/alerts.css +0 -8
- data/app/assets/stylesheets/iron_warbler/datapoints.css +0 -0
- data/app/assets/stylesheets/iron_warbler/profiles.css +0 -4
- data/app/assets/stylesheets/iron_warbler/strategies.scss +0 -0
- data/app/assets/stylesheets/iron_warbler/utils.css +0 -44
- data/app/jobs/iro/application_job.rb-trash +0 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fabfbb9bdc5c7cceac9b4cf0e3fdb5513c89f199502f5731b2f4d423e96a90d0
|
4
|
+
data.tar.gz: b182eba8faab8d64b7c75826ab2b5c7328e6fa4123201f334238e9d981293992
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c33a21b2c7c4587088b9eccf288075ccb1bcd6ec3bb62e87deeed5b9f28ba1fa1f875e37bda0e875ae8d74af9907c1dd2232bbad7bd45b70cc7ca96106d98f6c
|
7
|
+
data.tar.gz: 6e38e2f1815f67c5afa4936c3604cc668b79a15c1f7541f1ff5196344e8fd022acb1457ecf7524935e726186202c7162b9626dded867bfe48b75a2dae038fe9a
|
@@ -12,8 +12,18 @@
|
|
12
12
|
*
|
13
13
|
*= require_tree .
|
14
14
|
*= require_self
|
15
|
-
|
15
|
+
**/
|
16
16
|
|
17
|
-
|
18
|
-
|
17
|
+
html {
|
18
|
+
--iro-color-long: lightseagreen;
|
19
|
+
--iro-color-short: orange;
|
20
|
+
|
21
|
+
--iro-color-grid1: #ccc;
|
22
|
+
--iro-color-grid2: #999;
|
23
|
+
--iro-color-bg1: #efefef;
|
24
|
+
--iro-color-bg2: #fefefe;
|
19
25
|
}
|
26
|
+
|
27
|
+
/* body {
|
28
|
+
color: red !important;
|
29
|
+
} */
|
@@ -1,4 +1,9 @@
|
|
1
1
|
|
2
|
+
.positions--header {
|
3
|
+
position: relative;
|
4
|
+
z-index: 1;
|
5
|
+
}
|
6
|
+
|
2
7
|
.positions--table {
|
3
8
|
|
4
9
|
table {
|
@@ -15,17 +20,12 @@
|
|
15
20
|
border: 1px solid red;
|
16
21
|
|
17
22
|
> * {
|
18
|
-
border: 1px solid yellow;
|
19
|
-
// background: #ddd;
|
20
|
-
|
21
23
|
transform-origin: 0 0;
|
22
24
|
rotate: -40deg;
|
23
25
|
|
24
26
|
padding: .4em 0;
|
25
27
|
width: 120px;
|
26
|
-
|
27
28
|
}
|
28
|
-
|
29
29
|
}
|
30
30
|
|
31
31
|
th.begin_price {
|
@@ -43,5 +43,24 @@
|
|
43
43
|
th.next_symbol {
|
44
44
|
width: 120px;
|
45
45
|
}
|
46
|
+
|
47
|
+
tr.is_long {
|
48
|
+
border-left: 5px solid var(--iro-color-long);
|
49
|
+
}
|
50
|
+
tr.is_short {
|
51
|
+
border-left: 5px solid var(--iro-color-short);
|
52
|
+
}
|
53
|
+
|
54
|
+
tr.covered_call {
|
55
|
+
.begin-outer-price,
|
56
|
+
.end-outer-price,
|
57
|
+
.max-gainp,
|
58
|
+
.max-loss,
|
59
|
+
.outer-strike,
|
60
|
+
._ {
|
61
|
+
display: none;
|
62
|
+
}
|
63
|
+
}
|
64
|
+
|
46
65
|
}
|
47
66
|
}
|
@@ -0,0 +1,214 @@
|
|
1
|
+
|
2
|
+
.purses-gameuiW {
|
3
|
+
border: 1px solid red;
|
4
|
+
width: 100%;
|
5
|
+
overflow: scroll;
|
6
|
+
}
|
7
|
+
|
8
|
+
.purses-gameui {
|
9
|
+
|
10
|
+
.Origin::before {
|
11
|
+
position: absolute;
|
12
|
+
top: -1em;
|
13
|
+
content: "";
|
14
|
+
margin-left: -1em;
|
15
|
+
border: 1em solid transparent;
|
16
|
+
border-top: 1em solid black;
|
17
|
+
}
|
18
|
+
.Origin {
|
19
|
+
position: absolute;
|
20
|
+
top: 0;
|
21
|
+
// background: rgba(255,255,0, 0.5);
|
22
|
+
height: 100%;
|
23
|
+
width: 100%;
|
24
|
+
|
25
|
+
> .label {
|
26
|
+
width: 300px;
|
27
|
+
|
28
|
+
position: absolute;
|
29
|
+
top: -1.5em;
|
30
|
+
left: 1.2em;
|
31
|
+
z-index: 2;
|
32
|
+
}
|
33
|
+
}
|
34
|
+
.PositionW {
|
35
|
+
top: 0;
|
36
|
+
border: 2px solid black;
|
37
|
+
background: rgba(0,255,255, 0.25);
|
38
|
+
position: absolute;
|
39
|
+
height: 100%;
|
40
|
+
}
|
41
|
+
.reviewing {
|
42
|
+
.PositionW {
|
43
|
+
border-radius: 10px 10px 0 0;
|
44
|
+
height: 90%;
|
45
|
+
}
|
46
|
+
}
|
47
|
+
|
48
|
+
.Position {
|
49
|
+
position: absolute;
|
50
|
+
background: rgba(0,255,255, 0.25);
|
51
|
+
width: 100%;
|
52
|
+
height: 90%;
|
53
|
+
|
54
|
+
left: 0;
|
55
|
+
top: 0;
|
56
|
+
}
|
57
|
+
/* only for covered calls */
|
58
|
+
.PositionC {
|
59
|
+
background: rgba(255,153,51, 0.5);
|
60
|
+
position: absolute;
|
61
|
+
|
62
|
+
/* HEREHERE: either left, or right 0, this orange strip flips. */
|
63
|
+
// left: 0;
|
64
|
+
right: 0;
|
65
|
+
|
66
|
+
width: 10000px;
|
67
|
+
height: 100%;
|
68
|
+
}
|
69
|
+
|
70
|
+
.MaxGain,
|
71
|
+
.Breakeven {
|
72
|
+
position: absolute;
|
73
|
+
right: 0;
|
74
|
+
bottom: -10%;
|
75
|
+
border: 2px solid green;
|
76
|
+
background: rgba(0,255,0, 0.5);
|
77
|
+
height: 10%;
|
78
|
+
}
|
79
|
+
|
80
|
+
.sprite {
|
81
|
+
position: absolute;
|
82
|
+
}
|
83
|
+
.sprite-bottom {
|
84
|
+
bottom: 0;
|
85
|
+
}
|
86
|
+
|
87
|
+
.StockCoordinatesW {
|
88
|
+
// width: 500px;
|
89
|
+
|
90
|
+
// background: var(--iro-color-bg2);
|
91
|
+
// border: 1px solid red;
|
92
|
+
margin-bottom: 2em;
|
93
|
+
|
94
|
+
position: relative;
|
95
|
+
|
96
|
+
z-index: 1;
|
97
|
+
}
|
98
|
+
.StockCoordinates {
|
99
|
+
border-left: 1px solid var(--iro-color-grid1);
|
100
|
+
border-bottom: 1px solid var(--iro-color-grid1);
|
101
|
+
|
102
|
+
margin-left: 50%;
|
103
|
+
margin-bottom: 0em;
|
104
|
+
|
105
|
+
position: relative;
|
106
|
+
|
107
|
+
.Last {
|
108
|
+
border-left: 2px dotted red;
|
109
|
+
}
|
110
|
+
.label {
|
111
|
+
width: 200px;
|
112
|
+
color: gray;
|
113
|
+
// border: 1px solid cyan;
|
114
|
+
}
|
115
|
+
|
116
|
+
.marker {
|
117
|
+
position: absolute;
|
118
|
+
height: 100%;
|
119
|
+
}
|
120
|
+
|
121
|
+
.Net {
|
122
|
+
position: absolute;
|
123
|
+
// bottom: 3em;
|
124
|
+
// z-index: 3;
|
125
|
+
height: 90%;
|
126
|
+
|
127
|
+
// border-bottom: 5px solid red;
|
128
|
+
.label {
|
129
|
+
color: white;
|
130
|
+
text-shadow: 1px 1px black;
|
131
|
+
}
|
132
|
+
}
|
133
|
+
.NetPositive {
|
134
|
+
border: 2px dashed #339966;
|
135
|
+
background: rgba(32,64,96, 0.5);
|
136
|
+
}
|
137
|
+
.NetNegative {
|
138
|
+
background: rgba(255,0,0, 0.75);
|
139
|
+
}
|
140
|
+
|
141
|
+
|
142
|
+
// .grid-mark:nth-child(4n + 1) {
|
143
|
+
// border: 1px solid red;
|
144
|
+
// display: none;
|
145
|
+
// }
|
146
|
+
// .grid-mark:nth-child(4n) {
|
147
|
+
// border: 1px solid red;
|
148
|
+
// display: none;
|
149
|
+
// }
|
150
|
+
// .grid-mark:nth-child(6n + 1) {
|
151
|
+
// border: 1px solid red;
|
152
|
+
// display: none;
|
153
|
+
// }
|
154
|
+
// .grid-mark:nth-child(6n) {
|
155
|
+
// border: 1px solid red;
|
156
|
+
// display: none;
|
157
|
+
// }
|
158
|
+
// .grid-mark:nth-child(3n + 1) {
|
159
|
+
// border: 1px solid red;
|
160
|
+
// display: none;
|
161
|
+
// }
|
162
|
+
// .grid-mark:nth-child(3n) {
|
163
|
+
// border: 1px solid red;
|
164
|
+
// display: none;
|
165
|
+
// }
|
166
|
+
|
167
|
+
.grid-mark {
|
168
|
+
// border: 1px solid red;
|
169
|
+
|
170
|
+
height: 100%;
|
171
|
+
position: absolute;
|
172
|
+
top: 0;
|
173
|
+
width: 100px;
|
174
|
+
z-index: -2;
|
175
|
+
border-left: 1px dashed var(--iro-color-grid1);
|
176
|
+
|
177
|
+
.label::before {
|
178
|
+
content: "";
|
179
|
+
position: absolute;
|
180
|
+
left: -1em;
|
181
|
+
width: 1em;
|
182
|
+
height: 1em;
|
183
|
+
border: 1em solid transparent;
|
184
|
+
border-left-color: white;
|
185
|
+
}
|
186
|
+
.label {
|
187
|
+
|
188
|
+
// border: 1px solid red;
|
189
|
+
|
190
|
+
transform: rotate(-45deg);
|
191
|
+
transform-origin: center left;
|
192
|
+
|
193
|
+
font-size: 0.8em;
|
194
|
+
|
195
|
+
position: absolute;
|
196
|
+
height: 1em;
|
197
|
+
line-height: 1em;
|
198
|
+
bottom: -0em;
|
199
|
+
z-index: -2;
|
200
|
+
width: 0;
|
201
|
+
|
202
|
+
.labelC {
|
203
|
+
background: white;
|
204
|
+
position: absolute;
|
205
|
+
top: 1.5em;
|
206
|
+
left: -1.5em;
|
207
|
+
}
|
208
|
+
}
|
209
|
+
}
|
210
|
+
|
211
|
+
|
212
|
+
}
|
213
|
+
|
214
|
+
}
|
@@ -0,0 +1,112 @@
|
|
1
|
+
|
2
|
+
.purses-gameui {
|
3
|
+
|
4
|
+
|
5
|
+
.Origin::before {
|
6
|
+
content: "";
|
7
|
+
margin-left: -1em;
|
8
|
+
border: 1em solid transparent;
|
9
|
+
border-top: 1em solid black;
|
10
|
+
}
|
11
|
+
.Origin {
|
12
|
+
position: absolute;
|
13
|
+
top: 0;
|
14
|
+
left: calc( 50% );
|
15
|
+
// z-index: -2;
|
16
|
+
}
|
17
|
+
.sprite {
|
18
|
+
position: absolute;
|
19
|
+
}
|
20
|
+
.sprite-bottom {
|
21
|
+
bottom: 0;
|
22
|
+
}
|
23
|
+
|
24
|
+
.CoordinatesW {
|
25
|
+
// width: 500px;
|
26
|
+
|
27
|
+
background: var(--iro-color-bg2);
|
28
|
+
border: 1px solid red;
|
29
|
+
margin-bottom: 3em;
|
30
|
+
|
31
|
+
position: relative;
|
32
|
+
|
33
|
+
z-index: 1;
|
34
|
+
}
|
35
|
+
.Coordinates {
|
36
|
+
border-left: 1px solid var(--iro-color-grid1);
|
37
|
+
border-bottom: 1px solid var(--iro-color-grid1);
|
38
|
+
|
39
|
+
background: yellow;
|
40
|
+
|
41
|
+
height: 100px;
|
42
|
+
|
43
|
+
margin-left: 50%;
|
44
|
+
|
45
|
+
position: relative;
|
46
|
+
|
47
|
+
.Breakeven {
|
48
|
+
// background: cyan;
|
49
|
+
border-right: 2px solid lightblue;
|
50
|
+
|
51
|
+
.half-circle {
|
52
|
+
width: 100%;
|
53
|
+
height: 100%; /* as the half of the width */
|
54
|
+
background-color: lightblue;
|
55
|
+
border-top-left-radius: 100%; /* 100px of height + 10px of border */
|
56
|
+
border-top-right-radius: 100%; /* 100px of height + 10px of border */
|
57
|
+
// border: 10px solid gray;
|
58
|
+
// border-bottom: 0;
|
59
|
+
}
|
60
|
+
}
|
61
|
+
|
62
|
+
.Last {
|
63
|
+
border-left: 2px dotted red;
|
64
|
+
}
|
65
|
+
.label {
|
66
|
+
width: 200px;
|
67
|
+
color: gray;
|
68
|
+
}
|
69
|
+
|
70
|
+
.marker {
|
71
|
+
position: absolute;
|
72
|
+
height: 100%;
|
73
|
+
}
|
74
|
+
|
75
|
+
.Net {
|
76
|
+
|
77
|
+
position: absolute;
|
78
|
+
bottom: 3em;
|
79
|
+
z-index: 3;
|
80
|
+
|
81
|
+
background: #339966;
|
82
|
+
// border-bottom: 5px solid red;
|
83
|
+
.label {
|
84
|
+
color: white;
|
85
|
+
}
|
86
|
+
}
|
87
|
+
|
88
|
+
.grid-mark {
|
89
|
+
height: 100%;
|
90
|
+
position: absolute;
|
91
|
+
top: 0;
|
92
|
+
width: 100px;
|
93
|
+
z-index: 1;
|
94
|
+
border-left: 1px dashed var(--iro-color-grid1);
|
95
|
+
|
96
|
+
.label {
|
97
|
+
position: absolute;
|
98
|
+
bottom: -1em;
|
99
|
+
z-index: 0;
|
100
|
+
}
|
101
|
+
}
|
102
|
+
.mark0 {
|
103
|
+
.label {
|
104
|
+
bottom: -2em;
|
105
|
+
}
|
106
|
+
}
|
107
|
+
|
108
|
+
|
109
|
+
|
110
|
+
}
|
111
|
+
|
112
|
+
}
|
@@ -0,0 +1,81 @@
|
|
1
|
+
|
2
|
+
|
3
|
+
|
4
|
+
// .long-or-short::before {
|
5
|
+
// // content: '[LONG]';
|
6
|
+
// }
|
7
|
+
.long-or-short-item,
|
8
|
+
.long-or-short-container .is_long,
|
9
|
+
.long-or-short-container .is_short {
|
10
|
+
display: flex;
|
11
|
+
flex-direction: column;
|
12
|
+
}
|
13
|
+
|
14
|
+
.long-or-short-container .is_long,
|
15
|
+
.is_long .long-or-short-item {
|
16
|
+
border-left: 3px solid var(--iro-color-long);
|
17
|
+
padding-left: 5px;
|
18
|
+
}
|
19
|
+
.long-or-short-container .is_short,
|
20
|
+
.is_short .long-or-short-item {
|
21
|
+
border-left: 3px solid var(--iro-color-short);
|
22
|
+
padding-left: 5px;
|
23
|
+
}
|
24
|
+
|
25
|
+
.is_short .long-or-short-item::before {
|
26
|
+
// content: '[SHORT]';
|
27
|
+
}
|
28
|
+
.is_short .long-or-short-item,
|
29
|
+
.long-or-short-container .is_short {
|
30
|
+
flex-direction: column-reverse;
|
31
|
+
}
|
32
|
+
|
33
|
+
/* F */
|
34
|
+
|
35
|
+
.flex-row {
|
36
|
+
display: flex;
|
37
|
+
margin-bottom: 0.4em;
|
38
|
+
}
|
39
|
+
|
40
|
+
.floaty-collapse {
|
41
|
+
float: left;
|
42
|
+
z-index: 5;
|
43
|
+
position: relative;
|
44
|
+
background: white;
|
45
|
+
}
|
46
|
+
.field {
|
47
|
+
min-width: 100px;
|
48
|
+
margin-right: 1em;
|
49
|
+
}
|
50
|
+
|
51
|
+
/* H */
|
52
|
+
|
53
|
+
/* M */
|
54
|
+
|
55
|
+
.modal-absolute {
|
56
|
+
border: 1px solid green;
|
57
|
+
border-radius: 5px;
|
58
|
+
box-shadow: 2px 2px;
|
59
|
+
|
60
|
+
padding: 0.5em;
|
61
|
+
|
62
|
+
position: absolute;
|
63
|
+
|
64
|
+
min-width: 200px;
|
65
|
+
width: 400px;
|
66
|
+
|
67
|
+
min-height: 200px;
|
68
|
+
height: 300px;
|
69
|
+
/* overflow: auto; */
|
70
|
+
|
71
|
+
background: white;
|
72
|
+
|
73
|
+
z-index: 2;
|
74
|
+
|
75
|
+
}
|
76
|
+
|
77
|
+
|
78
|
+
|
79
|
+
/* W */
|
80
|
+
|
81
|
+
|
@@ -0,0 +1,87 @@
|
|
1
|
+
|
2
|
+
class Iro::Api::StocksController < Iro::ApiController
|
3
|
+
before_action :set_stock, only: [:show, :edit, :update, :destroy]
|
4
|
+
|
5
|
+
def index
|
6
|
+
authorize! :index, Iro::Stock
|
7
|
+
|
8
|
+
respond_to do |format|
|
9
|
+
format.json do
|
10
|
+
render
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
def show
|
16
|
+
authorize! :show, @stock
|
17
|
+
end_on = Time.now.to_date.in_time_zone('UTC')
|
18
|
+
|
19
|
+
begin_on = params[:begin_on].to_date.in_time_zone('UTC') if params[:begin_on]
|
20
|
+
end_on = params[:end_on].to_date.in_time_zone('UTC') if params[:end_on]
|
21
|
+
|
22
|
+
case params[:period]
|
23
|
+
when '1-mo'
|
24
|
+
begin_on = ( Time.now - 30.days ).to_date.in_time_zone('UTC')
|
25
|
+
# end_on = Time.now.to_date.in_time_zone('UTC')
|
26
|
+
when '3-mo'
|
27
|
+
begin_on = ( Time.now - 90.days ).to_date.in_time_zone('UTC')
|
28
|
+
# end_on = Time.now.to_date.in_time_zone('UTC')
|
29
|
+
when '1-yr'
|
30
|
+
begin_on = ( Time.now - 1.year ).to_date.in_time_zone('UTC')
|
31
|
+
# end_on = Time.now.to_date.in_time_zone('UTC')
|
32
|
+
end
|
33
|
+
|
34
|
+
@datapoints = Iro::Datapoint.where({
|
35
|
+
:quote_at.gte => begin_on,
|
36
|
+
:quote_at.lte => end_on,
|
37
|
+
symbol: params[:ticker],
|
38
|
+
}).order_by({ quote_at: :asc })
|
39
|
+
end
|
40
|
+
|
41
|
+
def new
|
42
|
+
@stock = Iro::Stock.new
|
43
|
+
authorize! :new, @stock
|
44
|
+
end
|
45
|
+
|
46
|
+
def edit
|
47
|
+
end
|
48
|
+
|
49
|
+
def create
|
50
|
+
@stock = Iro::Stock.new(stock_params)
|
51
|
+
authorize! :create, @stock
|
52
|
+
|
53
|
+
if @stock.save
|
54
|
+
flash_notice @stock
|
55
|
+
else
|
56
|
+
flash_alert @stock
|
57
|
+
end
|
58
|
+
redirect_to action: :index
|
59
|
+
end
|
60
|
+
|
61
|
+
def update
|
62
|
+
@stock = Iro::Stock.find params[:id]
|
63
|
+
authorize! :update, @stock
|
64
|
+
if @stock.update(stock_params)
|
65
|
+
flash_notice @stock
|
66
|
+
else
|
67
|
+
flash_alert @stock
|
68
|
+
end
|
69
|
+
redirect_to request.referrer
|
70
|
+
end
|
71
|
+
|
72
|
+
def destroy
|
73
|
+
@stock.destroy
|
74
|
+
redirect_to stocks_url, notice: 'Stock was successfully destroyed.'
|
75
|
+
end
|
76
|
+
|
77
|
+
##
|
78
|
+
## private
|
79
|
+
##
|
80
|
+
private
|
81
|
+
|
82
|
+
def set_stock
|
83
|
+
@stock = Iro::Stock.find_by({ ticker: params[:ticker] })
|
84
|
+
end
|
85
|
+
|
86
|
+
end
|
87
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
|
2
|
+
class Iro::ApiController < ActionController::Base
|
3
|
+
layout false
|
4
|
+
|
5
|
+
before_action :decode_jwt
|
6
|
+
|
7
|
+
##
|
8
|
+
## private
|
9
|
+
##
|
10
|
+
private
|
11
|
+
|
12
|
+
def decode_jwt
|
13
|
+
out = JWT.decode params[:jwt_token], nil, false
|
14
|
+
email = out[0]['email']
|
15
|
+
user = User.find_by({ email: email })
|
16
|
+
sign_in user
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -1,6 +1,5 @@
|
|
1
1
|
|
2
2
|
class Iro::PositionsController < Iro::ApplicationController
|
3
|
-
|
4
3
|
before_action :set_lists
|
5
4
|
|
6
5
|
def new
|
@@ -32,8 +31,40 @@ class Iro::PositionsController < Iro::ApplicationController
|
|
32
31
|
def edit
|
33
32
|
@position = Iro::Position.find params[:id]
|
34
33
|
authorize! :edit, @position
|
34
|
+
end
|
35
|
+
|
36
|
+
def refresh
|
37
|
+
@position = pos = Iro::Position.find params[:id]
|
38
|
+
authorize! :refresh, @position
|
39
|
+
|
40
|
+
## covered call
|
41
|
+
out = Tda::Option.get_quote({
|
42
|
+
contractType: 'CALL',
|
43
|
+
strike: pos.inner_strike,
|
44
|
+
expirationDate: pos.expires_on,
|
45
|
+
ticker: pos.stock.ticker,
|
46
|
+
})
|
47
|
+
puts! out, 'out'
|
48
|
+
@position.update({
|
49
|
+
end_inner_price: ( out.bid + out.ask ) / 2,
|
50
|
+
end_inner_delta: out.delta,
|
51
|
+
})
|
52
|
+
redirect_to request.referrer || purse_path( @position.purse )
|
53
|
+
end
|
54
|
+
|
55
|
+
def roll
|
56
|
+
@position = Iro::Position.find params[:id]
|
57
|
+
authorize! :roll, @position
|
58
|
+
|
59
|
+
stock = @position.stock
|
35
60
|
|
36
|
-
@
|
61
|
+
@positions = [
|
62
|
+
Iro::Position.new({ stock: stock, begin_inner_price: 5.21, inner_strike: 91, expires_on: '2024-04-05', gain_loss_amount: -1.25 }),
|
63
|
+
Iro::Position.new({ stock: stock, begin_inner_price: 5.77, inner_strike: 90, expires_on: '2024-04-05', gain_loss_amount: -0.7 }),
|
64
|
+
Iro::Position.new({ stock: stock, begin_inner_price: 6.4, inner_strike: 89, expires_on: '2024-04-05', gain_loss_amount: -0.03 }),
|
65
|
+
Iro::Position.new({ stock: stock, begin_inner_price: 6.85, inner_strike: 88, expires_on: '2024-04-05', gain_loss_amount: 0.6 }),
|
66
|
+
Iro::Position.new({ stock: stock, begin_inner_price: 7.07, inner_strike: 87, expires_on: '2024-04-05', gain_loss_amount: 1.22 }),
|
67
|
+
]
|
37
68
|
end
|
38
69
|
|
39
70
|
def update
|
@@ -55,8 +86,8 @@ class Iro::PositionsController < Iro::ApplicationController
|
|
55
86
|
private
|
56
87
|
|
57
88
|
def set_lists
|
58
|
-
@strategies_list = Iro::Strategy.list
|
59
|
-
@
|
89
|
+
@strategies_list = Iro::Strategy.list(params[:long_or_short])
|
90
|
+
@stocks_list = Iro::Stock.list
|
60
91
|
end
|
61
92
|
|
62
93
|
end
|
@@ -23,8 +23,6 @@ class Iro::PursesController < Iro::ApplicationController
|
|
23
23
|
def edit
|
24
24
|
@purse = Iro::Purse.find(params[:id])
|
25
25
|
authorize! :edit, @purse
|
26
|
-
|
27
|
-
|
28
26
|
end
|
29
27
|
|
30
28
|
def index
|
@@ -36,15 +34,24 @@ class Iro::PursesController < Iro::ApplicationController
|
|
36
34
|
@purse = Iro::Purse.find(params[:id])
|
37
35
|
authorize! :show, @purse
|
38
36
|
|
39
|
-
@positions =
|
37
|
+
@positions = @purse.positions.includes( :strategy
|
38
|
+
).order({ expires_on: :desc })
|
39
|
+
|
40
|
+
@unit = @purse.unit # 12 ## pixels per dollar
|
41
|
+
@height = @purse.height # 100 ## pixels
|
42
|
+
@n_dollars = 100 ## dollars to each side of origin
|
43
|
+
|
44
|
+
render params[:template]
|
40
45
|
end
|
41
46
|
|
42
47
|
def update
|
43
48
|
@purse = Iro::Purse.find(params[:id])
|
44
49
|
authorize! :update, @purse
|
45
50
|
if @purse.update params[:purse].permit!
|
46
|
-
|
51
|
+
flash[:notice] = 'ok'
|
52
|
+
redirect_to purse_path(@purse)
|
47
53
|
else
|
54
|
+
flash_alert @purse
|
48
55
|
render :edit
|
49
56
|
end
|
50
57
|
end
|