tradier 0.2.0 → 0.3.0

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.
@@ -118,6 +118,28 @@ describe Tradier::API::Markets do
118
118
  expect(expirations.size).to eq(12)
119
119
  expect(expirations.first).to be_a Date
120
120
  end
121
+
122
+ context 'with strikes' do
123
+ before do
124
+ stub_get("/v1/markets/options/expirations").
125
+ with(:query => {:symbol => "AAPL", :strikes => 'true'}).
126
+ to_return(:body => fixture("expirations_with_strikes.json"), :headers => {:content_type => "application/json; charset=utf-8"})
127
+ end
128
+
129
+ it "requests the correct resource" do
130
+ @client.expirations("AAPL", :strikes => true)
131
+
132
+ expect(a_get("/v1/markets/options/expirations").
133
+ with(:query => {:symbol => "AAPL", :strikes => 'true'})).to have_been_made
134
+ end
135
+
136
+ it "returns an array of expirations" do
137
+ expirations = @client.expirations("AAPL", :strikes => true)
138
+ expect(expirations).to be_an Array
139
+ expect(expirations.size).to eq(12)
140
+ expect(expirations.first).to be_a Tradier::Expiration
141
+ end
142
+ end
121
143
  end
122
144
 
123
145
  describe "#strikes" do
@@ -0,0 +1,30 @@
1
+ require 'spec_helper'
2
+
3
+ describe Tradier::Expiration do
4
+
5
+ describe "#date" do
6
+ it "returns the date when set" do
7
+ exp = described_class.new({ :date => '2013-07-04' })
8
+ expect(exp.date).to be_a Date
9
+ expect(exp.date.to_s).to eq('2013-07-04')
10
+ end
11
+ it "returns nil when date is not set" do
12
+ exp = described_class.new({})
13
+ expect(exp.date).to be_nil
14
+ end
15
+ end
16
+
17
+ describe '#strikes' do
18
+ it 'returns an array of strikes when set' do
19
+ exp = described_class.new({ :strikes => { :strike => [2, 3, 4, 5, 6] }})
20
+ expect(exp.strikes).to be_an Array
21
+ expect(exp.strikes.size).to eq(5)
22
+ end
23
+ it 'returns an empty array when not set' do
24
+ exp = described_class.new({})
25
+ expect(exp.strikes).to be_an Array
26
+ expect(exp.strikes.size).to eq(0)
27
+ end
28
+ end
29
+
30
+ end
@@ -31,5 +31,13 @@ describe Tradier::Watchlist do
31
31
  expect(watchlist.items.size).to eq(2)
32
32
  expect(watchlist.items.first).to be_a Tradier::WatchlistItem
33
33
  end
34
+
35
+ it "returns an array of watchlist items" do
36
+ response = {:items => { :item => {:symbol => 'AAPL'}}}
37
+ watchlist = Tradier::Watchlist.new(response)
38
+ expect(watchlist.items).to be_an Array
39
+ expect(watchlist.items.size).to eq(1)
40
+ expect(watchlist.items.first).to be_a Tradier::WatchlistItem
41
+ end
34
42
  end
35
43
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tradier
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.2.0
4
+ version: 0.3.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Steve Agalloco
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2014-01-17 00:00:00.000000000 Z
12
+ date: 2014-04-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: faraday
@@ -79,11 +79,13 @@ files:
79
79
  - LICENSE.md
80
80
  - README.md
81
81
  - Rakefile
82
- - tradier.gemspec
82
+ - lib/tradier.rb
83
83
  - lib/tradier/account.rb
84
+ - lib/tradier/adjustment.rb
84
85
  - lib/tradier/api/accounts.rb
85
86
  - lib/tradier/api/markets.rb
86
87
  - lib/tradier/api/orders.rb
88
+ - lib/tradier/api/utils.rb
87
89
  - lib/tradier/api/utils/account.rb
88
90
  - lib/tradier/api/utils/balance.rb
89
91
  - lib/tradier/api/utils/base.rb
@@ -98,7 +100,6 @@ files:
98
100
  - lib/tradier/api/utils/strike.rb
