class Object
Public Instance Methods
close(coin, volume)
click to toggle source
# 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)
click to toggle source
# File lib/run.rb, line 31 def contract_account_info coin JSON.parse(Tradecow::Future.contract_account_info(coin).parsed_response)["data"].first["withdraw_available"] end
get_future_info(coin)
click to toggle source
# 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
run()
click to toggle source
# File lib/run.rb, line 51 def run get_future_info 'eth' close 'ETH210625', 743 # amount = contract_account_info('eth') transfer('futures-to-pro', contract_account_info('eth').truncate(8), 'eth') sell('eth', 'ethusdt', 'sell-market', nil) end
sell(coin, type, amount=nil)
click to toggle source
# 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)
click to toggle source
# 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