bitFlyerの約定履歴を取得するAPIをたたくと、
require 'net/http'
require 'uri'
require 'json'
def get_execution
uri = URI.parse("https://api.bitflyer.jp")
uri.path = "/v1/getexecutions"
uri.query = "product_code=FX_BTC_JPY"
https = Net::HTTP.new(uri.host, uri.port)
https.use_ssl = true
response = https.get uri.request_uri
response_hash = JSON.parse(response.body)
response_hash
end
puts get_execution
結果として
{"id"=>305620858, "side"=>"BUY", "price"=>718665.0, "size"=>0.30960986, "exec_date"=>"2018-07-15T07:37:37.64", "buy_child_order_acceptance_id"=>"JRF20180715-073737-775297", "sell_child_order_acceptance_id"=>"JRF20180715-073735-355829"}
このようなハッシュが100個、配列に入って返ってきます。
そこで、返ってきた100のハッシュの"side"の値だけを取り出したいのですが、方法がわかりません。
どなたか知恵を貸していただけないでしょうか...。
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/07/17 07:28
2018/07/17 07:29