iron_warbler 2.0.7.28 → 2.0.7.29

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: b7ca7e6c0657dbafd3a3e9149fbf05f7a0e0aa275b39d183e145d8802cadc175
4
- data.tar.gz: c67d4ee07b9646761ed2de0d1291e68d36d7a794ed6b4db58a2d7f2428d72944
3
+ metadata.gz: 60a17bd2d6ccedafac952f5463331f53ff1e1817e8eab7a00285b43deb265396
4
+ data.tar.gz: e85425f94157c1d040c2606247ca42b5c7d928431d05978c92d94ea1b8f1b365
5
5
  SHA512:
6
- metadata.gz: ad587c8488a2a3a1f7a269c32129ba879c3fde5fb54e2a32a7e2a2f45132995e7d2566a492e002c9ee72d83cfb40fdbc1c81dc5f7a536cd5b368cdb95bb2a038
7
- data.tar.gz: 4c08a09952620d5339e9f76e5b29ebf5d1134fe0fd20b774f3b7123cd6fe28683b7f517388ac08f1af6142df4edda686d36ab304ff8816c954ce368bdf5a22db
6
+ metadata.gz: 5f035df03d218468790ed2af125164f2173dcdbcd47598cd3f846aea14cfc6b032b2c16f72d03f7ca53d5eebfa37bf398359bfd032230e2c74e44296214a6f1e
7
+ data.tar.gz: 9e71f4855db33c8f7b02fd021980eb1e8b8eff59d6d7f24c96c8d3de380aeafb286a127650ef56dea0192f60f874b8b4f71b2feb57028706a2a681661d4fb822
@@ -0,0 +1,9 @@
1
+
2
+ .iro-alerts--index {
3
+ .field {
4
+ label {
5
+ min-width: auto;
6
+ }
7
+ }
8
+ }
9
+
@@ -45,8 +45,8 @@ class Iro::AlertsController < Iro::ApplicationController
45
45
  super
46
46
 
47
47
  # @profiles_list = Wco::Profile.list
48
- @stocks_list = Iro::Stock.list
49
- puts! @stocks_list, '@stocks_list'
48
+ @stocks_list = Iro::Stock.list
49
+ @symbols_list = [[nil,nil]] + Iro::Stock.active.map { |s| [ s.ticker, s.ticker ] }
50
50
  end
51
51
 
52
52
 
@@ -1,8 +1,41 @@
1
1
 
2
+ class Schwab
3
+ include HTTParty
4
+ debug_output $stdout
5
+ end
6
+
2
7
  class Iro::ApiController < ActionController::Base
3
8
  layout false
4
9
 
5
- before_action :decode_jwt
10
+ before_action :decode_jwt, except: [ :oauth2_redirect ]
11
+
12
+ def oauth2_redirect
13
+ out = Schwab.post( "https://api.schwabapi.com/v1/oauth/token", {
14
+ headers: {
15
+ "Content-Type": "application/x-www-form-urlencoded",
16
+ },
17
+ basic_auth: { username: SCHWAB_DATA[:key], password: SCHWAB_DATA[:secret] },
18
+ body: {
19
+ grant_type: 'authorization_code',
20
+ code: params[:code].sub('%40', '@'),
21
+ redirect_uri: SCHWAB_DATA[:redirect_url],
22
+ },
23
+ })
24
+ out = out.parsed_response
25
+
26
+ attrs = {
27
+ schwab_access_token: out['access_token'],
28
+ schwab_refresh_token: out['refresh_token'],
29
+ schwab_id_token: out['id_token'],
30
+ }
31
+ # puts! attrs, 'attrs'
32
+
33
+ profile = Wco::Profile.find_by email: 'piousbox@gmail.com'
34
+ profile.update(attrs)
35
+ profile.save!
36
+
37
+ render json: { status: :ok }
38
+ end
6
39
 
7
40
  ##
8
41
  ## private
@@ -84,7 +84,7 @@ class Tda::Option
84
84
  end
