bitflyerのapiを使ってgetcollateralのopen_position_pnlを取得したいのですがエラーになってしまします。どこをどのように修正したらいいでしょうか?
コードrequire "net/http" require "uri" require "openssl" require "json" key = "ほげ" secret = "ほげ" timestamp = Time.now.to_i.to_s method = "GET" uri = URI.parse("https://api.bitflyer.jp") uri.path = "/v1/me/getcollateral" text = timestamp + method + uri.request_uri sign = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha256"), secret, text) options = Net::HTTP::Get.new(uri.request_uri, initheader = { "ACCESS-KEY" => key, "ACCESS-TIMESTAMP" => timestamp, "ACCESS-SIGN" => sign, }); https = Net::HTTP.new(uri.host, uri.port) https.use_ssl = true response = https.request(options) puts response.body json = response.body getpositions = JSON.parse(json) gp = getcollateral.empty? ? 0 : getcollateral[0]["open_position_pnl"] puts gp
エラーコード
l.rb:30:in `<main>': undefined local variable or method `getcollateral' for main:Object (NameError)
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/07/01 08:09 編集
2018/07/01 08:27
2018/07/01 08:52