Skip to content

Instantly share code, notes, and snippets.

@ku
Created December 7, 2020 07:52
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ku/b79e9609e7adc8ccaf9bbbd6ecb5e32d to your computer and use it in GitHub Desktop.
Save ku/b79e9609e7adc8ccaf9bbbd6ecb5e32d to your computer and use it in GitHub Desktop.
urls = [
"https://public.bitbank.cc/eth_btc/candlestick/1hour/20201201?ts=1607320647235",
"https://public.bitbank.cc/eth_btc/candlestick/1hour/20201202?ts=1607320647235",
"https://public.bitbank.cc/eth_btc/candlestick/1hour/20201203?ts=1607320647235",
"https://public.bitbank.cc/eth_btc/candlestick/1hour/20201204?ts=1607320647235",
"https://public.bitbank.cc/eth_btc/candlestick/1hour/20201205?ts=1607320647235",
"https://public.bitbank.cc/eth_btc/candlestick/1hour/20201206?ts=1607320647235",
"https://public.bitbank.cc/eth_btc/candlestick/1hour/20201207?ts=1607320647235",
]
require 'net/http'
require 'pp'
require 'json'
require 'time'
urls.each do |u|
uri = URI u
body = Net::HTTP.get(uri) # => String
r = JSON.parse(body)
r["data"]["candlestick"][0]["ohlcv"].each do |data|
(o, h, l, c, v, t) = data
dt = Time.at( t/1000 )
puts [
dt.to_s,
v,
].join(",") + "\n"
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment