Class: Huo::Market
- Inherits:
-
Object
- Object
- Huo::Market
- Defined in:
- lib/huo/market.rb
Constant Summary collapse
- DETAIL_API_PATH =
'http://api.huobi.com/staticmarket/detail_btc_json.js'- SIMPLE_API_PATH =
'http://api.huobi.com/staticmarket/ticker_btc_json.js'
Instance Method Summary collapse
Instance Method Details
#api_path_for(param = '1min') ⇒ Object
23 24 25 26 27 28 29 30 31 32 33 34 35 36 |
# File 'lib/huo/market.rb', line 23 def api_path_for(param = '1min') period = case param when '1min' then '001' when '5min' then '005' when '15min' then '015' when '30min' then '030' when '60min' then '060' when 'day' then '100' when 'week' then '200' when 'month' then '300' when 'year' then '400' end "http://api.huobi.com/staticmarket/btc_kline_#{period}_json.js" end |
#get_detail_data ⇒ Object
18 19 20 21 |
# File 'lib/huo/market.rb', line 18 def get_detail_data json = RestClient.get(DETAIL_API_PATH) JSON.parse(json) end |
#get_simple_data ⇒ Object
8 9 10 11 12 13 14 15 16 |
# File 'lib/huo/market.rb', line 8 def get_simple_data json = nil begin json = RestClient.get(SIMPLE_API_PATH) rescue SocketError return nil end JSON.parse(json).tap { |h| h['time'] = Time.at(h['time'].to_i) } end |