tdameritrade-api-ruby 1.3.0.20210215

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +22 -0
  3. data/.rspec +2 -0
  4. data/CHANGELOG.md +29 -0
  5. data/Gemfile +4 -0
  6. data/LICENSE.txt +22 -0
  7. data/README.md +84 -0
  8. data/Rakefile +8 -0
  9. data/lib/tdameritrade-api-ruby.rb +1 -0
  10. data/lib/tdameritrade.rb +9 -0
  11. data/lib/tdameritrade/authentication.rb +65 -0
  12. data/lib/tdameritrade/client.rb +56 -0
  13. data/lib/tdameritrade/error.rb +20 -0
  14. data/lib/tdameritrade/operations/base_operation.rb +36 -0
  15. data/lib/tdameritrade/operations/create_watchlist.rb +30 -0
  16. data/lib/tdameritrade/operations/get_instrument_fundamentals.rb +22 -0
  17. data/lib/tdameritrade/operations/get_price_history.rb +55 -0
  18. data/lib/tdameritrade/operations/get_quotes.rb +21 -0
  19. data/lib/tdameritrade/operations/get_watchlists.rb +12 -0
  20. data/lib/tdameritrade/operations/replace_watchlist.rb +33 -0
  21. data/lib/tdameritrade/operations/support/build_watchlist_items.rb +21 -0
  22. data/lib/tdameritrade/operations/update_watchlist.rb +33 -0
  23. data/lib/tdameritrade/util.rb +50 -0
  24. data/lib/tdameritrade/version.rb +3 -0
  25. data/spec/spec_helper.rb +110 -0
  26. data/spec/support/authenticated_client.rb +12 -0
  27. data/spec/support/spec/mocks/mock_get_instrument_fundamentals.rb +17 -0
  28. data/spec/support/spec/mocks/mock_get_price_history.rb +17 -0
  29. data/spec/support/spec/mocks/mock_get_quotes.rb +17 -0
  30. data/spec/support/spec/mocks/mock_watchlists.rb +43 -0
  31. data/spec/support/spec/mocks/tdameritrade_api_mock_base.rb +21 -0
  32. data/spec/support/webmock_off.rb +7 -0
  33. data/spec/tdameritrade/operations/create_watchlist_spec.rb +42 -0
  34. data/spec/tdameritrade/operations/error_spec.rb +75 -0
  35. data/spec/tdameritrade/operations/get_instrument_fundamentals_spec.rb +182 -0
  36. data/spec/tdameritrade/operations/get_price_history_spec.rb +160 -0
  37. data/spec/tdameritrade/operations/get_quotes_spec.rb +351 -0
  38. data/spec/tdameritrade/operations/get_watchlists_spec.rb +80 -0
  39. data/spec/tdameritrade/operations/replace_watchlist_spec.rb +45 -0
  40. data/spec/tdameritrade/operations/update_watchlist_spec.rb +45 -0
  41. data/tdameritrade-api-ruby.gemspec +33 -0
  42. metadata +253 -0
