bit_flyer 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: d1e4274feb5745f36a99a4a76817add7109b2bbb09dfa2ff0f8bdeb0fb81b0a1
4
+ data.tar.gz: af4de2cc07a5f622aa3e1eed723cea15cc44b6550d407729010035bf63c0917b
5
+ SHA512:
6
+ metadata.gz: b41564cffe421bf2f8e4ec9222a8c490dc67e6f3fa28a106669dabf54d1348e154cf80e4fa336364a154e5a745e58754587c1d29fa2adae3599eea4ee2f3b406
7
+ data.tar.gz: ef15abd1e0dd43fb254323d2465e68ab23af086c9d81ca02201818dd97df34ab829f3f5eefde2d753a95b86a9b2d82492da4d0cd032ab4358ddf9b2e27d6d856
data/.gitignore ADDED
@@ -0,0 +1,16 @@
1
+ /.bundle/
2
+ /.yardoc
3
+ /_yardoc/
4
+ /coverage/
5
+ /doc/
6
+ /pkg/
7
+ /spec/reports/
8
+ /tmp/
9
+
10
+ vendor/
11
+
12
+ /.idea/
13
+ /Gemfile.lock
14
+
15
+ # rspec failure tracking
16
+ .rspec_status
data/.rspec ADDED
@@ -0,0 +1,3 @@
1
+ --format documentation
2
+ --color
3
+ --require spec_helper
data/.travis.yml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ sudo: false
3
+ language: ruby
4
+ cache: bundler
5
+ rvm:
6
+ - 2.5.1
7
+ before_install: gem install bundler -v 2.0.1
@@ -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 sohakahori@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 [http://contributor-covenant.org/version/1/4][version]
72
+
73
+ [homepage]: http://contributor-covenant.org
74
+ [version]: http://contributor-covenant.org/version/1/4/
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source "https://rubygems.org"
2
+
3
+ # Specify your gem's dependencies in bit_flyer.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,21 @@
1
+ The MIT License (MIT)
2
+
3
+ Copyright (c) 2019 sohakahori
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.
data/README.md ADDED
@@ -0,0 +1,43 @@
1
+ # BitFlyer
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/bit_flyer`. 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 'bit_flyer'
13
+ ```
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install bit_flyer
22
+
23
+ ## Usage
24
+
25
+ TODO: Write usage instructions here
26
+
27
+ ## Development
28
+
29
+ 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.
30
+
31
+ 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).
32
+
33
+ ## Contributing
34
+
35
+ Bug reports and pull requests are welcome on GitHub at https://github.com/[USERNAME]/bit_flyer. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [Contributor Covenant](http://contributor-covenant.org) code of conduct.
36
+
37
+ ## License
38
+
39
+ The gem is available as open source under the terms of the [MIT License](https://opensource.org/licenses/MIT).
40
+
41
+ ## Code of Conduct
42
+
43
+ Everyone interacting in the BitFlyer project’s codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/[USERNAME]/bit_flyer/blob/master/CODE_OF_CONDUCT.md).
data/Rakefile ADDED
@@ -0,0 +1,6 @@
1
+ require "bundler/gem_tasks"
2
+ require "rspec/core/rake_task"
3
+
4
+ RSpec::Core::RakeTask.new(:spec)
5
+
6
+ task :default => :spec
data/bin/console ADDED
@@ -0,0 +1,14 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require "bundler/setup"
4
+ require "bit_flyer"
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__)
data/bin/setup ADDED
@@ -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
data/bit_flyer.gemspec ADDED
@@ -0,0 +1,46 @@
1
+
2
+ lib = File.expand_path("../lib", __FILE__)
3
+ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
4
+ require "bit_flyer/version"
5
+
6
+ Gem::Specification.new do |spec|
7
+ spec.name = "bit_flyer"
8
+ spec.version = BitFlyer::VERSION
9
+ spec.authors = ["sohakahori"]
10
+ spec.email = ["soh.shizuoka@gmail.com"]
11
+
12
+ spec.summary = %q{bitFlyerのAPIに関するgem}
13
+ spec.description = %q{bitFlyerのAPIに関するgem}
14
+ spec.homepage = "https://github.com/sohakahori/bit_flyer.git"
15
+ spec.license = "MIT"
16
+
17
+ # Prevent pushing this gem to RubyGems.org. To allow pushes either set the 'allowed_push_host'
18
+ # to allow pushing to a single host or delete this section to allow pushing to any host.
19
+ # if spec.respond_to?(:metadata)
20
+ # spec.metadata["allowed_push_host"] = "http://test@test.com"
21
+
22
+ # spec.metadata["homepage_uri"] = spec.homepage
23
+ # spec.metadata["source_code_uri"] = "TODO: Put your gem's public repo URL here."
24
+ # spec.metadata["changelog_uri"] = "TODO: Put your gem's CHANGELOG.md URL here."
25
+ # else
26
+ # raise "RubyGems 2.0 or newer is required to protect against " \
27
+ # "public gem pushes."
28
+ # end
29
+
30
+ # Specify which files should be added to the gem when it is released.
31
+ # The `git ls-files -z` loads the files in the RubyGem that have been added into git.
32
+ spec.files = Dir.chdir(File.expand_path('..', __FILE__)) do
33
+ `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
34
+ end
35
+ spec.bindir = "exe"
36
+ spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
37
+ spec.require_paths = ["lib"]
38
+
39
+ spec.add_dependency 'activesupport', '>= 4.0.0'
40
+ spec.add_dependency 'faraday'
41
+ spec.add_dependency 'pry-byebug'
42
+ spec.add_dependency 'pry-doc'
43
+
44
+ spec.add_development_dependency "rake", "~> 10.0"
45
+ spec.add_development_dependency "rspec", "~> 3.0"
46
+ end
@@ -0,0 +1,17 @@
1
+ module BitFlyer
2
+ module Api
3
+ class Base
4
+ require 'faraday'
5
+ BASE_URL = "https://api.bitflyer.com"
6
+
7
+ private
8
+ def connect
9
+ @connect ||= Faraday.new(:url => BitFlyer::Api::Base::BASE_URL) do |faraday|
10
+ faraday.request :url_encoded # form-encode POST params
11
+ faraday.response :logger # log requests to STDOUT
12
+ faraday.adapter Faraday.default_adapter # make requests with Net::HTTP
13
+ end
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,74 @@
1
+ module BitFlyer
2
+ module Api
3
+ class PrivateReader < BitFlyer::Api::Base
4
+ require "openssl"
5
+ require "uri"
6
+ require 'active_support/core_ext'
7
+
8
+ CURRENCY_CODE = 'JPY'
9
+
10
+ def initialize(key, secret)
11
+ @key = key
12
+ @secret = secret
13
+ end
14
+
15
+
16
+ # 約定の一覧を取得
17
+ # パラメータ
18
+ # product_code: マーケットの一覧で取得できる product_code または alias のいずれかを指定してください。
19
+ # count, before, after: ページ形式 を参照してください。
20
+ def executions(product_code = '', count = nil, before = nil, after = nil)
21
+ timestamp = Time.now.to_i.to_s
22
+ uri = URI.parse(BASE_URL)
23
+ uri.path = "/v1/me/getexecutions"
24
+ query_string = {}
25
+ query_string[:product_code] = product_code if product_code.present?
26
+ query_string[:count] = count if count.present?
27
+ query_string[:before] = before unless before.nil?
28
+ query_string[:after] = after unless after.nil?
29
+ uri.query = query_string.to_param
30
+ uri_path = query_string.count >= 1 ? uri.request_uri : uri.path
31
+
32
+ text = timestamp + 'GET' + uri_path
33
+ sign = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha256"), @secret, text)
34
+
35
+ response = connect.get do |req|
36
+ req.url uri_path
37
+ req.headers = {
38
+ "ACCESS-KEY" => @key,
39
+ "ACCESS-TIMESTAMP" => timestamp,
40
+ "ACCESS-SIGN" => sign
41
+ }
42
+ end
43
+ response.body
44
+ end
45
+
46
+ # 残高履歴
47
+ def balancehistory(count = 100, before = nil, after = nil)
48
+ timestamp = Time.now.to_i.to_s
49
+ uri = URI.parse(BASE_URL)
50
+ uri.path = "/v1/me/getbalancehistory"
51
+ query_string = {}
52
+ query_string[:currency_code] = CURRENCY_CODE
53
+ query_string[:count] = count if count.present?
54
+ query_string[:before] = before unless before.nil?
55
+ query_string[:after] = after unless after.nil?
56
+ uri.query = query_string.to_param
57
+ request_uri = uri.request_uri
58
+
59
+ text = timestamp + 'GET' + request_uri
60
+ sign = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha256"), @secret, text)
61
+
62
+ response = connect.get do |req|
63
+ req.url request_uri
64
+ req.headers = {
65
+ "ACCESS-KEY" => @key,
66
+ "ACCESS-TIMESTAMP" => timestamp,
67
+ "ACCESS-SIGN" => sign
68
+ }
69
+ end
70
+ response.body
71
+ end
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,94 @@
1
+ module BitFlyer
2
+ module Api
3
+ class PublicReader < BitFlyer::Api::Base
4
+ require 'active_support/all'
5
+
6
+ # マーケットの一覧
7
+ def market
8
+ conn = connect
9
+ response = conn.get '/v1/markets'
10
+ response.body
11
+ end
12
+
13
+ # チャット
14
+ def chats(from_date = nil)
15
+ conn = connect
16
+ from_date = from_date.to_date unless from_date.nil?
17
+ response = conn.get '/v1/getchats', {from_date: from_date}
18
+ response.body
19
+ end
20
+
21
+ # 板情報
22
+ def board(product_code = '')
23
+ conn = connect
24
+ params = {}
25
+ params[:product_code] = product_code if product_code.present?
26
+ response = conn.get '/v1/board', params
27
+ response.body
28
+ end
29
+
30
+ # Ticker
31
+ def ticker(product_code = '')
32
+ conn = connect
33
+ params = {}
34
+ params[:product_code] = product_code if product_code.present?
35
+ response = conn.get '/v1/ticker', params
36
+ response.body
37
+ end
38
+
39
+ # 約定履歴
40
+ def executions(count = 100, before = nil, after = nil)
41
+ conn = connect
42
+ params = {}
43
+ params[:count] = count if count.present?
44
+ params[:before] = before unless before.nil?
45
+ params[:after] = after unless before.nil?
46
+ response = conn.get '/v1/executions', params
47
+ response.body
48
+ end
49
+
50
+ # 板の状態
51
+ #
52
+ # health: 取引所の稼動状態です。以下のいずれかの値をとります。
53
+ # NORMAL: 取引所は稼動しています。
54
+ # BUSY: 取引所に負荷がかかっている状態です。
55
+ # VERY BUSY: 取引所の負荷が大きい状態です。
56
+ # SUPER BUSY: 負荷が非常に大きい状態です。発注は失敗するか、遅れて処理される可能性があります。
57
+ # NO ORDER: 発注が受付できない状態です。
58
+ # STOP: 取引所は停止しています。発注は受付されません。
59
+ #
60
+ # state: 板の状態です。以下の値をとります。
61
+ # RUNNING: 通常稼働中
62
+ # CLOSED: 取引停止中
63
+ # STARTING: 再起動中
64
+ # PREOPEN: 板寄せ中
65
+ # CIRCUIT BREAK: サーキットブレイク発動中
66
+ # AWAITING SQ: Lightning Futures の取引終了後 SQ(清算値)の確定前
67
+ # MATURED: Lightning Futures の満期に到達
68
+ # data.rb: 板の状態について、付加情報を提供します。
69
+ # special_quotation: Lightning Futures の SQ(清算値)
70
+ def board_state(product_code = '')
71
+ conn = connect
72
+ params = {}
73
+ params[:product_code] = product_code if product_code.present?
74
+ response = conn.get '/v1/getboardstate', params
75
+ response.body
76
+ end
77
+
78
+ # 取引所の状態
79
+ # NORMAL: 取引所は稼動しています。
80
+ # BUSY: 取引所に負荷がかかっている状態です。
81
+ # VERY BUSY: 取引所の負荷が大きい状態です。
82
+ # SUPER BUSY: 負荷が非常に大きい状態です。発注は失敗するか、遅れて処理される可能性があります。
83
+ # NO ORDER: 発注が受付できない状態です。
84
+ # STOP: 取引所は停止しています。発注は受付されません。
85
+ def health(product_code = '')
86
+ conn = connect
87
+ params = {}
88
+ params[:product_code] = product_code if product_code.present?
89
+ response = conn.get '/v1/gethealth', params
90
+ response.body
91
+ end
92
+ end
93
+ end
94
+ end
@@ -0,0 +1,43 @@
1
+ module BitFlyer
2
+ module Models
3
+ class BalanceHistory
4
+ attr_reader :id,
5
+ :trade_date,
6
+ :product_code,
7
+ :currency_code,
8
+ :trade_type,
9
+ :rade_type,
10
+ :price,
11
+ :amount,
12
+ :quantity,
13
+ :commission,
14
+ :balance,
15
+ :order_id
16
+
17
+ # trade_type:
18
+ # BUY: 買い
19
+ # SELL: 売り
20
+ # DEPOSIT: 入金・仮想通貨の預入
21
+ # WITHDRAW: 出金・仮想通貨の外部送付
22
+ # FEE: 手数料
23
+ # POST_COLL: 証拠金の預入
24
+ # CANCEL_COLL: 証拠金の引出
25
+ # PAYMENT: ビットコイン決済による仮想通貨の移転
26
+ # TRANSFER: その他の一般的な資金移動
27
+
28
+ def initialize(attrs = {})
29
+ @id = attrs['id']
30
+ @trade_date = attrs['trade_date']
31
+ @product_code = attrs['product_code']
32
+ @currency_code = attrs['currency_code']
33
+ @trade_type = attrs['trade_type']
34
+ @price = attrs['price'] # 仮想通貨の取引時の値段(BTCなら1BTCの値段)
35
+ @amount = attrs['amount'] # 取引した値段(日本円等)
36
+ @quantity = attrs['quantity'] # 取引した仮想通貨量
37
+ @commission = attrs['commission'] # 手数料(多分仮装通過の量)
38
+ @balance = attrs['balance'] # 残金(1,0000円入金していて1000円で0.01BTCを買った時→9,000)
39
+ @order_id = attrs['order_id']
40
+ end
41
+ end
42
+ end
43
+ end
@@ -0,0 +1,16 @@
1
+ module BitFlyer
2
+ module Models
3
+ class Board
4
+ attr_reader :mid_price
5
+
6
+ def initialize(attrs = {})
7
+ @attrs = attrs
8
+ @mid_price = attrs['mid_price']
9
+ end
10
+
11
+ def bids
12
+ @bids ||= @attrs['bids'].map {|bid| BitFlyer::Models::Boards::Bid.new(bid) }
13
+ end
14
+ end
15
+ end
16
+ end
@@ -0,0 +1,17 @@
1
+ module BitFlyer
2
+ module Models
3
+ class BoardState
4
+ attr_reader :health, :state
5
+
6
+ def initialize(attrs = {})
7
+ @attrs = attrs
8
+ @health = attrs['health']
9
+ @state = attrs['state']
10
+ end
11
+
12
+ def data
13
+ @data ||= @attrs['data'].present? ? BitFlyer::Models::BoardStates::Data.new(@attrs['data']) : nil
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,13 @@
1
+ module BitFlyer
2
+ module Models
3
+ module BoardStates
4
+ class Data
5
+ attr_reader :special_quotation
6
+
7
+ def initialize(attrs = {})
8
+ @special_quotation = attrs['special_quotation']
9
+ end
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,14 @@
1
+ module BitFlyer
2
+ module Models
3
+ module Boards
4
+ class Bid
5
+ attr_reader :price, :size
6
+
7
+ def initialize(params)
8
+ @price = params['price']
9
+ @size = params['size']
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,13 @@
1
+ module BitFlyer
2
+ module Models
3
+ class Chat
4
+ attr_reader :nickname, :message, :date
5
+
6
+ def initialize(attrs = {})
7
+ @nickname = attrs['nickname']
8
+ @message = attrs['message']
9
+ @date = attrs['date']
10
+ end
11
+ end
12
+ end
13
+ end
@@ -0,0 +1,17 @@
1
+ module BitFlyer
2
+ module Models
3
+ class Execution
4
+ attr_reader :id, :side, :price, :size, :exec_date, :buy_child_order_acceptance_id, :sell_child_order_acceptance_id
5
+
6
+ def initialize(attrs = {})
7
+ @id = attrs['id']
8
+ @side = attrs['side']
9
+ @price = attrs['price']
10
+ @size = attrs['size']
11
+ @exec_date = Time.parse(attrs['exec_date']).in_time_zone('Tokyo')
12
+ @buy_child_order_acceptance_id = attrs['buy_child_order_acceptance_id']
13
+ @sell_child_order_acceptance_id = attrs['sell_child_order_acceptance_id']
14
+ end
15
+ end
16
+ end
17
+ end
@@ -0,0 +1,11 @@
1
+ module BitFlyer
2
+ module Models
3
+ class Health
4
+ attr_reader :status
5
+
6
+ def initialize(attrs = {})
7
+ @status = attrs['status']
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,11 @@
1
+ module BitFlyer
2
+ module Models
3
+ class Market
4
+ attr_reader :product_code, :alias
5
+ def initialize(attrs = {})
6
+ @product_code = attrs['product_code']
7
+ @alias = attrs['alias'].present? ? attrs['alias'] : nil
8
+ end
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,33 @@
1
+ module BitFlyer
2
+ module Models
3
+ class Ticker
4
+ attr_reader :product_code,
5
+ :timestamp,
6
+ :tick_id,
7
+ :best_bid,
8
+ :best_ask,
9
+ :best_bid_size,
10
+ :best_ask_size,
11
+ :total_bid_depth,
12
+ :total_ask_depth,
13
+ :ltp, # 最終取引価格
14
+ :volume, # volume
15
+ :volume_by_product
16
+
17
+ def initialize(attrs = {})
18
+ @product_code = attrs['product_code']
19
+ @timestamp = Time.parse(attrs['timestamp']).in_time_zone('Tokyo')
20
+ @tick_id = attrs['tick_id']
21
+ @best_bid = attrs['best_bid']
22
+ @best_ask = attrs['best_ask']
23
+ @best_bid_size = attrs['best_bid_size']
24
+ @best_ask_size = attrs['best_ask_size']
25
+ @total_bid_depth = attrs['total_bid_depth']
26
+ @total_ask_depth = attrs['total_ask_depth']
27
+ @ltp = attrs['ltp']
28
+ @volume = attrs['volume']
29
+ @volume_by_product = attrs['volume_by_product']
30
+ end
31
+ end
32
+ end
33
+ end
@@ -0,0 +1,3 @@
1
+ module BitFlyer
2
+ VERSION = "0.1.1"
3
+ end
data/lib/bit_flyer.rb ADDED
@@ -0,0 +1,17 @@
1
+ require 'bit_flyer/version.rb'
2
+ require 'bit_flyer/api/base'
3
+ require 'bit_flyer/api/public_reader'
4
+ require 'bit_flyer/api/private_reader'
5
+ require 'bit_flyer/models/balance_history'
6
+ require 'bit_flyer/models/market'
7
+ require 'bit_flyer/models/chat'
8
+ require 'bit_flyer/models/board'
9
+ require 'bit_flyer/models/boards/bid'
10
+ require 'bit_flyer/models/ticker'
11
+ require 'bit_flyer/models/execution'
12
+ require 'bit_flyer/models/board_state'
13
+ require 'bit_flyer/models/board_states/data'
14
+ require 'bit_flyer/models/health'
15
+
16
+ require 'active_support/all'
17
+
metadata ADDED
@@ -0,0 +1,154 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: bit_flyer
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.1.1
5
+ platform: ruby
6
+ authors:
7
+ - sohakahori
8
+ autorequire:
9
+ bindir: exe
10
+ cert_chain: []
11
+ date: 2019-07-11 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: activesupport
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: 4.0.0
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: 4.0.0
27
+ - !ruby/object:Gem::Dependency
28
+ name: faraday
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: pry-byebug
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: pry-doc
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :runtime
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ - !ruby/object:Gem::Dependency
70
+ name: rake
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '10.0'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '10.0'
83
+ - !ruby/object:Gem::Dependency
84
+ name: rspec
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '3.0'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '3.0'
97
+ description: bitFlyerのAPIに関するgem
98
+ email:
99
+ - soh.shizuoka@gmail.com
100
+ executables: []
101
+ extensions: []
102
+ extra_rdoc_files: []
103
+ files:
104
+ - ".gitignore"
105
+ - ".rspec"
106
+ - ".travis.yml"
107
+ - CODE_OF_CONDUCT.md
108
+ - Gemfile
109
+ - LICENSE.txt
110
+ - README.md
111
+ - Rakefile
112
+ - bin/console
113
+ - bin/setup
114
+ - bit_flyer.gemspec
115
+ - lib/bit_flyer.rb
116
+ - lib/bit_flyer/api/base.rb
117
+ - lib/bit_flyer/api/private_reader.rb
118
+ - lib/bit_flyer/api/public_reader.rb
119
+ - lib/bit_flyer/models/balance_history.rb
120
+ - lib/bit_flyer/models/board.rb
121
+ - lib/bit_flyer/models/board_state.rb
122
+ - lib/bit_flyer/models/board_states/data.rb
123
+ - lib/bit_flyer/models/boards/bid.rb
124
+ - lib/bit_flyer/models/chat.rb
125
+ - lib/bit_flyer/models/execution.rb
126
+ - lib/bit_flyer/models/health.rb
127
+ - lib/bit_flyer/models/market.rb
128
+ - lib/bit_flyer/models/ticker.rb
129
+ - lib/bit_flyer/version.rb
130
+ homepage: https://github.com/sohakahori/bit_flyer.git
131
+ licenses:
132
+ - MIT
133
+ metadata: {}
134
+ post_install_message:
135
+ rdoc_options: []
136
+ require_paths:
137
+ - lib
138
+ required_ruby_version: !ruby/object:Gem::Requirement
139
+ requirements:
140
+ - - ">="
141
+ - !ruby/object:Gem::Version
142
+ version: '0'
143
+ required_rubygems_version: !ruby/object:Gem::Requirement
144
+ requirements:
145
+ - - ">="
146
+ - !ruby/object:Gem::Version
147
+ version: '0'
148
+ requirements: []
149
+ rubyforge_project:
150
+ rubygems_version: 2.7.6
151
+ signing_key:
152
+ specification_version: 4
153
+ summary: bitFlyerのAPIに関するgem
154
+ test_files: []