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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 91f4c3c5f908983786abe2b1fbc402d18fcad4222323fbccbf662175c3603ea4
4
- data.tar.gz: 6cc8d4b4cf40fff0c84a4e1c6b76202551a2a5e22ccc4f7e8e1f96596701be2e
3
+ metadata.gz: 021150c40e30bb02fb18567bf718130b52075e9fa8bcb999e231f95c80413ed9
4
+ data.tar.gz: 52f7e91b77c3ead85ced22ccd64f4267cfc96d3fddf59671fa115ce413c13267
5
5
  SHA512:
6
- metadata.gz: 18b383d3a25ebb58fce4406279f1f1921b0a3932b763074f6183d6bcc417591fb8ec04d73083753e51c4954c453bf331a33f1e44116a429515d2ece4fb1b8ab2
7
- data.tar.gz: 3506848b877ff5bd81d41077406005e5483b36a7ea3f0984d3c2aeb187dc82022e1ac91e4e32af557487ca6331969a62a9b3d303dc7244e667ed50e151d4692c
6
+ metadata.gz: dbfe2e00671a9ca7dc6c232186993e45f00c7afd6e74f4f2140d0902c19e29c5e709462dfef1d41112a2f9652e04c6b367fc5b878ce32ffc8d07d11245aafc07
7
+ data.tar.gz: 2160353727634f5e7df835689ab93192d6e95dc42f37d600ef346a840d1221d5812c9c790d0e480dbf0312dfd8c6d3bb83b033bf66ca1877143eb3b3b4b59b50
@@ -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
- ## place2 = credit-spread
155
- def place2_price
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
- if 'CALL' == pos.put_call
323
- out_delta = out[:delta] rescue 1
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 + " -> $#{outer.strike}"
444
+ out = out + " >> $#{outer.strike}"
434
445
  end
435
446
  end
436
447
  out += "] "
@@ -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.place2_price > 0 ? "NET_CREDIT" : "NET_DEBIT",
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.roll_price > 0 ? "NET_CREDIT" : "NET_DEBIT",
193
+ orderType: pos.pending_price > 0 ? "NET_CREDIT" : "NET_DEBIT",
194
194
  session: "NORMAL",
195
195
  duration: "DAY",
196
- price: pos.roll_price.abs.to_s,
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.269
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-09 00:00:00.000000000 Z
11
+ date: 2026-04-10 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ahoy_matey