tradier 0.3.0 → 0.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/tradier/api/accounts.rb +4 -0
- data/lib/tradier/api/markets.rb +28 -0
- data/lib/tradier/api/utils.rb +2 -0
- data/lib/tradier/api/utils/search.rb +15 -0
- data/lib/tradier/security.rb +12 -0
- data/lib/tradier/version.rb +1 -1
- data/spec/fixtures/lookup.json +114 -0
- data/spec/fixtures/search.json +54 -0
- data/spec/tradier/api/accounts_spec.rb +10 -0
- data/spec/tradier/api/markets_spec.rb +38 -0
- data/spec/tradier/client_spec.rb +2 -2
- metadata +19 -13
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 449b7877390ee6691113e738fc3ebf638eecc09f
|
4
|
+
data.tar.gz: ec4c89c64ee72eb5665e92b7f4144a0353076075
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c7c24a2ca8b67075d6b5b2bea0aef327c0b044bee2bae19a61bbc5057821abcd390a79799630d2af8535cade2db7b82b2fada66244660bff99b11121aec2f612
|
7
|
+
data.tar.gz: 9610f12009bb0a19f1f01c78c0718d3e95278a1b131f29c9a0403e4081a7bd172798ca85099eaa26139acb778c3975997fb4fbfdcc632ab781fba09c206e02c1
|
data/lib/tradier/api/accounts.rb
CHANGED
@@ -108,6 +108,9 @@ module Tradier
|
|
108
108
|
# Request a specific account's events.
|
109
109
|
# @param [String] account_number An account number (optional).
|
110
110
|
# @return [Array<Tradier::Event>] An array of [Tradier::Event] objects for a given account.
|
111
|
+
# @overload events(account_number, options)
|
112
|
+
# @option options [Integer] :limit Indicate the number of events to return for pagination.
|
113
|
+
# @option options [Integer] ;offset Indicate the offset of results to return for pagination.
|
111
114
|
# @raise [Tradier::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
112
115
|
def events(account_number=nil, options={})
|
113
116
|
if account_number
|
@@ -116,6 +119,7 @@ module Tradier
|
|
116
119
|
object_from_response(Tradier::API::Utils::Account, :get, '/user/history', options).body
|
117
120
|
end
|
118
121
|
end
|
122
|
+
alias :history :events
|
119
123
|
|
120
124
|
end
|
121
125
|
end
|
data/lib/tradier/api/markets.rb
CHANGED
@@ -112,6 +112,34 @@ module Tradier
|
|
112
112
|
object_from_response(Tradier::EventSession, :post, '/markets/events/session', options)
|
113
113
|
end
|
114
114
|
|
115
|
+
# @see https://developer.tradier.com/documentation/markets/get-search
|
116
|
+
# @rate_limited Yes
|
117
|
+
# @authentication Requires user context
|
118
|
+
# Search for a stock symbol using a keyword lookup.
|
119
|
+
# @param [String] q The company/index name to search for.
|
120
|
+
# @overload search(q, options)
|
121
|
+
# @option options [Boolean] :indexes Indicate whether or not to include indexes in results.
|
122
|
+
# @return [Array<Tradier::Security>] An array of search results.
|
123
|
+
# @raise [Tradier::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
124
|
+
def search(q, options={})
|
125
|
+
options.merge!('q' => q)
|
126
|
+
object_from_response(Tradier::API::Utils::Search, :get, '/markets/search', options).body
|
127
|
+
end
|
128
|
+
|
129
|
+
# @see https://developer.tradier.com/documentation/markets/get-lookup
|
130
|
+
# @rate_limited Yes
|
131
|
+
# @authentication Requires user context
|
132
|
+
# Lookup a symbol.
|
133
|
+
# @param [String] q The company/index name to search for.
|
134
|
+
# @overload lookup(q, options)
|
135
|
+
# @option options [Boolean] :indexes Indicate whether or not to include indexes in results.
|
136
|
+
# @return [Array<Tradier::Security>] An array of lookup results.
|
137
|
+
# @raise [Tradier::Error::Unauthorized] Error raised when supplied user credentials are not valid.
|
138
|
+
def lookup(q, options={})
|
139
|
+
options.merge!('q' => q)
|
140
|
+
object_from_response(Tradier::API::Utils::Search, :get, '/markets/lookup', options).body
|
141
|
+
end
|
142
|
+
|
115
143
|
private
|
116
144
|
|
117
145
|
def normalized_symbols(symbols)
|
data/lib/tradier/api/utils.rb
CHANGED
@@ -9,6 +9,7 @@ require 'tradier/order'
|
|
9
9
|
require 'tradier/position'
|
10
10
|
require 'tradier/profile'
|
11
11
|
require 'tradier/quote'
|
12
|
+
require 'tradier/security'
|
12
13
|
require 'tradier/timesales'
|
13
14
|
require 'tradier/watchlist'
|
14
15
|
require 'tradier/event'
|
@@ -23,6 +24,7 @@ require 'tradier/api/utils/option_quote'
|
|
23
24
|
require 'tradier/api/utils/order'
|
24
25
|
require 'tradier/api/utils/position'
|
25
26
|
require 'tradier/api/utils/quote'
|
27
|
+
require 'tradier/api/utils/search'
|
26
28
|
require 'tradier/api/utils/strike'
|
27
29
|
require 'tradier/api/utils/timesales'
|
28
30
|
require 'tradier/api/utils/watchlist'
|
data/lib/tradier/version.rb
CHANGED
@@ -0,0 +1,114 @@
|
|
1
|
+
{
|
2
|
+
"securities": {
|
3
|
+
"security": [
|
4
|
+
{
|
5
|
+
"symbol": "AAPL",
|
6
|
+
"exchange": "XNAS",
|
7
|
+
"type": "stock",
|
8
|
+
"description": "Apple Inc"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"symbol": "AA",
|
12
|
+
"exchange": "XNYS",
|
13
|
+
"type": "stock",
|
14
|
+
"description": "Alcoa Inc"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"symbol": "AAL",
|
18
|
+
"exchange": "XNAS",
|
19
|
+
"type": "stock",
|
20
|
+
"description": "American Airlines Group Inc"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"symbol": "AAN",
|
24
|
+
"exchange": "XNYS",
|
25
|
+
"type": "stock",
|
26
|
+
"description": "Aaron's Inc"
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"symbol": "AAP",
|
30
|
+
"exchange": "XNYS",
|
31
|
+
"type": "stock",
|
32
|
+
"description": "Advance Auto Parts Inc"
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"symbol": "AAXJ",
|
36
|
+
"exchange": "XNAS",
|
37
|
+
"type": "etf",
|
38
|
+
"description": "iShares MSCI All Country Asia ex Japan Index Fund"
|
39
|
+
},
|
40
|
+
{
|
41
|
+
"symbol": "AAVL",
|
42
|
+
"exchange": "XNAS",
|
43
|
+
"type": "stock",
|
44
|
+
"description": "Avalanche Biotechnologies Inc"
|
45
|
+
},
|
46
|
+
{
|
47
|
+
"symbol": "AAOI",
|
48
|
+
"exchange": "XNAS",
|
49
|
+
"type": "stock",
|
50
|
+
"description": "Applied Optoelectronics Inc"
|
51
|
+
},
|
52
|
+
{
|
53
|
+
"symbol": "AAWW",
|
54
|
+
"exchange": "XNAS",
|
55
|
+
"type": "stock",
|
56
|
+
"description": "Atlas Air Worldwide Holdings Inc"
|
57
|
+
},
|
58
|
+
{
|
59
|
+
"symbol": "AAON",
|
60
|
+
"exchange": "XNAS",
|
61
|
+
"type": "stock",
|
62
|
+
"description": "AAON Inc"
|
63
|
+
},
|
64
|
+
{
|
65
|
+
"symbol": "AAT",
|
66
|
+
"exchange": "XNYS",
|
67
|
+
"type": "stock",
|
68
|
+
"description": "American Assets Trust Inc"
|
69
|
+
},
|
70
|
+
{
|
71
|
+
"symbol": "AAME",
|
72
|
+
"exchange": "XNAS",
|
73
|
+
"type": "stock",
|
74
|
+
"description": "Atlantic American Corp"
|
75
|
+
},
|
76
|
+
{
|
77
|
+
"symbol": "AADR",
|
78
|
+
"exchange": "ARCX",
|
79
|
+
"type": "etf",
|
80
|
+
"description": "WCM BNY Mellon Focused Growth ADR ETF"
|
81
|
+
},
|
82
|
+
{
|
83
|
+
"symbol": "AAIT",
|
84
|
+
"exchange": "XNAS",
|
85
|
+
"type": "etf",
|
86
|
+
"description": "iShares MSCI All Country Asia Information Technology Index Fund"
|
87
|
+
},
|
88
|
+
{
|
89
|
+
"symbol": "AAMC",
|
90
|
+
"exchange": "XASE",
|
91
|
+
"type": "stock",
|
92
|
+
"description": "Altisource Asset Management Corp Com"
|
93
|
+
},
|
94
|
+
{
|
95
|
+
"symbol": "AAp",
|
96
|
+
"exchange": "XASE",
|
97
|
+
"type": "stock",
|
98
|
+
"description": "Alcoa Inc. $3.75 Preferred Stock"
|
99
|
+
},
|
100
|
+
{
|
101
|
+
"symbol": "AAU",
|
102
|
+
"exchange": "XASE",
|
103
|
+
"type": "stock",
|
104
|
+
"description": "Almaden Minerals, Ltd. Ordinary Shares (Canada)"
|
105
|
+
},
|
106
|
+
{
|
107
|
+
"symbol": "AAV",
|
108
|
+
"exchange": "XNYS",
|
109
|
+
"type": "stock",
|
110
|
+
"description": "Advantage Oil & Gas Ltd Ordinary Shares"
|
111
|
+
}
|
112
|
+
]
|
113
|
+
}
|
114
|
+
}
|
@@ -0,0 +1,54 @@
|
|
1
|
+
{
|
2
|
+
"securities": {
|
3
|
+
"security": [
|
4
|
+
{
|
5
|
+
"symbol": "AAPL",
|
6
|
+
"exchange": "XNAS",
|
7
|
+
"type": "stock",
|
8
|
+
"description": "Apple Inc"
|
9
|
+
},
|
10
|
+
{
|
11
|
+
"symbol": "AMAT",
|
12
|
+
"exchange": "XNAS",
|
13
|
+
"type": "stock",
|
14
|
+
"description": "Applied Materials Inc"
|
15
|
+
},
|
16
|
+
{
|
17
|
+
"symbol": "AMCC",
|
18
|
+
"exchange": "XNAS",
|
19
|
+
"type": "stock",
|
20
|
+
"description": "Applied Micro Circuits Corp"
|
21
|
+
},
|
22
|
+
{
|
23
|
+
"symbol": "AREX",
|
24
|
+
"exchange": "XNAS",
|
25
|
+
"type": "stock",
|
26
|
+
"description": "Approach Resources Inc"
|
27
|
+
},
|
28
|
+
{
|
29
|
+
"symbol": "AAOI",
|
30
|
+
"exchange": "XNAS",
|
31
|
+
"type": "stock",
|
32
|
+
"description": "Applied Optoelectronics Inc"
|
33
|
+
},
|
34
|
+
{
|
35
|
+
"symbol": "AIT",
|
36
|
+
"exchange": "XNYS",
|
37
|
+
"type": "stock",
|
38
|
+
"description": "Applied Industrial Technologies Inc"
|
39
|
+
},
|
40
|
+
{
|
41
|
+
"symbol": "AGTC",
|
42
|
+
"exchange": "XNAS",
|
43
|
+
"type": "stock",
|
44
|
+
"description": "Applied Genetic Technologies Corp"
|
45
|
+
},
|
46
|
+
{
|
47
|
+
"symbol": "ARCI",
|
48
|
+
"exchange": "XNAS",
|
49
|
+
"type": "stock",
|
50
|
+
"description": "Appliance Recycling Centers Of America Inc"
|
51
|
+
}
|
52
|
+
]
|
53
|
+
}
|
54
|
+
}
|
@@ -190,6 +190,16 @@ describe Tradier::API::Accounts do
|
|
190
190
|
expect(events.first).to be_a Tradier::Account
|
191
191
|
end
|
192
192
|
end
|
193
|
+
context 'with pagination' do
|
194
|
+
before do
|
195
|
+
stub_get("/v1/accounts/123456789/history?limit=12&offset=2").
|
196
|
+
to_return(:body => fixture("account_history.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
197
|
+
end
|
198
|
+
it "requests the correct resource" do
|
199
|
+
@client.events("123456789", :limit => 12, :offset => 2)
|
200
|
+
expect(a_get("/v1/accounts/123456789/history?limit=12&offset=2")).to have_been_made
|
201
|
+
end
|
202
|
+
end
|
193
203
|
end
|
194
204
|
|
195
205
|
end
|
@@ -255,4 +255,42 @@ describe Tradier::API::Markets do
|
|
255
255
|
expect(session).to be_a Tradier::EventSession
|
256
256
|
end
|
257
257
|
end
|
258
|
+
|
259
|
+
describe '#search' do
|
260
|
+
before do
|
261
|
+
stub_get("/v1/markets/search").
|
262
|
+
with(:query => { :q => 'App'}).
|
263
|
+
to_return(:body => fixture("search.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
264
|
+
end
|
265
|
+
|
266
|
+
it "requests the correct resource" do
|
267
|
+
@client.search('App')
|
268
|
+
expect(a_get("/v1/markets/search?q=App")).to have_been_made
|
269
|
+
end
|
270
|
+
|
271
|
+
it "returns an array of Tradier::Security objects" do
|
272
|
+
results = @client.search('App')
|
273
|
+
expect(results).to be_an Array
|
274
|
+
expect(results.first).to be_a Tradier::Security
|
275
|
+
end
|
276
|
+
end
|
277
|
+
|
278
|
+
describe '#lookup' do
|
279
|
+
before do
|
280
|
+
stub_get("/v1/markets/lookup").
|
281
|
+
with(:query => { :q => 'AA'}).
|
282
|
+
to_return(:body => fixture("lookup.json"), :headers => {:content_type => "application/json; charset=utf-8"})
|
283
|
+
end
|
284
|
+
|
285
|
+
it "requests the correct resource" do
|
286
|
+
@client.lookup('AA')
|
287
|
+
expect(a_get("/v1/markets/lookup?q=AA")).to have_been_made
|
288
|
+
end
|
289
|
+
|
290
|
+
it "returns an array of Tradier::Security objects" do
|
291
|
+
results = @client.lookup('AA')
|
292
|
+
expect(results).to be_an Array
|
293
|
+
expect(results.first).to be_a Tradier::Security
|
294
|
+
end
|
295
|
+
end
|
258
296
|
end
|
data/spec/tradier/client_spec.rb
CHANGED
@@ -116,8 +116,8 @@ describe Tradier::Client do
|
|
116
116
|
subject.stub(:connection).and_raise(Faraday::Error::ClientError.new("Oops"))
|
117
117
|
expect{subject.send(:request, :get, "/path")}.to raise_error Tradier::Error::ClientError
|
118
118
|
end
|
119
|
-
it "catches MultiJson::
|
120
|
-
subject.stub(:connection).and_raise(MultiJson::
|
119
|
+
it "catches MultiJson::ParseError errors" do
|
120
|
+
subject.stub(:connection).and_raise(MultiJson::ParseError.build(ArgumentError.new, "<!DOCTYPE html>"))
|
121
121
|
expect{subject.send(:request, :get, "/path")}.to raise_error Tradier::Error::DecodeError
|
122
122
|
end
|
123
123
|
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.
|
4
|
+
version: 0.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Steve Agalloco
|
@@ -9,62 +9,62 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2014-
|
12
|
+
date: 2014-09-05 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: faraday
|
16
16
|
requirement: !ruby/object:Gem::Requirement
|
17
17
|
requirements:
|
18
|
-
- - ~>
|
18
|
+
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
20
|
version: '0.8'
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - ~>
|
25
|
+
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
version: '0.8'
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: faraday_middleware
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- -
|
32
|
+
- - ">="
|
33
33
|
- !ruby/object:Gem::Version
|
34
34
|
version: '0'
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- -
|
39
|
+
- - ">="
|
40
40
|
- !ruby/object:Gem::Version
|
41
41
|
version: '0'
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: celluloid
|
44
44
|
requirement: !ruby/object:Gem::Requirement
|
45
45
|
requirements:
|
46
|
-
- -
|
46
|
+
- - ">="
|
47
47
|
- !ruby/object:Gem::Version
|
48
48
|
version: '0'
|
49
49
|
type: :runtime
|
50
50
|
prerelease: false
|
51
51
|
version_requirements: !ruby/object:Gem::Requirement
|
52
52
|
requirements:
|
53
|
-
- -
|
53
|
+
- - ">="
|
54
54
|
- !ruby/object:Gem::Version
|
55
55
|
version: '0'
|
56
56
|
- !ruby/object:Gem::Dependency
|
57
57
|
name: bundler
|
58
58
|
requirement: !ruby/object:Gem::Requirement
|
59
59
|
requirements:
|
60
|
-
- - ~>
|
60
|
+
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
62
|
version: '1'
|
63
63
|
type: :development
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
|
-
- - ~>
|
67
|
+
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
69
|
version: '1'
|
70
70
|
description: Rubygem for interacting with the Tradier API.
|
@@ -75,7 +75,7 @@ executables: []
|
|
75
75
|
extensions: []
|
76
76
|
extra_rdoc_files: []
|
77
77
|
files:
|
78
|
-
- .yardopts
|
78
|
+
- ".yardopts"
|
79
79
|
- LICENSE.md
|
80
80
|
- README.md
|
81
81
|
- Rakefile
|
@@ -97,6 +97,7 @@ files:
|
|
97
97
|
- lib/tradier/api/utils/order.rb
|
98
98
|
- lib/tradier/api/utils/position.rb
|
99
99
|
- lib/tradier/api/utils/quote.rb
|
100
|
+
- lib/tradier/api/utils/search.rb
|
100
101
|
- lib/tradier/api/utils/strike.rb
|
101
102
|
- lib/tradier/api/utils/timesales.rb
|
102
103
|
- lib/tradier/api/utils/watchlist.rb
|
@@ -137,6 +138,7 @@ files:
|
|
137
138
|
- lib/tradier/quote.rb
|
138
139
|
- lib/tradier/response/parse_json.rb
|
139
140
|
- lib/tradier/response/raise_error.rb
|
141
|
+
- lib/tradier/security.rb
|
140
142
|
- lib/tradier/symbol.rb
|
141
143
|
- lib/tradier/timesales.rb
|
142
144
|
- lib/tradier/version.rb
|
@@ -153,6 +155,7 @@ files:
|
|
153
155
|
- spec/fixtures/expirations.json
|
154
156
|
- spec/fixtures/expirations_with_strikes.json
|
155
157
|
- spec/fixtures/history.json
|
158
|
+
- spec/fixtures/lookup.json
|
156
159
|
- spec/fixtures/option_quote.json
|
157
160
|
- spec/fixtures/option_quotes.json
|
158
161
|
- spec/fixtures/order.json
|
@@ -160,6 +163,7 @@ files:
|
|
160
163
|
- spec/fixtures/placed_order.json
|
161
164
|
- spec/fixtures/quote.json
|
162
165
|
- spec/fixtures/quotes.json
|
166
|
+
- spec/fixtures/search.json
|
163
167
|
- spec/fixtures/session.json
|
164
168
|
- spec/fixtures/strikes.json
|
165
169
|
- spec/fixtures/timesales.json
|
@@ -208,12 +212,12 @@ require_paths:
|
|
208
212
|
- lib
|
209
213
|
required_ruby_version: !ruby/object:Gem::Requirement
|
210
214
|
requirements:
|
211
|
-
- -
|
215
|
+
- - ">="
|
212
216
|
- !ruby/object:Gem::Version
|
213
217
|
version: '0'
|
214
218
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
215
219
|
requirements:
|
216
|
-
- -
|
220
|
+
- - ">="
|
217
221
|
- !ruby/object:Gem::Version
|
218
222
|
version: '0'
|
219
223
|
requirements: []
|
@@ -234,6 +238,7 @@ test_files:
|
|
234
238
|
- spec/fixtures/expirations.json
|
235
239
|
- spec/fixtures/expirations_with_strikes.json
|
236
240
|
- spec/fixtures/history.json
|
241
|
+
- spec/fixtures/lookup.json
|
237
242
|
- spec/fixtures/option_quote.json
|
238
243
|
- spec/fixtures/option_quotes.json
|
239
244
|
- spec/fixtures/order.json
|
@@ -241,6 +246,7 @@ test_files:
|
|
241
246
|
- spec/fixtures/placed_order.json
|
242
247
|
- spec/fixtures/quote.json
|
243
248
|
- spec/fixtures/quotes.json
|
249
|
+
- spec/fixtures/search.json
|
244
250
|
- spec/fixtures/session.json
|
245
251
|
- spec/fixtures/strikes.json
|
246
252
|
- spec/fixtures/timesales.json
|