85
85
  end
86
86
  if params[:expirationDate]
87
- opts[:fromDate] = opts[:toDate] = params[:expirationDate]
87
+ opts[:fromDate] = opts[:toDate] = params[:expirationDate].to_s[0...10]
88
88
  else
89
89
  raise Iro::InputError.new("Invalid input, missing 'date'.")
90
90
  end
@@ -98,11 +98,12 @@ class Tda::Option
98
98
  opts[:strike] = params[:strike]
99
99
  end
100
100
 
101
- query = { apikey: ::TD_AMERITRADE[:apiKey] }.merge opts
101
+ query = { }.merge opts
102
102
  # puts! query, 'input opts'
103
103
 
104
104
  headers = {
105
- Authorize: "Bearer #{::TD_AMERITRADE[:access_token]}",
105
+ accept: 'application/json',
106
+ Authorization: "Bearer #{::SCHWAB_DATA[:access_token]}",
106
107
  }
107
108
 
108
109
 
@@ -13,14 +13,16 @@ class Tda::Stock
13
13
  ## tickers = "GME"
14
14
  ## tickers = "NVDA,GME"
15
15
  def self.get_quotes tickers
16
+ profile = Wco::Profile.find_by email: 'piousbox@gmail.com'
17
+
16
18
  path = "/quotes"
17
19
  headers = {
18
20
  accept: 'application/json',
19
- Authorization: "Bearer #{::SCHWAB_DATA[:access_token]}",
21
+ Authorization: "Bearer #{profile.schwab_access_token}",
20
22
  }
21
23
  inns = self.get path, { headers: headers, query: { symbols: tickers } }
22
24
  inns = inns.parsed_response
23
- # puts! inns, 'parsed response'
25
+ puts! inns, 'parsed response'
24
26
 
25
27
  if [ NilClass, String ].include?( inns.class )
26
28
  return []
@@ -7,6 +7,8 @@
7
7
  .W
8
8
  .d-flex.flex-wrap
9
9
  %ul
10
+ %li
11
+ = link_to "Schwab Login", "https://api.schwabapi.com/v1/oauth/authorize?client_id=#{SCHWAB_DATA[:key]}&redirect_uri=#{SCHWAB_DATA[:redirect_url]}"
10
12
  %li
11
13
  = link_to "Stocks (#{Iro::Stock.all.length})", stocks_path
12
14
  = link_to '[sync]', sync_stocks_path
@@ -24,7 +24,7 @@
24
24
  -# = f.text_field :kind
25
25
  .field
26
26
  = f.label :symbol
27
- = f.select :symbol, options_for_select( @stocks_list, selected: alert.symbol )
27
+ = f.select :symbol, options_for_select( @symbols_list, selected: alert.symbol )
28
28
  .field
29
29
  = f.label :direction
30
30
  = f.select :direction, options_for_select([ :ABOVE, :BELOW ], selected: alert.direction)
@@ -1,9 +1,9 @@
1
1
 
2
- .iro-alerts--index.maxwidth
2
+ .iro-alerts--index.padded
3
3
  %h5 Iro Alerts
4
4
 
5
- %ul
5
+ .a
6
6
  - @alerts.each do |alert|
7
- %li
7
+ .a
8
8
  = render 'iro/alerts/form', alert: alert
9
- %li= render 'iro/alerts/form', alert: Iro::Alert.new
9
+ .a= render 'iro/alerts/form', alert: Iro::Alert.new
@@ -18,9 +18,9 @@
18
18
  %label Stock
19
19
  = f.select :stock_id, options_for_select( @stocks_list, selected: position.stock_id )
20
20
 
21
- .field
22
- %label long or short?
23
- = f.select :long_or_short, options_for_select([nil, Iro::Strategy::LONG, Iro::Strategy::SHORT], selected: long_or_short )
21
+ -# .field
22
+ -# %label long or short?
23
+ -# = f.select :long_or_short, options_for_select([nil, Iro::Strategy::LONG, Iro::Strategy::SHORT], selected: long_or_short )
24
24
 
