wco_models 3.5.0.6 → 3.5.0.9

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.
Files changed (45) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/stylesheets/wco/main.scss +7 -3
  3. data/app/assets/stylesheets/wco/photos.scss +2 -1
  4. data/app/controllers/wco/newsvideos_controller.rb +18 -16
  5. data/app/controllers/wco/office_action_templates_controller.rb +3 -0
  6. data/app/controllers/wco/publishers_controller.rb +6 -16
  7. data/app/controllers/wco/reports_controller.rb +6 -5
  8. data/app/controllers/wco/sitemap_paths_controller.rb +14 -2
  9. data/app/controllers/wco/sites_controller.rb +1 -1
  10. data/app/controllers/wco/tags_controller.rb +1 -1
  11. data/app/jobs/wco/newspartial_speech_job.rb +12 -0
  12. data/app/jobs/wco/{newsvideo_generate_job.rb → newsvideo_combine_job.rb} +2 -2
  13. data/app/models/iro/option.rb +37 -4
  14. data/app/models/iro/priceitem.rb +62 -4
  15. data/app/models/tda/option.rb +39 -41
  16. data/app/models/wco/newspartial.rb +16 -6
  17. data/app/models/wco/newsvideo.rb +1 -1
  18. data/app/models/wco/publisher.rb +29 -8
  19. data/app/models/wco/publisher_d10.rb +50 -0
  20. data/app/models/wco/report.rb +12 -2
  21. data/app/models/wco/site.rb +1 -67
  22. data/app/models/wco/sitemap_path.rb +19 -13
  23. data/app/models/wco/tag.rb +15 -8
  24. data/app/models/wco/utils.rb +1 -1
  25. data/app/views/wco/api/newsproducer/README.txt +4 -0
  26. data/app/views/wco/api/newsproducer/_studio_blue2.js-bk +606 -0
  27. data/app/views/wco/api/newsproducer/_studio_blue2.js-bk2 +898 -0
  28. data/app/views/wco/api/newsproducer/studio_blue2.html.erb-bk +151 -0
  29. data/app/views/wco/office_action_templates/index.haml +1 -1
  30. data/app/views/wco/office_actions/_actions.haml +1 -1
  31. data/app/views/wco/publishers/_form.haml +11 -2
  32. data/app/views/wco/publishers/_post_with.haml +1 -1
  33. data/app/views/wco/reports/_form.haml +13 -2
  34. data/app/views/wco/reports/_index.haml +18 -11
  35. data/app/views/wco/reports/show.haml +6 -1
  36. data/app/views/wco/sitemap_paths/_index.haml +1 -0
  37. data/app/views/wco/sitemap_paths/show.haml +14 -0
  38. data/app/views/wco/sites/index.haml +6 -0
  39. data/app/views/wco/sites/show.haml +1 -1
  40. data/app/views/wco/tags/_form.haml +3 -0
  41. data/config/routes.rb +3 -3
  42. data/lib/shortcuts.rb +1 -1
  43. data/lib/wco_models.rb +1 -1
  44. metadata +10 -4
  45. data/app/views/wco/sitemap_paths/check.haml +0 -13
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: aab7c60fdd1e0428ce334c2855120a51172b8a8f852b54457d6c7edda6626280
4
- data.tar.gz: c18bf1720e767f456bc8ccf3ec2a1ff29b6af86c5e4f6b7433b8abccd0cf486f
3
+ metadata.gz: fe726654a262c13acae39364cbe85f35ff9743896e31d230a15801f86dd399f6
4
+ data.tar.gz: d414e7b473e6adb849dd44b57dd0c50616911e84f20b8db3acfefd9aa9fa9e48
5
5
  SHA512:
