tinkoff_invest 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 6b76203ef34ccc6f4ebb178af733d5c635ddf08c86ee4bea1ab0a65935feb3d6
4
+ data.tar.gz: 9dbe6248102aa80b2506be2386f3936d00943827e5b2d1e399b0e0ae05c54fca
5
+ SHA512:
6
+ metadata.gz: 22a9bcccc3d84da177bcfd5864a882e7bdaf63f0720c520807c905f35b66bc2366f1a6365ccefbe554e399bf6379387e5008b164f87681688bc0099225c44d1a
7
+ data.tar.gz: '08ebb3db7f6ba030cfe0b7f2b49d5a30bae40932d17934c92a6ca9cc9eef8073e746ab2dfb68c8acfd60bcb17a21aec234a41aa807f5fbe6a833fc8e02c022cd'
@@ -0,0 +1,11 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ # rspec failure tracking
11
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --require spec_helper
2
+ --format documentation
3
+ --color
@@ -0,0 +1,191 @@
1
+ require:
2
+ - rubocop-performance
3
+ - rubocop-rspec
4
+
5
+ AllCops:
6
+ Exclude:
7
+ - 'bin/*'
8
+ NewCops: enable
9
+
10
+ # Commonly used screens these days easily fit more than 80 characters.
11
+ Layout/LineLength:
12
+ Max: 120
13
+
14
+ # Too short methods lead to extraction of single-use methods, which can make
15
+ # the code easier to read (by naming things), but can also clutter the class
16
+ Metrics/MethodLength:
17
+ Max: 20
18
+
19
+ # The guiding principle of classes is SRP, SRP can't be accurately measured by LoC
20
+ Metrics/ClassLength:
21
+ Max: 1500
22
+
23
+ # No space makes the method definition shorter and differentiates
24
+ # from a regular assignment.
25
+ Layout/SpaceAroundEqualsInParameterDefault:
26
+ EnforcedStyle: no_space
27
+
28
+ # Single quotes being faster is hardly measurable and only affects parse time.
29
+ # Enforcing double quotes reduces the times where you need to change them
30
+ # when introducing an interpolation. Use single quotes only if their semantics
31
+ # are needed.
32
+ Style/StringLiterals:
33
+ EnforcedStyle: single_quotes
34
+
35
+ # We do not need to support Ruby 1.9, so this is good to use.
36
+ Style/SymbolArray:
37
+ Enabled: true
38
+
39
+ # Most readable form.
40
+ Layout/HashAlignment:
41
+ EnforcedHashRocketStyle: table
42
+ EnforcedColonStyle: table
43
+
44
+ # Mixing the styles looks just silly.
45
+ Style/HashSyntax:
46
+ EnforcedStyle: ruby19_no_mixed_keys
47
+
48
+ # has_key? and has_value? are far more readable than key? and value?
49
+ Style/PreferredHashMethods:
50
+ Enabled: false
51
+
52
+ # String#% is by far the least verbose and only object oriented variant.
53
+ Style/FormatString:
54
+ EnforcedStyle: percent
55
+
56
+ Style/CollectionMethods:
57
+ Enabled: true
58
+ PreferredMethods:
59
+ # inject seems more common in the community.
60
+ reduce: 'inject'
61
+
62
+ # Either allow this style or don't. Marking it as safe with parenthesis
63
+ # is silly. Let's try to live without them for now.
64
+ Style/ParenthesesAroundCondition:
65
+ AllowSafeAssignment: false
66
+ Lint/AssignmentInCondition:
67
+ AllowSafeAssignment: false
68
+
69
+ # A specialized exception class will take one or more arguments and construct the message from it.
70
+ # So both variants make sense.
71
+ Style/RaiseArgs:
72
+ Enabled: false
73
+
74
+ # Indenting the chained dots beneath each other is not supported by this cop,
75
+ # see https://github.com/bbatsov/rubocop/issues/1633
76
+ Layout/MultilineOperationIndentation:
77
+ Enabled: false
78
+
79
+ Layout/FirstHashElementIndentation:
80
+ EnforcedStyle: consistent
81
+
82
+ # Fail is an alias of raise. Avoid aliases, it's more cognitive load for no gain.
83
+ # The argument that fail should be used to abort the program is wrong too,
84
+ # there's Kernel#abort for that.
85
+ Style/SignalException:
86
+ EnforcedStyle: only_raise
87
+
88
+ # Suppressing exceptions can be perfectly fine, and be it to avoid to
89
+ # explicitly type nil into the rescue since that's what you want to return,
90
+ # or suppressing LoadError for optional dependencies
91
+ Lint/SuppressedException:
92
+ Enabled: false
93
+
94
+ # Layout/SpaceInsideBlockBraces:
95
+ # # The space here provides no real gain in readability while consuming
96
+ # # horizontal space that could be used for a better parameter name.
97
+ # # Also {| differentiates better from a hash than { | does.
98
+ # SpaceBeforeBlockParameters: false
99
+
100
+ # No trailing space differentiates better from the block:
101
+ # foo} means hash, foo } means block.
102
+ Layout/SpaceInsideHashLiteralBraces:
103
+ EnforcedStyle: space
104
+
105
+ # { ... } for multi-line blocks is okay, follow Weirichs rule instead:
106
+ # https://web.archive.org/web/20140221124509/http://onestepback.org/index.cgi/Tech/Ruby/BraceVsDoEnd.rdoc
107
+ Style/BlockDelimiters:
108
+ Enabled: false
109
+
110
+ # do / end blocks should be used for side effects,
111
+ # methods that run a block for side effects and have
112
+ # a useful return value are rare, assign the return
113
+ # value to a local variable for those cases.
114
+ Style/MethodCalledOnDoEndBlock:
115
+ Enabled: true
116
+
117
+ # Enforcing the names of variables? To single letter ones? Just no.
118
+ Style/SingleLineBlockParams:
119
+ Enabled: false
120
+
121
+ # Shadowing outer local variables with block parameters is often useful
122
+ # to not reinvent a new name for the same thing, it highlights the relation
123
+ # between the outer variable and the parameter. The cases where it's actually
124
+ # confusing are rare, and usually bad for other reasons already, for example
125
+ # because the method is too long.
126
+ Lint/ShadowingOuterLocalVariable:
127
+ Enabled: false
128
+
129
+ # Check with yard instead.
130
+ Style/Documentation:
131
+ Enabled: false
132
+
133
+ # This is just silly. Calling the argument `other` in all cases makes no sense.
134
+ Naming/BinaryOperatorParameterName:
135
+ Enabled: false
136
+
137
+ Naming/MethodParameterName:
138
+ AllowedNames:
139
+ - ad
140
+ - id
141
+
142
+ # There are valid cases, for example debugging Cucumber steps,
143
+ # also they'll fail CI anyway
144
+ Lint/Debugger:
145
+ Enabled: false
146
+
147
+ # Style preference
148
+ Style/MethodDefParentheses:
149
+ Enabled: false
150
+
151
+ Style/IfUnlessModifier:
152
+ Enabled: false
153
+
154
+ Metrics/BlockLength:
155
+ Exclude:
156
+ - 'spec/**/*'
157
+
158
+ RSpec/NestedGroups:
159
+ Max: 6
160
+
161
+ RSpec/ContextWording:
162
+ Prefixes:
163
+ - when
164
+ - with
165
+ - without
166
+ - and
167
+ - if
168
+ - in
169
+ - for
170
+
171
+ RSpec/ExampleLength:
172
+ Max: 20
173
+
174
+ # Hanami::Interactor::Result expose are not verifiable
175
+ RSpec/VerifiedDoubles:
176
+ Enabled: false
177
+
178
+ Layout/MultilineMethodCallIndentation:
179
+ Enabled: false
180
+
181
+ Layout/EndAlignment:
182
+ EnforcedStyleAlignWith: variable
183
+
184
+ Style/FormatStringToken:
185
+ EnforcedStyle: template
186
+
187
+ Layout/CaseIndentation:
188
+ EnforcedStyle: end
189
+
190
+ RSpec/ImplicitSubject:
191
+ EnforcedStyle: single_statement_only
@@ -0,0 +1 @@
1
+ 2.7.2
@@ -0,0 +1,6 @@
1
+ ---
2
+ language: ruby
3
+ cache: bundler
4
+ rvm:
5
+ - 2.7.2
6
+ before_install: gem install bundler -v 2.1.4
@@ -0,0 +1,10 @@
1
+ # Changelog
2
+ All notable changes to this project will be documented in this file.
3
+
4
+ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
5
+ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
6
+
7
+ ## [0.2.0] - 2020-11-19
8
+ ### Added
9
+ - Start project
10
+ - Market endpoints
@@ -0,0 +1,74 @@
1
+ # Contributor Covenant Code of Conduct
2
+
3
+ ## Our Pledge
4
+
5
+ In the interest of fostering an open and welcoming environment, we as
6
+ contributors and maintainers pledge to making participation in our project and
7
+ our community a harassment-free experience for everyone, regardless of age, body
8
+ size, disability, ethnicity, gender identity and expression, level of experience,
9
+ nationality, personal appearance, race, religion, or sexual identity and
10
+ orientation.
11
+
12
+ ## Our Standards
13
+
14
+ Examples of behavior that contributes to creating a positive environment
15
+ include:
16
+
17
+ * Using welcoming and inclusive language
18
+ * Being respectful of differing viewpoints and experiences
19
+ * Gracefully accepting constructive criticism
20
+ * Focusing on what is best for the community
21
+ * Showing empathy towards other community members
22
+
23
+ Examples of unacceptable behavior by participants include:
24
+
25
+ * The use of sexualized language or imagery and unwelcome sexual attention or
26
+ advances
27
+ * Trolling, insulting/derogatory comments, and personal or political attacks
28
+ * Public or private harassment
29
+ * Publishing others' private information, such as a physical or electronic
30
+ address, without explicit permission
31
+ * Other conduct which could reasonably be considered inappropriate in a
32
+ professional setting
33
+
34
+ ## Our Responsibilities
35
+
36
+ Project maintainers are responsible for clarifying the standards of acceptable
37
+ behavior and are expected to take appropriate and fair corrective action in
38
+ response to any instances of unacceptable behavior.
39
+
40
+ Project maintainers have the right and responsibility to remove, edit, or
41
+ reject comments, commits, code, wiki edits, issues, and other contributions
42
+ that are not aligned to this Code of Conduct, or to ban temporarily or
43
+ permanently any contributor for other behaviors that they deem inappropriate,
44
+ threatening, offensive, or harmful.
45
+
46
+ ## Scope
47
+
48
+ This Code of Conduct applies both within project spaces and in public spaces
49
+ when an individual is representing the project or its community. Examples of
50
+ representing a project or community include using an official project e-mail
51
+ address, posting via an official social media account, or acting as an appointed
52
+ representative at an online or offline event. Representation of a project may be
53
+ further defined and clarified by project maintainers.
54
+
55
+ ## Enforcement
56
+
57
+ Instances of abusive, harassing, or otherwise unacceptable behavior may be
58
+ reported by contacting the project team at kortirso@gmail.com. All
59
+ complaints will be reviewed and investigated and will result in a response that
60
+ is deemed necessary and appropriate to the circumstances. The project team is
61
+ obligated to maintain confidentiality with regard to the reporter of an incident.
62
+ Further details of specific enforcement policies may be posted separately.
63
+
64
+ Project maintainers who do not follow or enforce the Code of Conduct in good
65
+ faith may face temporary or permanent repercussions as determined by other
66
+ members of the project's leadership.
67
+
68
+ ## Attribution
69
+
70
+ This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4,
71
+ available at [https://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: https://contributor-covenant.org
74
+ [version]: https://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,11 @@
1
+ # frozen_string_literal: true
2
+
3
+ source 'https://rubygems.org'
4
+
5
+ git_source(:github) { |repo_name| "https://github.com/#{repo_name}" }
6
+
7
+ group :test do
8
+ gem 'rspec'
9
+ end
10
+
11
+ gemspec
@@ -0,0 +1,75 @@
1
+ PATH
2
+ remote: .
3
+ specs:
4
+ tinkoff_invest (0.1.0)
5
+ dry-initializer (~> 3.0)
6
+ faraday (~> 1.1)
7
+ faraday_middleware (~> 1.0)
8
+
9
+ GEM
10
+ remote: https://rubygems.org/
11
+ specs:
12
+ ast (2.4.1)
13
+ diff-lcs (1.4.4)
14
+ dry-initializer (3.0.4)
15
+ faraday (1.1.0)
16
+ multipart-post (>= 1.2, < 3)
17
+ ruby2_keywords
18
+ faraday_middleware (1.0.0)
19
+ faraday (~> 1.0)
20
+ multipart-post (2.1.1)
21
+ parallel (1.20.0)
22
+ parser (2.7.2.0)
23
+ ast (~> 2.4.1)
24
+ rainbow (3.0.0)
25
+ rake (13.0.1)
26
+ regexp_parser (1.8.2)
27
+ rexml (3.2.4)
28
+ rspec (3.10.0)
29
+ rspec-core (~> 3.10.0)
30
+ rspec-expectations (~> 3.10.0)
31
+ rspec-mocks (~> 3.10.0)
32
+ rspec-core (3.10.0)
33
+ rspec-support (~> 3.10.0)
34
+ rspec-expectations (3.10.0)
35
+ diff-lcs (>= 1.2.0, < 2.0)
36
+ rspec-support (~> 3.10.0)
37
+ rspec-mocks (3.10.0)
38
+ diff-lcs (>= 1.2.0, < 2.0)
39
+ rspec-support (~> 3.10.0)
40
+ rspec-support (3.10.0)
41
+ rubocop (1.3.1)
42
+ parallel (~> 1.10)
43
+ parser (>= 2.7.1.5)
44
+ rainbow (>= 2.2.2, < 4.0)
45
+ regexp_parser (>= 1.8)
46
+ rexml
47
+ rubocop-ast (>= 1.1.1)
48
+ ruby-progressbar (~> 1.7)
49
+ unicode-display_width (>= 1.4.0, < 2.0)
50
+ rubocop-ast (1.1.1)
51
+ parser (>= 2.7.1.5)
52
+ rubocop-performance (1.9.0)
53
+ rubocop (>= 0.90.0, < 2.0)
54
+ rubocop-ast (>= 0.4.0)
55
+ rubocop-rspec (2.0.0)
56
+ rubocop (~> 1.0)
57
+ rubocop-ast (>= 1.1.0)
58
+ ruby-progressbar (1.10.1)
59
+ ruby2_keywords (0.0.2)
60
+ unicode-display_width (1.7.0)
61
+
62
+ PLATFORMS
63
+ ruby
64
+
65
+ DEPENDENCIES
66
+ bundler (~> 2.1.4)
67
+ rake (~> 13.0)
68
+ rspec
69
+ rubocop (~> 1.3)
70
+ rubocop-performance (~> 1.8)
71
+ rubocop-rspec (~> 2.0)
72
+ tinkoff_invest!
73
+
74
+ BUNDLED WITH
75
+ 2.1.4
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2020 kortirso
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in
13
+ all copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21
+ THE SOFTWARE.
@@ -0,0 +1,97 @@
1
+ # TinkoffApi
2
+
3
+ Welcome to your new gem! In this directory, you'll find the files you need to be able to package up your Ruby library into a gem. Put your Ruby code in the file `lib/tinkoff_invest`. To experiment with that code, run `bin/console` for an interactive prompt.
4
+
5
+ TODO: Delete this and the text above, and describe your gem
6
+
7
+ ## Installation
8
+
9
+ Add this line to your application's Gemfile:
10
+
11
+ ```ruby
12
+ gem 'tinkoff_invest'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle install
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install tinkoff_invest
22
+
23
+ ## Usage
24
+
25
+ Create client object.
26
+
27
+ ```ruby
28
+ require 'tinkoff_invest'
29
+ service = TinkoffInvest::V1::Client.new(token: 'token', sandbox: false)
30
+ ```
31
+
32
+ ### Stocks
33
+
34
+ Request for getting stocks list.
35
+
36
+ ```ruby
37
+ service.stocks
38
+ ```
39
+
40
+ ### Bonds
41
+
42
+ Request for getting bonds list.
43
+
44
+ ```ruby
45
+ service.bonds
46
+ ```
47
+
48
+ ### Foundations
49
+
50
+ Request for getting foundations list.
51
+
52
+ ```ruby
53
+ service.etfs
54
+ ```
55
+
56
+ ### Search by ticker
57
+
58
+ Request for getting security by ticker.
59
+
60
+ ```ruby
61
+ service.search_by_ticker(ticker: 'ticker')
62
+ ```
63
+
64
+ ### Search by FIGI
65
+
66
+ Request for getting security by FIGI.
67
+
68
+ ```ruby
69
+ service.search_by_figi(figi: 'figi')
70
+ ```
71
+
72
+ ### Orderbook
73
+
74
+ Request for getting security's orderbook by FIGI.
75
+
76
+ ```ruby
77
+ service.orderbook(figi: 'figi', depth: 0)
78
+ ```
79
+
80
+ ## Development
81
+
82
+ After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake spec` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
83
+
84
+ To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
85
+
86
+ ## Contributing
87
+
88
+ Bug reports and pull requests are welcome on GitHub at https://github.com/kortirso/tinkoff_invest. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/kortirso/tinkoff_invest/blob/master/CODE_OF_CONDUCT.md).
89
+
90
+
91
+ ## License
92
+
93
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
94
+
95
+ ## Code of Conduct
96
+
97
+ Everyone interacting in the TinkoffApi project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/kortirso/tinkoff_invest/blob/master/CODE_OF_CONDUCT.md).
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'bundler/gem_tasks'
4
+ require 'rspec/core/rake_task'
5
+
6
+ RSpec::Core::RakeTask.new(:spec)
7
+
8
+ task default: :spec
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require 'bundler/setup'
4
+ require 'tinkoff_invest'
5
+
6
+ # You can add fixtures and/or initialization code here to make experimenting
7
+ # with your gem easier. You can also use a different console, if you like.
8
+
9
+ # (If you use this, don't forget to add pry to your Gemfile!)
10
+ # require 'pry'
11
+ # Pry.start
12
+
13
+ require 'irb'
14
+ IRB.start(__FILE__)
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env bash
2
+ set -euo pipefail
3
+ IFS=$'\n\t'
4
+ set -vx
5
+
6
+ bundle install
7
+
8
+ # Do any other automated setup that you need to do here
@@ -0,0 +1,8 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'tinkoff_invest/version'
4
+ require_relative 'tinkoff_invest/v1/client'
5
+
6
+ module TinkoffInvest
7
+ class Error < StandardError; end
8
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require 'faraday'
4
+ require 'faraday_middleware'
5
+ require 'dry/initializer'
6
+ require_relative 'market/stocks'
7
+ require_relative 'market/bonds'
8
+ require_relative 'market/etfs'
9
+ require_relative 'market/orderbook'
10
+ require_relative 'market/search_by_figi'
11
+ require_relative 'market/search_by_ticker'
12
+
13
+ module TinkoffInvest
14
+ module V1
15
+ class Client
16
+ extend Dry::Initializer
17
+ include TinkoffInvest::V1::Market::Stocks
18
+ include TinkoffInvest::V1::Market::Bonds
19
+ include TinkoffInvest::V1::Market::Etfs
20
+ include TinkoffInvest::V1::Market::Orderbook
21
+ include TinkoffInvest::V1::Market::SearchByFigi
22
+ include TinkoffInvest::V1::Market::SearchByTicker
23
+
24
+ option :token
25
+ option :sandbox, default: proc { true }
26
+ option :url, default: proc { 'https://api-invest.tinkoff.ru/openapi' }
27
+ option :connection, default: proc { build_connection }
28
+
29
+ private
30
+
31
+ def build_connection
32
+ Faraday.new(base_url, headers: connection_headers) do |conn|
33
+ conn.request :json
34
+ conn.response :json, content_type: /\bjson$/
35
+ conn.adapter Faraday.default_adapter
36
+ end
37
+ end
38
+
39
+ def base_url
40
+ return @url unless @sandbox
41
+
42
+ "#{@url}/sandbox"
43
+ end
44
+
45
+ def connection_headers
46
+ {
47
+ 'Authorization' => "Bearer #{@token}"
48
+ }
49
+ end
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TinkoffInvest
4
+ module V1
5
+ module Market
6
+ module Bonds
7
+ def bonds
8
+ response = connection.get('market/bonds')
9
+ response.body if response.success?
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TinkoffInvest
4
+ module V1
5
+ module Market
6
+ module Etfs
7
+ def etfs
8
+ response = connection.get('market/etfs')
9
+ response.body if response.success?
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,17 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TinkoffInvest
4
+ module V1
5
+ module Market
6
+ module Orderbook
7
+ def orderbook(figi:, depth: 0)
8
+ response = connection.get('market/orderbook') do |request|
9
+ request.params['figi'] = figi
10
+ request.params['depth'] = depth
11
+ end
12
+ response.body if response.success?
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TinkoffInvest
4
+ module V1
5
+ module Market
6
+ module SearchByFigi
7
+ def search_by_figi(figi:)
8
+ response = connection.get('market/search/by-figi') do |request|
9
+ request.params['figi'] = figi
10
+ end
11
+ response.body if response.success?
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,16 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TinkoffInvest
4
+ module V1
5
+ module Market
6
+ module SearchByTicker
7
+ def search_by_ticker(ticker:)
8
+ response = connection.get('market/search/by-ticker') do |request|
9
+ request.params['ticker'] = ticker
10
+ end
11
+ response.body if response.success?
12
+ end
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,14 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TinkoffInvest
4
+ module V1
5
+ module Market
6
+ module Stocks
7
+ def stocks
8
+ response = connection.get('market/stocks')
9
+ response.body if response.success?
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,5 @@
1
+ # frozen_string_literal: true
2
+
3
+ module TinkoffInvest
4
+ VERSION = '0.2.0'
5
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ lib = File.expand_path('lib', __dir__)
4
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
5
+ require 'tinkoff_invest/version'
6
+
7
+ Gem::Specification.new do |spec|
8
+ spec.name = 'tinkoff_invest'
9
+ spec.version = TinkoffInvest::VERSION
10
+ spec.authors = ['kortirso']
11
+ spec.email = ['kortirso@gmail.com']
12
+
13
+ spec.summary = 'Ruby wrapper for Tinkoff Invest API'
14
+ spec.homepage = 'https://github.com/kortirso/tinkoff_invest'
15
+ spec.license = 'MIT'
16
+
17
+ spec.required_ruby_version = '~> 2.7'
18
+
19
+ spec.metadata['homepage_uri'] = spec.homepage
20
+ spec.metadata['source_code_uri'] = spec.homepage
21
+ spec.metadata['changelog_uri'] = 'https://github.com/kortirso/tinkoff_invest/blob/master/CHANGELOG.md'
22
+
23
+ spec.files = `git ls-files -z`.split("\x0").reject do |f|
24
+ f.match(%r{^(test|spec|features)/})
25
+ end
26
+ spec.bindir = 'exe'
27
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
28
+ spec.require_paths = ['lib']
29
+
30
+ spec.add_development_dependency 'bundler', '~> 2.1.4'
31
+ spec.add_development_dependency 'rake', '~> 13.0'
32
+ spec.add_development_dependency 'rubocop', '~> 1.3'
33
+ spec.add_development_dependency 'rubocop-performance', '~> 1.8'
34
+ spec.add_development_dependency 'rubocop-rspec', '~> 2.0'
35
+ spec.add_dependency 'dry-initializer', '~> 3.0'
36
+ spec.add_dependency 'faraday', '~> 1.1'
37
+ spec.add_dependency 'faraday_middleware', '~> 1.0'
38
+ end
metadata ADDED
@@ -0,0 +1,182 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: tinkoff_invest
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.2.0
5
+ platform: ruby
6
+ authors:
7
+ - kortirso
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2020-11-19 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: 2.1.4
20
+ type: :development
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: 2.1.4
27
+ - !ruby/object:Gem::Dependency
28
+ name: rake
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - "~>"
32
+ - !ruby/object:Gem::Version
33
+ version: '13.0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - "~>"
39
+ - !ruby/object:Gem::Version
40
+ version: '13.0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: rubocop
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.3'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.3'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop-performance
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '1.8'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '1.8'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rubocop-rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '2.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '2.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: dry-initializer
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :runtime
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ - !ruby/object:Gem::Dependency
98
+ name: faraday
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '1.1'
104
+ type: :runtime
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '1.1'
111
+ - !ruby/object:Gem::Dependency
112
+ name: faraday_middleware
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.0'
125
+ description:
126
+ email:
127
+ - kortirso@gmail.com
128
+ executables: []
129
+ extensions: []
130
+ extra_rdoc_files: []
131
+ files:
132
+ - ".gitignore"
133
+ - ".rspec"
134
+ - ".rubocop.yml"
135
+ - ".ruby-version"
136
+ - ".travis.yml"
137
+ - CHANGELOG.md
138
+ - CODE_OF_CONDUCT.md
139
+ - Gemfile
140
+ - Gemfile.lock
141
+ - LICENSE.txt
142
+ - README.md
143
+ - Rakefile
144
+ - bin/console
145
+ - bin/setup
146
+ - lib/tinkoff_invest.rb
147
+ - lib/tinkoff_invest/v1/client.rb
148
+ - lib/tinkoff_invest/v1/market/bonds.rb
149
+ - lib/tinkoff_invest/v1/market/etfs.rb
150
+ - lib/tinkoff_invest/v1/market/orderbook.rb
151
+ - lib/tinkoff_invest/v1/market/search_by_figi.rb
152
+ - lib/tinkoff_invest/v1/market/search_by_ticker.rb
153
+ - lib/tinkoff_invest/v1/market/stocks.rb
154
+ - lib/tinkoff_invest/version.rb
155
+ - tinkoff_invest.gemspec
156
+ homepage: https://github.com/kortirso/tinkoff_invest
157
+ licenses:
158
+ - MIT
159
+ metadata:
160
+ homepage_uri: https://github.com/kortirso/tinkoff_invest
161
+ source_code_uri: https://github.com/kortirso/tinkoff_invest
162
+ changelog_uri: https://github.com/kortirso/tinkoff_invest/blob/master/CHANGELOG.md
163
+ post_install_message:
164
+ rdoc_options: []
165
+ require_paths:
166
+ - lib
167
+ required_ruby_version: !ruby/object:Gem::Requirement
168
+ requirements:
169
+ - - "~>"
170
+ - !ruby/object:Gem::Version
171
+ version: '2.7'
172
+ required_rubygems_version: !ruby/object:Gem::Requirement
173
+ requirements:
174
+ - - ">="
175
+ - !ruby/object:Gem::Version
176
+ version: '0'
177
+ requirements: []
178
+ rubygems_version: 3.1.4
179
+ signing_key:
180
+ specification_version: 4
181
+ summary: Ruby wrapper for Tinkoff Invest API
182
+ test_files: []