Class: RakutenTrading::PublicApi

Inherits:
Object
  • Object
show all
Defined in:
lib/rakuten_trading/api/public_api.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(api_client = ApiClient.default) ⇒ PublicApi

Returns a new instance of PublicApi.



16
17
18
# File 'lib/rakuten_trading/api/public_api.rb', line 16

def initialize(api_client = ApiClient.default)
  @api_client = api_client
end

Instance Attribute Details

#api_clientObject

Returns the value of attribute api_client.



14
15
16
# File 'lib/rakuten_trading/api/public_api.rb', line 14

def api_client
  @api_client
end

Instance Method Details

#get_candlestick(symbol_id, candlestick_type, opts = {}) ⇒ InlineResponse2001

ローソク取得 指定された銘柄のローソク足データを取得します。データは指定された範囲で検索され、最新のデータから最大500件まで取得することが可能です。

Parameters:

  • symbol_id

    シンボルID

  • candlestick_type

    ローソク足の種類。ISO8601フォーマットに準拠。

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :date_from (Integer)

    取得開始日時。UNIXタイムスタンプ(ミリ秒)で指定。

  • :date_to (Integer)

    取得終了日時。UNIXタイムスタンプ(ミリ秒)で指定。

Returns:



27
28
29
30
# File 'lib/rakuten_trading/api/public_api.rb', line 27

def get_candlestick(symbol_id, candlestick_type, opts = {})
  data, _status_code, _headers = get_candlestick_with_http_info(symbol_id, candlestick_type, opts)
  data
end

#get_candlestick_with_http_info(symbol_id, candlestick_type, opts = {}) ⇒ Array<(InlineResponse2001, Integer, Hash)>

ローソク取得 指定された銘柄のローソク足データを取得します。データは指定された範囲で検索され、最新のデータから最大500件まで取得することが可能です。

Parameters:

  • symbol_id

    シンボルID

  • candlestick_type

    ローソク足の種類。ISO8601フォーマットに準拠。

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :date_from (Integer)

    取得開始日時。UNIXタイムスタンプ(ミリ秒)で指定。

  • :date_to (Integer)

    取得終了日時。UNIXタイムスタンプ(ミリ秒)で指定。

Returns:

  • (Array<(InlineResponse2001, Integer, Hash)>)

    InlineResponse2001 data, response status code and response headers



40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
# File 'lib/rakuten_trading/api/public_api.rb', line 40

def get_candlestick_with_http_info(symbol_id, candlestick_type, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PublicApi.get_candlestick ...'
  end
  # verify the required parameter 'symbol_id' is set
  if @api_client.config.client_side_validation && symbol_id.nil?
    fail ArgumentError, "Missing the required parameter 'symbol_id' when calling PublicApi.get_candlestick"
  end
  # verify the required parameter 'candlestick_type' is set
  if @api_client.config.client_side_validation && candlestick_type.nil?
    fail ArgumentError, "Missing the required parameter 'candlestick_type' when calling PublicApi.get_candlestick"
  end
  # verify enum value
  if @api_client.config.client_side_validation && !['PT1M', 'PT5M', 'PT15M', 'PT30M', 'PT1H', 'PT4H', 'PT8H', 'P1D', 'P1W', 'P1M'].include?(candlestick_type)
    fail ArgumentError, "invalid value for 'candlestick_type', must be one of PT1M, PT5M, PT15M, PT30M, PT1H, PT4H, PT8H, P1D, P1W, P1M"
  end
  # resource path
  local_var_path = '/candlestick'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'symbolId'] = symbol_id
  query_params[:'candlestickType'] = candlestick_type
  query_params[:'dateFrom'] = opts[:'date_from'] if !opts[:'date_from'].nil?
  query_params[:'dateTo'] = opts[:'date_to'] if !opts[:'date_to'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  return_type = opts[:return_type] || 'InlineResponse2001' 

  auth_names = opts[:auth_names] || ['ApiKeyAuth', 'SignatureAuth']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type)

  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PublicApi#get_candlestick\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_orderbook(symbol_id, opts = {}) ⇒ InlineResponse2002

板取得

Parameters:

  • symbol_id

    シンボルID

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



97
98
99
100
# File 'lib/rakuten_trading/api/public_api.rb', line 97

def get_orderbook(symbol_id, opts = {})
  data, _status_code, _headers = get_orderbook_with_http_info(symbol_id, opts)
  data
end

#get_orderbook_with_http_info(symbol_id, opts = {}) ⇒ Array<(InlineResponse2002, Integer, Hash)>

板取得

Parameters:

  • symbol_id

    シンボルID

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(InlineResponse2002, Integer, Hash)>)

    InlineResponse2002 data, response status code and response headers



106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# File 'lib/rakuten_trading/api/public_api.rb', line 106

def get_orderbook_with_http_info(symbol_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PublicApi.get_orderbook ...'
  end
  # verify the required parameter 'symbol_id' is set
  if @api_client.config.client_side_validation && symbol_id.nil?
    fail ArgumentError, "Missing the required parameter 'symbol_id' when calling PublicApi.get_orderbook"
  end
  # resource path
  local_var_path = '/orderbook'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'symbolId'] = symbol_id

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  return_type = opts[:return_type] || 'InlineResponse2002' 

  auth_names = opts[:auth_names] || ['ApiKeyAuth', 'SignatureAuth']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type)

  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PublicApi#get_orderbook\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_symbol(opts = {}) ⇒ Array<InlineResponse200>

