questrade_api 1.0.0 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +3 -0
- data/Gemfile +1 -3
- data/README.md +34 -4
- data/lib/questrade_api/modules/market_call.rb +7 -0
- data/lib/questrade_api/version.rb +1 -1
- data/spec/questrade_api/modules/market_call_spec.rb +7 -0
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b4ce5fe5a4b01f8455e79cb80476d4426c1e9530
|
4
|
+
data.tar.gz: 747bd6e4053f03cc36ead638ceecd27baf5cc80e
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4cea9d006d79006b2af8c8f2093d480e347118c79243ab295705bd9ed3eb9983bebdc59c53e4398db2c5507d9d1f1efc95ee3222d2bf149d8faad688d7fd05da
|
7
|
+
data.tar.gz: beaa6a59a7f869a3a38daa96dc2b7ed81a239b26dfb97f9c82a5e7aff71bb77d6b5493aae686ceb3eb1b1c18611287375b1aa6c4c88342ba453de9f1b9aaffd2
|
data/.travis.yml
CHANGED
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -1,3 +1,4 @@
|
|
1
|
+
[![Gem Version](https://badge.fury.io/rb/questrade_api.svg)](https://badge.fury.io/rb/questrade_api)
|
1
2
|
[![Build Status](https://travis-ci.org/brunomeira/questrade_api.svg?branch=master)](https://travis-ci.org/brunomeira/questrade_api)
|
2
3
|
[![Code Climate](https://codeclimate.com/github/brunomeira/questrade_api/badges/gpa.svg)](https://codeclimate.com/github/brunomeira/questrade_api)
|
3
4
|
|
@@ -19,14 +20,31 @@ gem 'questrade_api'
|
|
19
20
|
$ bundle
|
20
21
|
```
|
21
22
|
- Follow the tutorial on <http://www.questrade.com/api/documentation/getting-started> to generate a refresh token
|
22
|
-
|
23
|
+
|
24
|
+
### Authorization
|
25
|
+
|
26
|
+
- After getting the refresh token from Questrade, you are now ready to ask for an access token. In order to fetch an access token, copy the snippet of code below and replace the example token with your refresh token.
|
23
27
|
|
24
28
|
```ruby
|
25
29
|
# By default this API calls the practice(demo) endpoint.
|
26
|
-
# Check our documentation to learn how to call the live endpoint.
|
27
30
|
client = QuestradeApi::Client.new(refresh_token: 'XXXX')
|
31
|
+
|
32
|
+
# If you want to call the live platform you need to pass :live as a parameter. Ex:
|
33
|
+
client = QuestradeApi::Client.new(refresh_token: 'XXXX', :live)
|
34
|
+
|
35
|
+
# Both calls automatically ask for a new access token
|
36
|
+
|
37
|
+
|
38
|
+
# In case you already have an access token and a api_server, you can instead use:
|
39
|
+
client = QuestradeApi::Client.new(access_token: 'XXXX', api_server: 'XXXX', :live)
|
40
|
+
|
41
|
+
# To ask for a new access token(Questrade invalidates tokens every 30 mins), simply call:
|
42
|
+
client.refresh_token # Make sure client has a valid refresh_token
|
28
43
|
```
|
29
|
-
|
44
|
+
|
45
|
+
### Some examples:
|
46
|
+
|
47
|
+
- After fetching a valid access token, you are now ready to use the API. Below you can find a few examples of the calls you can make with the gem.
|
30
48
|
|
31
49
|
```ruby
|
32
50
|
# Get Questrade's current server time
|
@@ -44,18 +62,30 @@ client.positions('account_id')
|
|
44
62
|
# Activities of an specific period of time for an specific account
|
45
63
|
client.activities('account_id', startTime: DateTime.yesterday.to_s, endTime: DateTime.now.to_s)
|
46
64
|
|
65
|
+
# Symbol by ID
|
66
|
+
client.symbol('id')
|
67
|
+
|
47
68
|
# Symbols by name
|
48
69
|
client.symbols(names: ['AAPL'])
|
49
70
|
|
50
71
|
# Search symbols by prefix
|
51
72
|
client.search_symbols(prefix: 'BMO')
|
52
73
|
|
74
|
+
# List of quotes
|
75
|
+
client.quotes(['123', '456'])
|
76
|
+
|
77
|
+
# Quote details
|
78
|
+
client.quote('123')
|
79
|
+
|
80
|
+
# Historical Market in candlestick format
|
81
|
+
client.candles('123', startTime: DateTime.yesterday.to_s, endTime: DateTime.now.to_s)
|
82
|
+
|
53
83
|
# In case you already have a valid access token and its respective URL, you can use the QuestradeApi::REST objects. Example:
|
54
84
|
# authorization can be any object that responds to url and access_token
|
55
85
|
authorization = QuestradeApi::Authorization.new(access_token: 'access_token', api_server: 'url')
|
56
86
|
accounts = QuestradeApi::REST::Account.fetch(accounts)
|
57
87
|
```
|
58
|
-
For more advanced options, check out our [documentation](http://www.rubydoc.info/gems/questrade_api/0.0
|
88
|
+
For more advanced options, check out our [documentation](http://www.rubydoc.info/gems/questrade_api/1.0.0).
|
59
89
|
|
60
90
|
## Current Status
|
61
91
|
|
@@ -14,6 +14,13 @@ module QuestradeApi
|
|
14
14
|
QuestradeApi::REST::Symbol.fetch(authorization, params)
|
15
15
|
end
|
16
16
|
|
17
|
+
def symbol(id)
|
18
|
+
symbol = QuestradeApi::REST::Symbol.new(authorization, id: id)
|
19
|
+
symbol.fetch
|
20
|
+
|
21
|
+
symbol
|
22
|
+
end
|
23
|
+
|
17
24
|
def search_symbols(params)
|
18
25
|
QuestradeApi::REST::Symbol.search(authorization, params)
|
19
26
|
end
|
@@ -31,6 +31,13 @@ describe QuestradeApi::MarketCall do
|
|
31
31
|
end
|
32
32
|
end
|
33
33
|
|
34
|
+
context '.symbol' do
|
35
|
+
it 'calls proper endpoint' do
|
36
|
+
expect_any_instance_of(QuestradeApi::REST::Symbol).to receive(:fetch).and_return([])
|
37
|
+
expect(subject.symbol('1')).to be_a(QuestradeApi::REST::Symbol)
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
34
41
|
context '.search_symbols' do
|
35
42
|
it 'calls proper endpoint' do
|
36
43
|
expect(QuestradeApi::REST::Symbol).to receive(:search).and_return([])
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: questrade_api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Bruno Meira
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rspec
|
@@ -157,7 +157,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
157
157
|
version: '0'
|
158
158
|
requirements: []
|
159
159
|
rubyforge_project:
|
160
|
-
rubygems_version: 2.
|
160
|
+
rubygems_version: 2.6.10
|
161
161
|
signing_key:
|
162
162
|
specification_version: 4
|
163
163
|
summary: An elegant Ruby gem to interact with Questrade API
|