wco_models 3.1.0.269 → 3.1.0.270
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/models/iro/position.rb +25 -14
- data/app/models/tda/order.rb +4 -4
- metadata +2 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 021150c40e30bb02fb18567bf718130b52075e9fa8bcb999e231f95c80413ed9
|
|
4
|
+
data.tar.gz: 52f7e91b77c3ead85ced22ccd64f4267cfc96d3fddf59671fa115ce413c13267
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dbfe2e00671a9ca7dc6c232186993e45f00c7afd6e74f4f2140d0902c19e29c5e709462dfef1d41112a2f9652e04c6b367fc5b878ce32ffc8d07d11245aafc07
|
|
7
|
+
data.tar.gz: 2160353727634f5e7df835689ab93192d6e95dc42f37d600ef346a840d1221d5812c9c790d0e480dbf0312dfd8c6d3bb83b033bf66ca1877143eb3b3b4b59b50
|
data/app/models/iro/position.rb
CHANGED
|
@@ -142,7 +142,7 @@ class Iro::Position
|
|
|
142
142
|
end
|
|
143
143
|
|
|
144
144
|
|
|
145
|
-
field :pending_price
|
|
145
|
+
field :pending_price, type: :float
|
|
146
146
|
|
|
147
147
|
## credit spread only
|
|
148
148
|
def close_price
|
|
@@ -151,8 +151,8 @@ class Iro::Position
|
|
|
151
151
|
return out.round(2)
|
|
152
152
|
end
|
|
153
153
|
|
|
154
|
-
##
|
|
155
|
-
def
|
|
154
|
+
## credit-spread
|
|
155
|
+
def open_price
|
|
156
156
|
pos = self
|
|
157
157
|
out = pos.inner.begin_price - pos.outer.begin_price
|
|
158
158
|
return out.round(2)
|
|
@@ -208,6 +208,19 @@ class Iro::Position
|
|
|
208
208
|
outer.sync
|
|
209
209
|
end
|
|
210
210
|
|
|
211
|
+
def schwab_query
|
|
212
|
+
pos = self
|
|
213
|
+
case pos.intent
|
|
214
|
+
when Iro::Strategy::INTENT_OPEN
|
|
215
|
+
the_q = Tda::Order.credit_spread_q pos
|
|
216
|
+
when Iro::Strategy::INTENT_ROLL
|
|
217
|
+
the_q = Tda::Order.roll_credit_call_spread_q pos
|
|
218
|
+
else
|
|
219
|
+
throw "prp - #schwab_query undefined for position #{pos.inspect}"
|
|
220
|
+
end
|
|
221
|
+
return the_q
|
|
222
|
+
end
|
|
223
|
+
|
|
211
224
|
def self.sync_all
|
|
212
225
|
@positions = Iro::Position.where( :status.in => [ 'active', 'pending' ] )
|
|
213
226
|
expiration_dates = @positions.map { |p| p.expires_on.to_s }.sort
|
|
@@ -274,6 +287,11 @@ class Iro::Position
|
|
|
274
287
|
# puts! outs, 'outs'
|
|
275
288
|
outs_bk = outs.dup
|
|
276
289
|
|
|
290
|
+
## cleanup mid-increments
|
|
291
|
+
outs = outs.select do |out|
|
|
292
|
+
( out[:strikePrice] - pos.inner.strike ) % strategy.stock.options_price_increment == 0
|
|
293
|
+
end
|
|
294
|
+
|
|
277
295
|
outs = outs.select do |out|
|
|
278
296
|
out[:bidSize] + out[:askSize] > 0
|
|
279
297
|
end
|
|
@@ -319,15 +337,8 @@ class Iro::Position
|
|
|
319
337
|
|
|
320
338
|
## next_inner_delta
|
|
321
339
|
outs = outs.select do |out|
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
out_delta <= strategy.next_inner_delta
|
|
325
|
-
elsif 'PUT' == pos.put_call
|
|
326
|
-
out_delta = out[:delta] rescue 0
|
|
327
|
-
out_delta <= strategy.next_inner_delta
|
|
328
|
-
else
|
|
329
|
-
raise 'zt5 - this cannot happen'
|
|
330
|
-
end
|
|
340
|
+
out_delta = out[:delta].abs rescue 0
|
|
341
|
+
out_delta <= strategy.next_inner_delta
|
|
331
342
|
end
|
|
332
343
|
# puts! outs[0][:strikePrice], 'after calc next_inner_delta'
|
|
333
344
|
# puts! outs, 'outs'
|
|
@@ -424,13 +435,13 @@ class Iro::Position
|
|
|
424
435
|
out = "#{stock} (#{q}) #{expires_on.to_datetime.strftime('%b %d')} #{strategy.long_or_short} ["
|
|
425
436
|
if Iro::Strategy::LONG == long_or_short
|
|
426
437
|
if outer&.strike
|
|
427
|
-
out = out + "$#{outer.strike}
|
|
438
|
+
out = out + "$#{outer.strike} << "
|
|
428
439
|
end
|
|
429
440
|
out = out + "$#{inner.strike}"
|
|
430
441
|
else
|
|
431
442
|
out = out + "$#{inner.strike}"
|
|
432
443
|
if outer&.strike
|
|
433
|
-
out = out + "
|
|
444
|
+
out = out + " >> $#{outer.strike}"
|
|
434
445
|
end
|
|
435
446
|
end
|
|
436
447
|
out += "] "
|
data/app/models/tda/order.rb
CHANGED
|
@@ -98,10 +98,10 @@ class Tda::Order
|
|
|
98
98
|
return query
|
|
99
99
|
end
|
|
100
100
|
|
|
101
|
-
## open credit spread
|
|
101
|
+
## open credit spread
|
|
102
102
|
def self.credit_spread_q pos
|
|
103
103
|
query = {
|
|
104
|
-
orderType: pos.
|
|
104
|
+
orderType: pos.pending_price > 0 ? "NET_CREDIT" : "NET_DEBIT",
|
|
105
105
|
session: "NORMAL",
|
|
106
106
|
duration: "DAY",
|
|
107
107
|
price: pos.pending_price,
|
|
@@ -190,10 +190,10 @@ class Tda::Order
|
|
|
190
190
|
|
|
191
191
|
def self.roll_credit_call_spread_q pos
|
|
192
192
|
query = {
|
|
193
|
-
orderType: pos.
|
|
193
|
+
orderType: pos.pending_price > 0 ? "NET_CREDIT" : "NET_DEBIT",
|
|
194
194
|
session: "NORMAL",
|
|
195
195
|
duration: "DAY",
|
|
196
|
-
price: pos.
|
|
196
|
+
price: pos.pending_price.abs.to_s,
|
|
197
197
|
orderStrategyType: "SINGLE",
|
|
198
198
|
orderLegCollection: [
|
|
199
199
|
## close
|
metadata
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: wco_models
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 3.1.0.
|
|
4
|
+
version: 3.1.0.270
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Victor Pudeyev
|
|
8
8
|
autorequire:
|
|
9
9
|
bindir: bin
|
|
10
10
|
cert_chain: []
|
|
11
|
-
date: 2026-04-
|
|
11
|
+
date: 2026-04-10 00:00:00.000000000 Z
|
|
12
12
|
dependencies:
|
|
13
13
|
- !ruby/object:Gem::Dependency
|
|
14
14
|
name: ahoy_matey
|