銘柄一覧取得 利用可能な全銘柄の一覧を取得します。

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :authority (String)

    PERSONAL, CORPORATE。

Returns:



153
154
155
156
# File 'lib/rakuten_trading/api/public_api.rb', line 153

def get_symbol(opts = {})
  data, _status_code, _headers = get_symbol_with_http_info(opts)
  data
end

#get_symbol_with_http_info(opts = {}) ⇒ Array<(Array<InlineResponse200>, Integer, Hash)>

銘柄一覧取得 利用可能な全銘柄の一覧を取得します。

Parameters:

  • opts (Hash) (defaults to: {})

    the optional parameters

Options Hash (opts):

  • :authority (String)

    PERSONAL, CORPORATE。

Returns:

  • (Array<(Array<InlineResponse200>, Integer, Hash)>)

    Array<InlineResponse200> data, response status code and response headers



163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
# File 'lib/rakuten_trading/api/public_api.rb', line 163

def get_symbol_with_http_info(opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PublicApi.get_symbol ...'
  end
  if @api_client.config.client_side_validation && opts[:'authority'] && !['PERSONAL', 'CORPORATE'].include?(opts[:'authority'])
    fail ArgumentError, 'invalid value for "authority", must be one of PERSONAL, CORPORATE'
  end
  # resource path
  local_var_path = '/cfd/symbol'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'authority'] = opts[:'authority'] if !opts[:'authority'].nil?

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  return_type = opts[:return_type] || 'Array<InlineResponse200>' 

  auth_names = opts[:auth_names] || ['ApiKeyAuth', 'SignatureAuth']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type)

  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PublicApi#get_symbol\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_ticker(symbol_id, opts = {}) ⇒ InlineResponse2003

ティッカー取得

Parameters:

  • symbol_id

    シンボルID

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



208
209
210
211
# File 'lib/rakuten_trading/api/public_api.rb', line 208

def get_ticker(symbol_id, opts = {})
  data, _status_code, _headers = get_ticker_with_http_info(symbol_id, opts)
  data
end

#get_ticker_with_http_info(symbol_id, opts = {}) ⇒ Array<(InlineResponse2003, Integer, Hash)>

ティッカー取得

Parameters:

  • symbol_id

    シンボルID

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(InlineResponse2003, Integer, Hash)>)

    InlineResponse2003 data, response status code and response headers



217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
# File 'lib/rakuten_trading/api/public_api.rb', line 217

def get_ticker_with_http_info(symbol_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PublicApi.get_ticker ...'
  end
  # verify the required parameter 'symbol_id' is set
  if @api_client.config.client_side_validation && symbol_id.nil?
    fail ArgumentError, "Missing the required parameter 'symbol_id' when calling PublicApi.get_ticker"
  end
  # resource path
  local_var_path = '/ticker'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'symbolId'] = symbol_id

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  return_type = opts[:return_type] || 'InlineResponse2003' 

  auth_names = opts[:auth_names] || ['ApiKeyAuth', 'SignatureAuth']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type)

  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PublicApi#get_ticker\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end

#get_trades(symbol_id, opts = {}) ⇒ InlineResponse2004

歩み値取得

Parameters:

  • symbol_id

    シンボルID

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:



263
264
265
266
# File 'lib/rakuten_trading/api/public_api.rb', line 263

def get_trades(symbol_id, opts = {})
  data, _status_code, _headers = get_trades_with_http_info(symbol_id, opts)
  data
end

#get_trades_with_http_info(symbol_id, opts = {}) ⇒ Array<(InlineResponse2004, Integer, Hash)>

歩み値取得

Parameters:

  • symbol_id

    シンボルID

  • opts (Hash) (defaults to: {})

    the optional parameters

Returns:

  • (Array<(InlineResponse2004, Integer, Hash)>)

    InlineResponse2004 data, response status code and response headers



272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
# File 'lib/rakuten_trading/api/public_api.rb', line 272

def get_trades_with_http_info(symbol_id, opts = {})
  if @api_client.config.debugging
    @api_client.config.logger.debug 'Calling API: PublicApi.get_trades ...'
  end
  # verify the required parameter 'symbol_id' is set
  if @api_client.config.client_side_validation && symbol_id.nil?
    fail ArgumentError, "Missing the required parameter 'symbol_id' when calling PublicApi.get_trades"
  end
  # resource path
  local_var_path = '/trades'

  # query parameters
  query_params = opts[:query_params] || {}
  query_params[:'symbolId'] = symbol_id

  # header parameters
  header_params = opts[:header_params] || {}
  # HTTP header 'Accept' (if needed)
  header_params['Accept'] = @api_client.select_header_accept(['application/json'])

  # form parameters
  form_params = opts[:form_params] || {}

  # http body (model)
  post_body = opts[:body] 

  return_type = opts[:return_type] || 'InlineResponse2004' 

  auth_names = opts[:auth_names] || ['ApiKeyAuth', 'SignatureAuth']
  data, status_code, headers = @api_client.call_api(:GET, local_var_path,
    :header_params => header_params,
    :query_params => query_params,
    :form_params => form_params,
    :body => post_body,
    :auth_names => auth_names,
    :return_type => return_type)

  if @api_client.config.debugging
    @api_client.config.logger.debug "API called: PublicApi#get_trades\nData: #{data.inspect}\nStatus code: #{status_code}\nHeaders: #{headers}"
  end
  return data, status_code, headers
end