kabustation_client
KabustationClient - the Ruby gem for the kabuステーションAPI
定義情報
REST APIのコード一覧、エンドポイントは下記リンク参照
This SDK is automatically generated by the OpenAPI Generator project:
- API version: 1.5
- Package version: 1.2.0
- Generator version: 7.6.0
- Build package: org.openapitools.codegen.languages.RubyClientCodegen For more information, please visit https://kabucom.github.io/kabusapi/ptal/index.html
Installation
Build a gem
To build the Ruby code into a gem:
gem build kabustation_client.gemspec
Then either install the gem locally:
gem install ./kabustation_client-1.1.0.gem
(for development, run gem install --dev ./kabustation_client-1.1.0.gem
to install the development dependencies)
or publish the gem to a gem hosting service, e.g. RubyGems.
Finally add this to the Gemfile:
gem 'kabustation_client', '~> 1.1.0'
Install from Git
If the Ruby gem is hosted at a git repository: https://github.com/kyohah/kabustation_client-ruby, then add the following in the Gemfile:
gem 'kabustation_client', :git => 'https://github.com/kyohah/kabustation_client-ruby.git'
Include the Ruby code directly
Include the Ruby code directly using -I
as follows:
ruby -Ilib script.rb
Getting Started
Please follow the installation procedure and then run the following code:
Windowsのnginxの設定
windows マシンで rubyを動かすなら不要
worker_processes 1;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
map $http_upgrade $connection_upgrade {
default upgrade;
'' close;
}
server {
listen 80;
server_name localhost;
proxy_http_version 1.1;
proxy_set_header Host localhost;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection $connection_upgrade;
location /production/ { # 本番用
proxy_pass http://127.0.0.1:18080/kabusapi;
}
location /development/ { # 検証用
proxy_pass http://127.0.0.1:18081/kabusapi;
}
}
}
require 'kabustation_client'
KabustationClient.configure do |config|
config.host = ENV.fetch('KABUSTATION_HOST', 'localhost')
config.base_path = '/production'
end
api_instance = KabustationClient::AuthApi.new
request_token = KabustationClient::RequestToken.new({api_password: 'xxxxxx'}) # RequestToken |
begin
#トークン発行
result = api_instance.token_post(request_token)
p result
rescue KabustationClient::ApiError => e
puts "Exception when calling AuthApi->token_post: #{e}"
end
KabustationClient.configure.api_key['ApiKeyAuth'] = result.token
register_instance = KabustationClient::RegisterApi.new
instance = KabustationClient::RequestRegister.new(symbols: [{symbol: '5401', exchange: 1}])
result = register_instance.register_put(instance)
client = KabustationClient::PushClient.new(
open: -> { puts "WebSocket opened" },
message: -> (board) { puts "Received message: #{board.symbol_name}" }, # KabustationClient::BoardSuccess
error: -> (e) { puts "Error occurred: #{e}" },
close: -> (e) { puts "Connection closed: #{e}" }
)
client.connect
Documentation for API Endpoints
All URIs are relative to http://localhost:18080/kabusapi
Class | Method | HTTP request | Description |
---|---|---|---|
KabustationClient::AuthApi | token_post | POST /token | トークン発行 |
KabustationClient::InfoApi | apisoftlimit_get | GET /apisoftlimit | ソフトリミット |
KabustationClient::InfoApi | board_get | GET /board/symbol | 時価情報・板情報 |
KabustationClient::InfoApi | exchange_get | GET /exchange/symbol | 為替情報 |
KabustationClient::InfoApi | marginpremium_get | GET /margin/marginpremium/symbol | プレミアム料取得 |
KabustationClient::InfoApi | orders_get | GET /orders | 注文約定照会 |
KabustationClient::InfoApi | positions_get | GET /positions | 残高照会 |
KabustationClient::InfoApi | primary_exchange_get | GET /primaryexchange/symbol | 優先市場 |
KabustationClient::InfoApi | ranking_get | GET /ranking | 詳細ランキング |
KabustationClient::InfoApi | regulations_get | GET /regulations/symbol | 規制情報 |
KabustationClient::InfoApi | symbol_get | GET /symbol/symbol | 銘柄情報 |
KabustationClient::InfoApi | symbolname_future_get | GET /symbolname/future | 先物銘柄コード取得 |
KabustationClient::InfoApi | symbolname_option_get | GET /symbolname/option | オプション銘柄コード取得 |
KabustationClient::InfoApi | symbolname_option_mini_get | GET /symbolname/minioptionweekly | ミニオプション(限週)銘柄コード取得 |
KabustationClient::OrderApi | cancelorder_put | PUT /cancelorder | 注文取消 |
KabustationClient::OrderApi | sendoder_future_post | POST /sendorder/future | 注文発注(先物) |
KabustationClient::OrderApi | sendorder_option_post | POST /sendorder/option | 注文発注(オプション) |
KabustationClient::OrderApi | sendorder_post | POST /sendorder | 注文発注(現物・信用) |
KabustationClient::RegisterApi | register_put | PUT /register | 銘柄登録 |
KabustationClient::RegisterApi | unregister_all_put | PUT /unregister/all | 銘柄登録全解除 |
KabustationClient::RegisterApi | unregister_put | PUT /unregister | 銘柄登録解除 |
KabustationClient::WalletApi | wallet_cash_get | GET /wallet/cash | 取引余力(現物) |
KabustationClient::WalletApi | wallet_cash_symbol_get | GET /wallet/cash/symbol | 取引余力(現物)(銘柄指定) |
KabustationClient::WalletApi | wallet_future_get | GET /wallet/future | 取引余力(先物) |
KabustationClient::WalletApi | wallet_future_symbol_get | GET /wallet/future/symbol | 取引余力(先物)(銘柄指定) |
KabustationClient::WalletApi | wallet_margin_get | GET /wallet/margin | 取引余力(信用) |
KabustationClient::WalletApi | wallet_margin_symbol_get | GET /wallet/margin/symbol | 取引余力(信用)(銘柄指定) |
KabustationClient::WalletApi | wallet_option_get | GET /wallet/option | 取引余力(オプション) |
KabustationClient::WalletApi | wallet_option_symbol_get | GET /wallet/option/symbol | 取引余力(オプション)(銘柄指定) |
Documentation for Models
- KabustationClient::ApiSoftLimitResponse
- KabustationClient::BoardSuccess
- KabustationClient::BoardSuccessBuy1
- KabustationClient::BoardSuccessBuy10
- KabustationClient::BoardSuccessBuy2
- KabustationClient::BoardSuccessBuy3
- KabustationClient::BoardSuccessBuy4
- KabustationClient::BoardSuccessBuy5
- KabustationClient::BoardSuccessBuy6
- KabustationClient::BoardSuccessBuy7
- KabustationClient::BoardSuccessBuy8
- KabustationClient::BoardSuccessBuy9
- KabustationClient::BoardSuccessSell1
- KabustationClient::BoardSuccessSell10
- KabustationClient::BoardSuccessSell2
- KabustationClient::BoardSuccessSell3
- KabustationClient::BoardSuccessSell4
- KabustationClient::BoardSuccessSell5
- KabustationClient::BoardSuccessSell6
- KabustationClient::BoardSuccessSell7
- KabustationClient::BoardSuccessSell8
- KabustationClient::BoardSuccessSell9
- KabustationClient::ErrorResponse
- KabustationClient::ExchangeResponse
- KabustationClient::MarginPremiumResponse
- KabustationClient::MarginPremiumResponseDayTrade
- KabustationClient::MarginPremiumResponseGeneralMargin
- KabustationClient::OrderSuccess
- KabustationClient::OrdersSuccess
- KabustationClient::OrdersSuccessDetailsInner
- KabustationClient::Positions
- KabustationClient::PositionsDeriv
- KabustationClient::PositionsSuccess
- KabustationClient::PrimaryExchangeResponse
- KabustationClient::RankingByCategoryResponse
- KabustationClient::RankingByCategoryResponseRankingInner
- KabustationClient::RankingByMarginResponse
- KabustationClient::RankingByMarginResponseRankingInner
- KabustationClient::RankingByTickCountResponse
- KabustationClient::RankingByTickCountResponseRankingInner
- KabustationClient::RankingByTradeValueResponse
- KabustationClient::RankingByTradeValueResponseRankingInner
- KabustationClient::RankingByTradeVolumeResponse
- KabustationClient::RankingByTradeVolumeResponseRankingInner
- KabustationClient::RankingDefaultResponse
- KabustationClient::RankingDefaultResponseRankingInner
- KabustationClient::RankingGet200Response
- KabustationClient::RegistSuccess
- KabustationClient::RegulationsResponse
- KabustationClient::RegulationsResponseRegulationsInfoInner
- KabustationClient::RequestCancelOrder
- KabustationClient::RequestRegister
- KabustationClient::RequestRegisterSymbolsInner
- KabustationClient::RequestSendOrder
- KabustationClient::RequestSendOrderDerivFuture
- KabustationClient::RequestSendOrderDerivFutureReverseLimitOrder
- KabustationClient::RequestSendOrderDerivOption
- KabustationClient::RequestSendOrderReverseLimitOrder
- KabustationClient::RequestToken
- KabustationClient::RequestUnregister
- KabustationClient::SymbolNameSuccess
- KabustationClient::SymbolSuccess
- KabustationClient::TokenSuccess
- KabustationClient::UnregisterAllSuccess
- KabustationClient::WalletCashSuccess
- KabustationClient::WalletFutureSuccess
- KabustationClient::WalletMarginSuccess
- KabustationClient::WalletOptionSuccess
Documentation for Authorization
Authentication schemes defined for the API:
ApiKeyAuth
- Type: API key
- API key parameter name: X-API-Key
- Location: HTTP header