@@ -0,0 +1,45 @@
1
+ require 'spec_helper'
2
+ require 'support/authenticated_client'
3
+ require 'tdameritrade'
4
+
5
+ describe TDAmeritrade::Operations::UpdateWatchlist do
6
+ include_context 'authenticated client'
7
+ # include_context 'webmock off'
8
+
9
+ context 'for single account' do
10
+ subject do
11
+ client.update_watchlist(account_id, watchlist_id, 'My New Watchlist', %w(AAPL MSFT VZ))
12
+ end
13
+
14
+ let(:account_id) { '123456789' }
15
+ let(:watchlist_id) { '666666666' }
16
+
17
+ let!(:expected_request) do
18
+ TDAmeritrade::Spec::Mocks::MockWatchlists.mock_update(
19
+ account_id,
20
+ watchlist_id,
21
+ request: {
22
+ headers: { 'Authorization': "Bearer #{client.access_token}" },
23
+ body: expected_request_body
24
+ }
25
+ )
26
+ end
27
+
28
+ let(:expected_request_body) do
29
+ {
30
+ :name=>"My New Watchlist",
31
+ :watchlistId=>"#{watchlist_id}",
32
+ :watchlistItems=>
33
+ [
34
+ {:quantity=>0, :averagePrice=>0, :commission=>0, :purchasedDate=>Date.today.strftime('%Y-%m-%d'), :instrument=>{:symbol=>"AAPL", :assetType=>"EQUITY"}},
35
+ {:quantity=>0, :averagePrice=>0, :commission=>0, :purchasedDate=>Date.today.strftime('%Y-%m-%d'), :instrument=>{:symbol=>"MSFT", :assetType=>"EQUITY"}},
36
+ {:quantity=>0, :averagePrice=>0, :commission=>0, :purchasedDate=>Date.today.strftime('%Y-%m-%d'), :instrument=>{:symbol=>"VZ", :assetType=>"EQUITY"}}
37
+ ]
38
+ }.to_json
39
+ end
40
+
41
+ it { is_expected.to be_truthy }
42
+ end
43
+
44
+
45
+ end
@@ -0,0 +1,33 @@
1
+ # coding: utf-8
2
+ lib = File.expand_path('../lib', __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require 'tdameritrade/version'
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "tdameritrade-api-ruby"
8
+ spec.version = TDAmeritrade::VERSION
9
+ spec.authors = ["Winston Kotzan"]
10
+ spec.email = ["wak@wakproductions.com"]
11
+ spec.summary = %q{This is a simple gem for connecting to the TD Ameritrade Developers API}
12
+ spec.description = ""
13
+ spec.homepage = ""
14
+ spec.license = "MIT"
15
+
16
+ spec.files = [`git ls-files`.split($/)] + Dir["lib/**/*"]
17
+ spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
18
+ spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
19
+ spec.require_paths = ["lib"]
20
+
21
+ spec.add_dependency "bundler", "~> 1.5"
22
+ spec.add_dependency "rake"
23
+ spec.add_dependency "hashie"
24
+ spec.add_dependency "httparty", "~> 0.13"
25
+ spec.add_dependency "activesupport", "~> 4.0"
26
+ spec.add_dependency "nokogiri", "~> 1.6"
27
+
28
+ spec.add_development_dependency "clipboard"
29
+ spec.add_development_dependency "httplog"
30
+ spec.add_development_dependency "rspec", ">= 3.2"
31
+ spec.add_development_dependency "pry"
32
+ spec.add_development_dependency "webmock"
33
+ end
metadata ADDED
@@ -0,0 +1,253 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tdameritrade-api-ruby
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.3.0.20210215
5
+ platform: ruby
6
+ authors:
7
+ - Winston Kotzan
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2021-02-16 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: bundler
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.5'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.5'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: hashie
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :runtime
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: httparty
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.13'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.13'
69
+ - !ruby/object:Gem::Dependency
70
+ name: activesupport
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '4.0'
76
+ type: :runtime
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '4.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: nokogiri
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.6'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.6'
97
+ - !ruby/object:Gem::Dependency
98
+ name: clipboard
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - ">="
102
+ - !ruby/object:Gem::Version
103
+ version: '0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - ">="
109
+ - !ruby/object:Gem::Version
110
+ version: '0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: httplog
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - ">="
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - ">="
123
+ - !ruby/object:Gem::Version
124
+ version: '0'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rspec
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - ">="
130
+ - !ruby/object:Gem::Version
131
+ version: '3.2'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - ">="
137
+ - !ruby/object:Gem::Version
138
+ version: '3.2'
139
+ - !ruby/object:Gem::Dependency
140
+ name: pry
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - ">="
144
+ - !ruby/object:Gem::Version
145
+ version: '0'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - ">="
151
+ - !ruby/object:Gem::Version
152
+ version: '0'
153
+ - !ruby/object:Gem::Dependency
154
+ name: webmock
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: '0'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - ">="
165
+ - !ruby/object:Gem::Version
166
+ version: '0'
167
+ description: ''
168
+ email:
169
+ - wak@wakproductions.com
170
+ executables: []
171
+ extensions: []
172
+ extra_rdoc_files: []
173
+ files:
174
+ - ".gitignore"
175
+ - ".rspec"
176
+ - CHANGELOG.md
177
+ - Gemfile
178
+ - LICENSE.txt
179
+ - README.md
180
+ - Rakefile
181
+ - lib/tdameritrade-api-ruby.rb
182
+ - lib/tdameritrade.rb
183
+ - lib/tdameritrade/authentication.rb
184
+ - lib/tdameritrade/client.rb
185
+ - lib/tdameritrade/error.rb
186
+ - lib/tdameritrade/operations/base_operation.rb
187
+ - lib/tdameritrade/operations/create_watchlist.rb
188
+ - lib/tdameritrade/operations/get_instrument_fundamentals.rb
189
+ - lib/tdameritrade/operations/get_price_history.rb
190
+ - lib/tdameritrade/operations/get_quotes.rb
191
+ - lib/tdameritrade/operations/get_watchlists.rb
192
+ - lib/tdameritrade/operations/replace_watchlist.rb
193
+ - lib/tdameritrade/operations/support/build_watchlist_items.rb
194
+ - lib/tdameritrade/operations/update_watchlist.rb
195
+ - lib/tdameritrade/util.rb
196
+ - lib/tdameritrade/version.rb
197
+ - spec/spec_helper.rb
198
+ - spec/support/authenticated_client.rb
199
+ - spec/support/spec/mocks/mock_get_instrument_fundamentals.rb
200
+ - spec/support/spec/mocks/mock_get_price_history.rb
201
+ - spec/support/spec/mocks/mock_get_quotes.rb
202
+ - spec/support/spec/mocks/mock_watchlists.rb
203
+ - spec/support/spec/mocks/tdameritrade_api_mock_base.rb
204
+ - spec/support/webmock_off.rb
205
+ - spec/tdameritrade/operations/create_watchlist_spec.rb
206
+ - spec/tdameritrade/operations/error_spec.rb
207
+ - spec/tdameritrade/operations/get_instrument_fundamentals_spec.rb
208
+ - spec/tdameritrade/operations/get_price_history_spec.rb
209
+ - spec/tdameritrade/operations/get_quotes_spec.rb
210
+ - spec/tdameritrade/operations/get_watchlists_spec.rb
211
+ - spec/tdameritrade/operations/replace_watchlist_spec.rb
212
+ - spec/tdameritrade/operations/update_watchlist_spec.rb
213
+ - tdameritrade-api-ruby.gemspec
214
+ homepage: ''
215
+ licenses:
216
+ - MIT
217
+ metadata: {}
218
+ post_install_message:
219
+ rdoc_options: []
220
+ require_paths:
221
+ - lib
222
+ required_ruby_version: !ruby/object:Gem::Requirement
223
+ requirements:
224
+ - - ">="
225
+ - !ruby/object:Gem::Version
226
+ version: '0'
227
+ required_rubygems_version: !ruby/object:Gem::Requirement
228
+ requirements:
229
+ - - ">="
230
+ - !ruby/object:Gem::Version
231
+ version: '0'
232
+ requirements: []
233
+ rubygems_version: 3.1.2
234
+ signing_key:
235
+ specification_version: 4
236
+ summary: This is a simple gem for connecting to the TD Ameritrade Developers API
237
+ test_files:
238
+ - spec/spec_helper.rb
239
+ - spec/support/authenticated_client.rb
240
+ - spec/support/spec/mocks/mock_get_instrument_fundamentals.rb
241
+ - spec/support/spec/mocks/mock_get_price_history.rb
242
+ - spec/support/spec/mocks/mock_get_quotes.rb
243
+ - spec/support/spec/mocks/mock_watchlists.rb
244
+ - spec/support/spec/mocks/tdameritrade_api_mock_base.rb
245
+ - spec/support/webmock_off.rb
246
+ - spec/tdameritrade/operations/create_watchlist_spec.rb
247
+ - spec/tdameritrade/operations/error_spec.rb
248
+ - spec/tdameritrade/operations/get_instrument_fundamentals_spec.rb
249
+ - spec/tdameritrade/operations/get_price_history_spec.rb
250
+ - spec/tdameritrade/operations/get_quotes_spec.rb
251
+ - spec/tdameritrade/operations/get_watchlists_spec.rb
252
+ - spec/tdameritrade/operations/replace_watchlist_spec.rb
253
+ - spec/tdameritrade/operations/update_watchlist_spec.rb