99
101
  - lib/tradier/api/utils/timesales.rb
100
102
  - lib/tradier/api/utils/watchlist.rb
101
- - lib/tradier/api/utils.rb
102
103
  - lib/tradier/api/watchlists.rb
103
104
  - lib/tradier/balance.rb
104
105
  - lib/tradier/base.rb
@@ -108,6 +109,7 @@ files:
108
109
  - lib/tradier/configurable.rb
109
110
  - lib/tradier/core_ext/enumerable.rb
110
111
  - lib/tradier/default.rb
112
+ - lib/tradier/error.rb
111
113
  - lib/tradier/error/bad_gateway.rb
112
114
  - lib/tradier/error/bad_request.rb
113
115
  - lib/tradier/error/client_error.rb
@@ -124,9 +126,9 @@ files:
124
126
  - lib/tradier/error/too_many_requests.rb
125
127
  - lib/tradier/error/unauthorized.rb
126
128
  - lib/tradier/error/unprocessable_entity.rb
127
- - lib/tradier/error.rb
128
129
  - lib/tradier/event.rb
129
130
  - lib/tradier/event_session.rb
131
+ - lib/tradier/expiration.rb
130
132
  - lib/tradier/history.rb
131
133
  - lib/tradier/option_quote.rb
132
134
  - lib/tradier/order.rb
@@ -140,7 +142,6 @@ files:
140
142
  - lib/tradier/version.rb
141
143
  - lib/tradier/watchlist.rb
142
144
  - lib/tradier/watchlist_item.rb
143
- - lib/tradier.rb
144
145
  - spec/fixtures/account_balances.json
145
146
  - spec/fixtures/account_gainloss.json
146
147
  - spec/fixtures/account_history.json
@@ -150,6 +151,7 @@ files:
150
151
  - spec/fixtures/chain.json
151
152
  - spec/fixtures/clock.json
152
153
  - spec/fixtures/expirations.json
154
+ - spec/fixtures/expirations_with_strikes.json
153
155
  - spec/fixtures/history.json
154
156
  - spec/fixtures/option_quote.json
155
157
  - spec/fixtures/option_quotes.json
@@ -185,6 +187,7 @@ files:
185
187
  - spec/tradier/error/client_error_spec.rb
186
188
  - spec/tradier/error/server_error_spec.rb
187
189
  - spec/tradier/error_spec.rb
190
+ - spec/tradier/expiration_spec.rb
188
191
  - spec/tradier/option_quote_spec.rb
189
192
  - spec/tradier/order_spec.rb
190
193
  - spec/tradier/position_spec.rb
@@ -194,6 +197,7 @@ files:
194
197
  - spec/tradier/watchlist_item_spec.rb
195
198
  - spec/tradier/watchlist_spec.rb
196
199
  - spec/tradier_spec.rb
200
+ - tradier.gemspec
197
201
  homepage: https://github.com/tradier/tradier.rb
198
202
  licenses:
199
203
  - MIT
@@ -214,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
214
218
  version: '0'
215
219
  requirements: []
216
220
  rubyforge_project:
217
- rubygems_version: 2.0.14
221
+ rubygems_version: 2.2.2
218
222
  signing_key:
219
223
  specification_version: 4
220
224
  summary: Rubygem for interacting with the Tradier API.
@@ -228,6 +232,7 @@ test_files:
228
232
  - spec/fixtures/chain.json
229
233
  - spec/fixtures/clock.json
230
234
  - spec/fixtures/expirations.json
235
+ - spec/fixtures/expirations_with_strikes.json
231
236
  - spec/fixtures/history.json
232
237
  - spec/fixtures/option_quote.json
233
238
  - spec/fixtures/option_quotes.json
@@ -263,6 +268,7 @@ test_files:
263
268
  - spec/tradier/error/client_error_spec.rb
264
269
  - spec/tradier/error/server_error_spec.rb
265
270
  - spec/tradier/error_spec.rb
271
+ - spec/tradier/expiration_spec.rb
266
272
  - spec/tradier/option_quote_spec.rb
267
273
  - spec/tradier/order_spec.rb
268
274
  - spec/tradier/position_spec.rb