25
25
  %label Strategy
26
26
  = f.select :strategy_id, options_for_select( @strategies_list, selected: position.strategy_id )
data/config/routes.rb CHANGED
@@ -9,14 +9,14 @@ Iro::Engine.routes.draw do
9
9
 
10
10
  resources :option_watches
11
11
 
12
- match 'positions/:id/close', to: 'positions#close', as: :close_position, via: [ :get, :post ]
13
- get 'positions/duplicate/:id', to: 'positions#new', as: :duplicate_position
14
- post 'positions/propose', to: 'positions#propose', as: :propose_position
15
- get 'positions/:id/prepare', to: 'positions#prepare', as: :prepare_to_roll_position, defaults: { template: 'gameui' }
16
- match 'positions/:id/prepare2', to: 'positions#prepare2', as: :prepare2_position, defaults: { template: 'gameui' }, via: [ :get, :post ]
17
- match 'positions/:id/prepare3', to: 'positions#prepare3', as: :prepare3_position, defaults: { template: 'gameui' }, via: [ :get, :post ]
18
- post 'positions/:id/roll', to: 'positions#do_roll', as: :roll_position
19
- get 'positions/:id/sync', to: 'positions#sync', as: :sync_position
12
+ match 'positions/:id/close', to: 'positions#close', as: :close_position, via: [ :get, :post ]
13
+ get 'positions/duplicate/:id', to: 'positions#new', as: :duplicate_position
14
+ post 'positions/propose', to: 'positions#propose', as: :propose_position
15
+ get 'positions/:id/prepare', to: 'positions#prepare', as: :prepare_to_roll_position, defaults: { template: 'gameui' }
16
+ match 'positions/:id/prepare2', to: 'positions#prepare2', as: :prepare2_position, defaults: { template: 'gameui' }, via: [ :get, :post ]
17
+ match 'positions/:id/prepare3', to: 'positions#prepare3', as: :prepare3_position, defaults: { template: 'gameui' }, via: [ :get, :post ]
18
+ post 'positions/:id/roll', to: 'positions#do_roll', as: :roll_position
19
+ get 'positions/:id/sync', to: 'positions#sync', as: :sync_position
20
20
  resources :positions
21
21
  resources :profiles
22
22
 
@@ -29,6 +29,7 @@ Iro::Engine.routes.draw do
29
29
 
30
30
  resources :strategies
31
31
 
32
+ get 'api/oauth2-redirect.html', to: 'api#oauth2_redirect'
32
33
  namespace :api do
33
34
  get 'stocks', to: 'stocks#index'
34
35
  get 'stocks/:ticker', to: 'stocks#show'
@@ -62,7 +62,8 @@ namespace :iro do
62
62
  # Wco::Exceptionist.notify(e, 'Error in iro:watch_stocks')
63
63
  end
64
64
 
65
- sleep 15*60 # 15 min
65
+ print '.'
66
+ sleep 15 # *60 # 15 min
66
67
  end
67
68
  end
68
69
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: iron_warbler
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.7.28
4
+ version: 2.0.7.29
5
5
  platform: ruby
6
6
  authors:
7
7
  - Victor Pudeyev
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2024-07-18 00:00:00.000000000 Z
11
+ date: 2024-07-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: business_time
@@ -218,6 +218,7 @@ files:
218
218
  - app/assets/javascript/iron_warbler/application.js
219
219
  - app/assets/javascript/iron_warbler/gameui.js
220
220
  - app/assets/stylesheets/iron_warbler/Card.scss
221
+ - app/assets/stylesheets/iron_warbler/alerts.scss
221
222
  - app/assets/stylesheets/iron_warbler/application.css
222
223
  - app/assets/stylesheets/iron_warbler/positions.scss
223
224
  - app/assets/stylesheets/iron_warbler/positions_gameui.scss