Created
December 7, 2020 07:52
-
-
Save ku/b79e9609e7adc8ccaf9bbbd6ecb5e32d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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