Top Level Namespace

Defined Under Namespace

Modules: Tradecow

Instance Method Summary collapse

Instance Method Details

#close(coin, volume) ⇒ Object



24
25
26
27
28
29
# File 'lib/run.rb', line 24

def close coin, volume
  # Volume 张
  # Tradecow::Future.contract_order 'ltc210924', 100, 'buy', 'close', 'optimal_20'
  r = Tradecow::Future.contract_order coin, volume, 'buy', 'close', 'optimal_20'
  puts r
end

#contract_account_info(coin) ⇒ Object



31
32
33
# File 'lib/run.rb', line 31

def  coin
  JSON.parse(Tradecow::Future.(coin).parsed_response)["data"].first["withdraw_available"]
end

#get_future_info(coin) ⇒ Object



13
14
15
16
17
18
19
20
21
22
# File 'lib/run.rb', line 13

def get_future_info coin
  data = JSON.parse(Tradecow::Future.contract_position_info(coin))['data']
  if data.nil? || data.empty?
    puts "No #{coin} in your account."
  else
    data.map do |x|
      puts "#{x["contract_code"]}, #{x["available"]}"
    end
  end
end

#runObject



51
52
53
54
55
56
57
# File 'lib/run.rb', line 51

def run
  get_future_info 'eth'
  close 'ETH210625', 743
  # amount = contract_account_info('eth')
  transfer('futures-to-pro', ('eth').truncate(8), 'eth')
  sell('eth', 'ethusdt', 'sell-market', nil)
end

#sell(coin, type, amount = nil) ⇒ Object



45
46
47
48
49
# File 'lib/run.rb', line 45

def sell coin, type, amount=nil
  # 即btcusdt, ethbtc...
  # sell-market
  Tradecow::Spot.place_order coin, type, amount
end

#transfer(trans, amount, coin) ⇒ Object



35
36
37
38
39
40
41
42
43
# File 'lib/run.rb', line 35

def transfer trans, amount, coin
  # 盈利部分实时结算列表:
  # BTC, ETH, LTC, LINK, TRX, XRP, ADA
  # 
  # spot to future: "pro-to-futures"
  # future to spot: "futures-to-pro"
  # 最多8位
  Tradecow::Account.transfer(trans, amount, coin)
end