class Watchcow::MarketDepth

Constants

URLDM
URLPRO

Public Class Methods

call(params:, k:) click to toggle source

Spot market or Futures market all goes here

# File lib/watchcow/market_depth.rb, line 9
def call(params:, k:)
  url = target_url(params, k)
  HTTParty.get(url)
end
prepared_params(params, k) click to toggle source
# File lib/watchcow/market_depth.rb, line 14
def prepared_params(params, k)
  return '' if params.nil?
  step =
    if k == :future
      "&type=step6"
    else
      "&type=step2"
    end
  arr = []
  params.each_pair do |k,v|
    arr.push "#{k}=#{v}"
  end
  return "#{arr.join('&')}#{step}"
end
target_url(params, k) click to toggle source
# File lib/watchcow/market_depth.rb, line 29
def target_url(params, k)
  prefix = k == :future ? URLDM : URLPRO
  "#{prefix}?#{prepared_params(params, k)}"
end