6
- metadata.gz: b69fe8c0a4ed79f68b2eaabdc1877d6889f1bb123d0e279ba42d611eb20b999f74c1f0dc295bf303dd66b518df8fd2bb98ac8d940068a5f053d99a1ccffcd902
7
- data.tar.gz: 10f32400adc59c385d9f71999716322ff235257bfa877e082a79419feffdbb456f7b03ad87d548dfb7945a66f48bd7dc7b1ca5ab37e39ec83051c63c70179165
6
+ metadata.gz: 8f47d924b4f7b5c93372946ed12ce8f9a0a922fea09d6b94293202d68ddceace0649222882245f981c0dfb1f15ae15dbebd9df83e2f5391b36621f84fb4bad1e
7
+ data.tar.gz: 7c8503c5fbf140a3272d701b660e60582cac151781063e2479bdcf1c0c746b065d07a97263c899ecbaf35968ff867817433517f1a21788b7c534dfc6222fe027
@@ -117,7 +117,10 @@ textarea.monospace {
117
117
  /* D */
118
118
 
119
119
  .d-flex {
120
- align-items: baseline;
120
+ align-items: baseline; /* 2026-11-12: I dont want this alignment */
121
+ }
122
+ .no-align {
123
+ align-items: unset;
121
124
  }
122
125
 
123
126
  .descr {
@@ -343,11 +346,12 @@ table thead.sticky {
343
346
  .w-300px {
344
347
  width: 300px;
345
348
  }
346
-
347
349
  .w-400px {
348
350
  width: 400px;
349
351
  }
350
-
351
352
  .w-500px {
352
353
  width: 500px;
353
354
  }
355
+ .w-600px {
356
+ width: 500px;
357
+ }
@@ -10,10 +10,11 @@
10
10
 
11
11
  div.thumb {
12
12
  margin: 0 0.5em 0.5em 0;
13
+ flex-shrink: 0;
13
14
  }
14
15
 
15
16
  .photos-thumbs img,
16
- img.thumb {
17
+ .thumb {
17
18
  border: 1px solid red;
18
19
  width: 100px;
19
20
  height: 100px;
@@ -108,42 +108,44 @@ class Wco::NewsvideosController < Wco::ApplicationController
108
108
  authorize! :edit, @newsvideo
109
109
 
110
110
  Rails.env.production? ?
111
- Wco::NewsvideoGenerateJob.perform_async(@newsvideo.id.to_s) :
112
- Wco::NewsvideoGenerateJob.perform_sync( @newsvideo.id.to_s)
111
+ Wco::NewsvideoCombineJob.perform_async(@newsvideo.id.to_s) :
112
+ Wco::NewsvideoCombineJob.perform_sync( @newsvideo.id.to_s)
113
113
 
114
- render json: { status: :ok, message: 'Scheduled the generation' }
114
+ flash_notice 'Scheduled.'
115
+ redirect_to request.referrer || { action: 'show', id: @newsvideo.id }
115
116
  end
116
117
 
118
+
117
119
  def generate_all_audio
118
120
  @newsvideo = Wco::Newsvideo.unscoped.find params[:id]
119
121
  authorize! :edit, @newsvideo
120
122
 
121
- # cmd = "cd #{PUPPETEER_ROOT} ; yarn run newsvideo_generate_all_audio #{@newsvideo.id}"
122
- # puts "+++ puppeteer cmd:"
123
- # puts cmd
124
- # out = `#{cmd}`
125
- # puts! out, 'out'
126
-
127
123
  @newsvideo.newspartials.each do |newspartial|
128
- newspartial.generate_speech
129
- print '.'
124
+ Rails.env.production? ?
125
+ Wco::NewspartialSpeechJob.perform_async(newspartial.id.to_s) :
126
+ Wco::NewspartialSpeechJob.perform_sync( newspartial.id.to_s)
130
127
  end
131
128
 
132
- render json: { status: :ok }
129
+ flash_notice 'Scheduled.'
130
+ redirect_to request.referrer || { action: 'show', id: @newsvideo.id }
133
131
  end
134
132
 
135
- ## via puppeteer
133
+
136
134
  def generate_all_video
137
135
  @newsvideo = Wco::Newsvideo.unscoped.find params[:id]
138
136
  authorize! :edit, @newsvideo
139
137
 
140
- @newsvideo.newspartials.each do |np|
141
- np.generate_video
138
+ @newsvideo.newspartials.each do |newspartial|
139
+ Rails.env.production? ?
140
+ Wco::NewspartialVideoJob.perform_async(newspartial.id.to_s) :
141
+ Wco::NewspartialVideoJob.perform_sync( newspartial.id.to_s)
142
142
  end
143
143
 
144
- render json: { status: :ok }
144
+ flash_notice 'Scheduled.'
145
+ redirect_to request.referrer || { action: 'show', id: @newsvideo.id }
145
146
  end
146
147
 
148
+
147
149
  def generate_illustration
148
150
  @newsvideo = Wco::Newsvideo.unscoped.find params[:id]
149
151
  authorize! :edit, @newsvideo
@@ -25,12 +25,15 @@ class Wco::OfficeActionTemplatesController < Wco::ApplicationController
25
25
  def perform
26
26
  @oat = OAT.find params[:id]
27
27
  authorize! :run, @oat
28
+
28
29
  @conversations = WcoEmail::Conversation.find( params[:conversation_ids] ) if params[:conversation_ids].present?
30
+
29
31
  if 'rb' == @oat.action_type
30
32
  out = eval( @oat.action_exe )
31
33
  elsif 'sh' == @oat.action_type
32
34
  out = `#{@oat.action_exe}`
33
35
  end
36
+
34
37
  flash_notice out
35
38
  redirect_to action: :index
36
39
  end
@@ -12,28 +12,18 @@ class Wco::PublishersController < Wco::ApplicationController
12
12
  redirect_to action: 'index'
13
13
  end
14
14
 
15
- ## this is becoming obsolete - try using do_run_any
16
- def do_run
17
- @publisher = Wco::Publisher.find params[:id]
18
- authorize! :do_run, @publisher
19
-
20
- @publisher.props = OpenStruct.new( JSON.parse params[:publisher][:props] )
21
- # @publisher.do_run binding
22
- @publisher.do_run
23
-
24
- flash_notice "Probably ok"
25
-
26
- redirect_to action: 'index'
27
- end
28
-
29
15
  def do_run_any
30
16
  @publisher = Wco::Publisher.find params[:id]
31
17
  authorize! :do_run, @publisher
32
18
 
33
19
  @publisher.props = OpenStruct.new( JSON.parse params[:props] )
34
- @publisher.do_run
20
+ flag = @publisher.do_run
21
+ if !flag
22
+ flash_alert @publisher.errors
23
+ else
24
+ flash_notice "#do_run_any Probably ok"
25
+ end
35
26
 
36
- flash_notice "Probably ok"
37
27
  redirect_to request.referrer || { action: 'index' }
38
28
  end
39
29
 
@@ -5,16 +5,18 @@ class Wco::ReportsController < Wco::ApplicationController
5
5
 
6
6
  def create
7
7
  params[:report][:tag_ids]&.delete ''
8
+ img_thumb_params = params[:report][:image_thumb]
9
+ params[:report].delete :image_thumb
8
10
 
9
11
  @report = Wco::Report.new params[:report].permit!
10
12
  authorize! :create, @report
11
13
 
12
14
  @report.author = current_profile
13
15
 
14
- if params[:report][:image_thumb]&.[](:image).present?
15
- thumb = @report.image_thumb || @report.build_image_thumb
16
- thumb.image = params[:report][:image_thumb_attributes][:image]
17
- thumb.save
16
+ if img_thumb_params.present?
17
+ @photo = Wco::Photo.new photo: img_thumb_params
18
+ @photo.save!
19
+ @report.image_thumb = @photo
18
20
  end
19
21
 
20
22
  if @report.save
@@ -205,7 +207,6 @@ class Wco::ReportsController < Wco::ApplicationController
205
207
  params[:report][:tag_ids]&.delete ''
206
208
  img_thumb_params = params[:report][:image_thumb]
207
209
  params[:report].delete :image_thumb
208
- # puts! img_thumb_params, 'img_thumb_params'
209
210
 
210
211
  @report = Wco::Report.unscoped.find params[:id]
211
212
  authorize! :update, @report
@@ -7,12 +7,13 @@ class Wco::SitemapPathsController < Wco::ApplicationController
7
7
  @spath = Wco::SitemapPath.find params[:id]
8
8
  authorize! :check, @spath
9
9
  @spath.check
10
+ redirect_to wco.spath_path(@spath)
10
11
  end
11
12
 
12
13
  def clear
13
14
  @spath = Wco::SitemapPath.find params[:id]
14
15
  authorize! :clear, @spath
15
- @spath.update_attributes({ results: [] })
16
+ @spath.logs.destroy_all
16
17
  redirect_to request.referrer || sites_path(@spath.site)
17
18
  end
18
19
 
@@ -29,6 +30,18 @@ class Wco::SitemapPathsController < Wco::ApplicationController
29
30
  end
30
31
  end
31
32
 
33
+ def destroy
34
+ @spath = Wco::SitemapPath.find params[:id]
35
+ site_id = @spath.site_id
36
+ authorize! :destroy, @spath
37
+ if @spath.destroy
38
+ flash_notice 'ok'
39
+ else
40
+ flash_alert 'No luck.'
41
+ end
42
+ redirect_to request.referrer || sites_path(site_id)
43
+ end
44
+
32
45
  def edit
33
46
  @spath = Wco::SitemapPath.find params[:id]
34
47
  @site = @spath.site
@@ -45,7 +58,6 @@ class Wco::SitemapPathsController < Wco::ApplicationController
45
58
  @spath = Wco::SitemapPath.find params[:id]
46
59
  @site = @spath.site
47
60
  authorize! :show, @spath
48
- render 'check'
49
61
  end
50
62
 
51
63
 
@@ -40,7 +40,7 @@ class Wco::SitesController < Wco::ApplicationController
40
40
 
41
41
  def index
42
42
  authorize! :index, Wco::Site
43
- @sites = Wco::Site.all
43
+ @sites = Wco::Site.all.includes( :tags )
44
44
  end
45
45
 
46
46
  def new
@@ -32,7 +32,7 @@ class Wco::TagsController < Wco::ApplicationController
32
32
 
33
33
  def index
34
34
  authorize! :index, Wco::Tag
35
- @tags = Wco::Tag.all.order_by( slug: :asc )
35
+ @tags = Wco::Tag.where( site: nil ).order_by( slug: :asc )
36
36
 
37
37
  tags = Wco::Tag.all.to_a.group_by(&:parent_id)
38
38
  build_tree = lambda do |parent_id|
@@ -0,0 +1,12 @@
1
+
2
+ class Wco::NewspartialSpeechJob
3
+ include Sidekiq::Job
4
+ sidekiq_options queue: 'default'
5
+
6
+ def perform id
7
+ puts! id, 'Newspartial speech job...'
8
+ @newspartial = Wco::Newspartial.find id
9
+ @newspartial.generate_speech
10
+ end
11
+
12
+ end
@@ -1,14 +1,14 @@
1
1
 
2
2
  require 'sidekiq'
3
3
 
4
- class Wco::NewsvideoGenerateJob
4
+ class Wco::NewsvideoCombineJob
5
5
  include Sidekiq::Job
6
6
  sidekiq_options queue: 'default'
7
7
 
8
8
  def perform id
9
9
  puts! id, 'Newsvideo generate job...'
10
10
  @newsvideo = Wco::Newsvideo.find id
11
- @newsvideo.generate
11
+ @newsvideo.only_combine
12
12
  end
13
13
 
14
14
  end
@@ -8,7 +8,7 @@ class Iro::Option
8
8
  attr_accessor :recompute
9
9
 
10
10
  belongs_to :stock, class_name: 'Iro::Stock', inverse_of: :strategies
11
- def ticker; stock.ticker; end
11
+ field :ticker, type: :string
12
12
 
13
13
  CALL = 'CALL'
14
14
  PUT = 'PUT'
@@ -67,14 +67,47 @@ class Iro::Option
67
67
  return options
68
68
  end
69
69
 
70
+ field :symbol, type: :string
71
+ validates :symbol, uniqueness: true
72
+ index({ symbol: -1 }, { unique: true, name: 'symbol' })
73
+ # def symbol
74
+ # return self[:symbol] if self[:symbol]
75
+ # self[:symbol] = generate_symbol
76
+ # end
77
+
70
78
  ## for schwab, eg:
71
79
  ## "COST 260306C01030000"
72
- def symbol
80
+ def generate_symbol
73
81
  p_c_ = put_call == 'PUT' ? 'P' : 'C'
74
82
  strike_ = format("%08d", (strike.to_f * 1000).round)
75
83
  sym = "#{stock.ticker.ljust(6)}#{expires_on.strftime("%y%m%d")}#{p_c_}#{strike_}"
76
84
  end
77
85
 
86
+ def self.find_or_create_by_symbol symbol
87
+ option = Iro::Option.where( symbol: symbol ).first
88
+ return option if option
89
+ h = Iro::Option.symbol_to_h symbol
90
+ item = Iro::Option.new({
91
+ stock: Iro::Stock.find_by( ticker: h[:ticker] ),
92
+ ticker: h[:ticker],
93
+ put_call: h[:put_call],
94
+ strike: h[:strike],
95
+ expires_on: h[:expires_on],
96
+ symbol: symbol,
97
+ })
98
+ item.save
99
+ return item
100
+ end
101
+
102
+ ## trash, I can save the symbol every time. 2026-10-04
103
+ # def self.find_by_symbol symbol
104
+ # option = self.where( symbol: symbol ).first
105
+ # return option if option
106
+ # h = Iro::Option.symbol_to_h symbol
107
+ # Iro::Option.where( h ).first
108
+ # end
109
+
110
+
78
111
  =begin
79
112
  symbol = "META 260424P00500000"
80
113
  =end
@@ -83,7 +116,7 @@ class Iro::Option
83
116
  date_str = symbol[6,6]
84
117
  type = symbol[12] == 'P' ? 'PUT' : 'CALL'
85
118
  strike_str = symbol[13,8]
86
- expires_on = Date.strptime(date_str, "%y%m%d")
119
+ expires_on = Date.strptime(date_str, "%y%m%d").to_s
87
120
  strike = strike_str.to_i / 1000.0
88
121
  return {
89
122
  ticker: ticker,
@@ -92,7 +125,7 @@ class Iro::Option
92
125
  expires_on: expires_on,
93
126
  }
94
127
  end
95
- def symbol_to_h
128
+ def to_h
96
129
  self.class.symbol_to_h symbol
97
130
  end
98
131
 
@@ -21,18 +21,19 @@ class Iro::Priceitem
21
21
  field :bidSize, type: Integer
22
22
  field :ask, type: Float
23
23
  field :askSize, type: Integer
24
- field :last, type: Float ## this is important
24
+ field :last, type: Float ## this is important?
25
+ field :mark, type: Float ## no, this is important. (bid+ask)/2
25
26
 
26
27
  field :openPrice, type: Float
27
28
  field :lowPrice, type: Float
28
29
  field :highPrice, type: Float
29
30
  field :closePrice, type: Float
30
31
 
31
- field :quote_at, type: DateTime ## this is important, the timestamp mostly used for analysis
32
+ field :quote_at, type: DateTime ## this is important?
32
33
  field :quoteTimeInLong, type: Integer
33
- field :timestamp, type: Integer ## do not use?!
34
+ field :timestamp, type: Integer ## do not use?
34
35
  field :totalVolume, type: Integer
35
- field :mark, type: Float
36
+
36
37
  field :exchangeName, type: String
37
38
  field :volatility, type: Float
38
39
 
@@ -43,6 +44,63 @@ class Iro::Priceitem
43
44
  field :openInterest, type: Integer
44
45
  field :strikePrice, type: Float
45
46
 
47
+ def self.create_from_chains!
48
+ Iro::Iro.schwab_exec_sync ## should be schwab_data_sync()
49
+
50
+ stocks = Iro::Stock.active
51
+ fridays = 3.times.map { |i| ( Date.current.next_occurring(:friday) + i.weeks ).to_s }
52
+
53
+ stocks.each do |stock|
54
+ puts "+++ Getting #{stock.ticker}..."
55
+ response = Tda::Option.get_chains({
56
+ ticker: stock.ticker,
57
+ fromDate: fridays[0],
58
+ toDate: fridays.last,
59
+ strikeCount: 10,
60
+ })
61
+ # puts! response.keys, 'response.keys'
62
+ # puts! response['symbol'], 'response symbol'
63
+ # sleep 10
64
+
65
+ first_val = nil
66
+ ['callExpDateMap', 'putExpDateMap'].each do |which_map|
67
+
68
+ response[which_map].each do |_date, strikes|
69
+ if fridays.include?( _date.split(':')[0] )
70
+ strikes.each do |_strike, vals|
71
+ vals.each do |val|
72
+ if !first_val
73
+ first_val = val
74
+ puts! val.keys, 'val keys'
75
+ end
76
+
77
+ option = Iro::Option.find_or_create_by_symbol( val['symbol'] )
78
+
79
+ # opt = OpenStruct.new val
80
+ pi = Iro::Priceitem.new( val.slice( 'expirationDate',
81
+ 'putCall', 'symbol', 'exchangeName', 'bid', 'ask',
82
+ 'last', 'mark', 'bidSize', 'askSize', 'totalVolume', 'quoteTimeInLong', 'volatility',
83
+ 'delta', 'gamma', 'theta', 'openInterest', 'strikePrice' ) )
84
+ pi.stock = stock
85
+ pi.option = option
86
+ pi.quote_at = Time.at( val['quoteTimeInLong'] / 1000 )
87
+ pi.ticker = stock.ticker
88
+ pi.save!
89
+
90
+ # puts! pi
91
+ print '.'
92
+
93
+
94
+ end
95
+ end
96
+ end ## end fridays.include?
97
+ end
98
+
99
+ end ## which_map
100
+ end
101
+
102
+ end
103
+
46
104
  def self.my_find props={}
47
105
  lookup = { '$lookup': {
48
106
  'from': 'iro_price_items',
@@ -1,16 +1,7 @@
1
1
 
2
2
  require 'httparty'
3
3
 
4
- =begin
5
- class Schwab
6
- include HTTParty
7
- debug_output $stdout
8
- base_uri 'https://api.schwabapi.com/marketdata/v1'
9
- end
10
- =end
11
-
12
4
  class Tda::Option
13
-
14
5
  include ::HTTParty
15
6
  # debug_output $stdout
16
7
  base_uri 'https://api.schwabapi.com/marketdata/v1'
@@ -18,7 +9,7 @@ class Tda::Option
18
9
 
19
10
  ##
20
11
  ## Get entire chains for a ticker
21
- ## params: { ticker, force }
12
+ ## params: { ticker, force, strikeCount, fromDate (yyyy-mm-dd), toDate }
22
13
  ##
23
14
  ## 2024-08-09 :: Continue
24
15
  ## 2024-08-21 :: Continue : )
@@ -29,7 +20,10 @@ class Tda::Option
29
20
  return JSON.parse File.read filename
30
21
 
31
22
  else
32
- query = { symbol: params[:ticker] } ## use 'GME' as symbol here even though a symbol is eg 'GME_021023P2.5'
23
+ query = { symbol: params[:ticker] } ## says query[:symbol], not ticker.
24
+ query[:strikeCount] = params[:strikeCount] if params[:strikeCount]
25
+ query[:fromDate] = params[:fromDate] if params[:fromDate]
26
+ query[:toDate] = params[:toDate] if params[:toDate]
33
27
  # puts! query, 'query'
34
28
 
35
29
  headers = {
@@ -37,40 +31,30 @@ class Tda::Option
37
31
  Authorization: "Bearer #{Iro::Iro.schwab_data_token}",
38
32
  }
39
33
  path = "/chains"
40
- out = self.get path, {
41
- headers: headers,
42
- query: query }
43
- timestamp = DateTime.parse out.headers['date']
44
- out = out.parsed_response
45
- # puts! out, 'outs'
34
+ response = self.get path, { headers: headers, query: query }
35
+ timestamp = DateTime.parse response.headers['date']
36
+ response = response.parsed_response
37
+ puts! response, '/chains got this response'
46
38
 
47
39
  outs = []
48
40
  %w| put call |.each do |contractType|
49
- _out = out["#{contractType}ExpDateMap"]
50
- _out.each do |date, vs| ## date="2023-02-10:5"
41
+ _out = response["#{contractType}ExpDateMap"]
42
+ _out.each do |_date, vs| ## date="2023-02-10:5"
51
43
  vs.each do |strike, _v| ## strike="18.5"
52
44
  _v = _v[0] ## weird, keep
53
45
  # puts! _v, '_v'
54
46
 
55
- v = {
56
- putCall: _v['putCall'],
57
- symbol: _v['symbol'],
58
- bid: _v['bid'],
59
- ask: _v['ask'],
60
- last: _v['last'],
61
- totalVolume: _v['totalVolume'],
62
- openInterest: _v['openInterest'],
63
- strikePrice: _v['strikePrice'],
64
- expirationDate: _v['expirationDate'],
65
- }
47
+ v = _v.slice( 'putCall', 'symbol', 'bid', 'ask', 'last', 'mark', 'totalVolume', 'openInterest',
48
+ 'strikePrice', 'expirationDate' )
66
49
  v.each do |k, i|
67
50
  if i == 'NaN'
68
51
  v[k] = nil
69
52
  end
70
53
  end
71
54
 
72
- v[:timestamp] = timestamp
73
- v[:ticker] = params[:ticker]
55
+ v[:timestamp] = timestamp # _v['quoteTimeInLong']/1000.0
56
+ v[:quote_at] = Time.at(_v['quoteTimeInLong'] / 1000.0)
57
+ v[:ticker] = params[:ticker]
74
58
  outs.push( v )
75
59
  end
76
60
  end
@@ -83,8 +67,8 @@ class Tda::Option
83
67
  end
84
68
  end
85
69
 
86
- File.write filename, out.to_json
87
- return out
70
+ File.write filename, JSON.pretty_generate(response)
71
+ return response
88
72
  end
89
73
  end
90
74
 
@@ -96,6 +80,8 @@ class Tda::Option
96
80
  OpenStruct.new ::Tda::Option.get_quotes(params)[0]
97
81
  end
98
82
 
83
+ ## ...for a single symbol.
84
+ ## but use get_quotes_h instead?!
99
85
  ##
100
86
  ## params: contractType, strike, expirationDate, ticker
101
87
  ##
@@ -250,19 +236,23 @@ class Tda::Option
250
236
  end
251
237
 
252
238
  def self.close_credit_call
239
+ throw 'r40 - not implemented'
253
240
  end
254
241
  def self.close_long_debit_call_spread
242
+ throw 'r41 - not implemented'
255
243
  end
256
244
  def self.close_short_debit_put_spread
245
+ throw 'r42 - not implemented'
257
246
  end
258
247
 
259
- def self.get_token
260
- opts = {
261
- grant_type: 'authorization_code',
262
- access_type: 'offline',
263
- code: ::TD_AMERITRADE[:code],
264
- }
265
- end
248
+ ## trash? remove.
249
+ # def self.get_token
250
+ # opts = {
251
+ # grant_type: 'authorization_code',
252
+ # access_type: 'offline',
253
+ # code: ::TD_AMERITRADE[:code],
254
+ # }
255
+ # end
266
256
 
267
257
  def self.create_credit_call outer:, inner:, q:, price:
268
258
  query = {
@@ -307,13 +297,21 @@ class Tda::Option
307
297
  # puts! out, 'created credit call?'
308
298
  end
309
299
  def self.create_long_debit_call_spread
300
+ throw 'r43 - not implemented'
310
301
  end
311
302
  def self.create_short_debit_put_spread
303
+ throw 'r44 - not implemented'
312
304
  end
313
305
 
314
306
 
315
307
  end
316
308
 
309
+
310
+
311
+
312
+
313
+
314
+
317
315
  ##
318
316
  ## From: https://developer.tdameritrade.com/content/place-order-samples
319
317
  ## Buy Limit: Vertical Call Spread
@@ -69,8 +69,9 @@ class Wco::Newspartial
69
69
  ##
70
70
  ## "am_fenrir", ## bad
71
71
  ## am_michael good
72
- ## "af_bella" ## bad
73
- ## "af_jessica", ## good
72
+ ## am_puck good
73
+ ## "af_bella" ## bad
74
+ ## "af_jessica" ## good
74
75
  ##
75
76
  def generate_speech
76
77
  out = HTTParty.post( "#{Wco::Setting.get('HEAD_TTS_ORIGIN')}/v1/synthesize",
@@ -139,8 +140,17 @@ class Wco::Newspartial
139
140
  return out
140
141
  end
141
142
  def generate_video
142
- out = `#{generate_video_cmd}`
143
- puts! out, 'out'
143
+ Open3.popen3(generate_video_cmd) do |stdin, stdout, stderr, wait_thr|
144
+ stdin.close
145
+ stdout.each_line do |line|
146
+ puts line
147
+ end
148
+ stderr.each_line do |line|
149
+ puts line
150
+ end
151
+ status = wait_thr.value
152
+ puts "Exit status: #{status.exitstatus}"
153
+ end
144
154
  end
145
155
  def generate_video_cmd
146
156
  cmd = "cd #{Wco::Setting.get('PUPPETEER_ROOT')} ; NEWSPARTIAL_URL='#{generate_video_url}' yarn run run_newspartial_1 "
@@ -150,12 +160,12 @@ class Wco::Newspartial
150
160
  end
151
161
  def generate_video_url
152
162
  newspartial = self
153
- url = Wco::Engine.routes.url_helpers.api_newspartial_config_url({ id: newspartial.id,
154
- host: Wco::Setting.get('WASYACO_ORIGIN'),
163
+ path = Wco::Engine.routes.url_helpers.api_newspartial_config_path({ id: newspartial.id,
155
164
  wco_origin: Wco::Setting.get('WASYACO_ORIGIN'),
156
165
  api_key: Wco::Setting.get('WASYACO_SIMPLE_API_KEY'),
157
166
  api_secret: Wco::Setting.get('WASYACO_SIMPLE_API_SECRET'),
158
167
  })
168
+ "https://#{Wco::Setting.get('WASYACO_ORIGIN')}#{path}"
159
169
  end
160
170
 
161
171
  def video
@@ -71,7 +71,7 @@ class Wco::Newsvideo
71
71
  end
72
72
 
73
73
 
74
- def generate
74
+ def only_combine
75
75
  @newsvideo = self
76
76
  workdir = Rails.root.join('tmp', @newsvideo.id.to_s)
77
77
  partials = @newsvideo.newspartials.order_by(slug: :asc).to_a