Пример #1
0
    def future_postion(self, symbol):
        # symbol 样例 btc_usd
        okcoinFuture = OKCoinFuture(okcoinRESTURL, self.apiKey, self.secretKey)

        return okcoinFuture.future_position(symbol, 'quarter')
Пример #2
0
print okcoinFuture.future_trades('ltc_usd','this_week')

print u'期货指数信息'
print okcoinFuture.future_index('ltc_usd')

print u'美元人民币汇率'
print okcoinFuture.exchange_rate()

print u'获取预估交割价' 
print okcoinFuture.future_estimated_price('ltc_usd')

print u'获取全仓账户信息'
print okcoinFuture.future_userinfo()

print u'获取全仓持仓信息'
print okcoinFuture.future_position('ltc_usd','this_week')

print u'期货下单'
print okcoinFuture.future_trade('ltc_usd','this_week','0.1','1','1','0','20')

print u'期货批量下单'
print okcoinFuture.future_batchTrade('ltc_usd','this_week','[{price:0.1,amount:1,type:1,match_price:0},{price:0.1,amount:3,type:1,match_price:0}]','20')

print u'期货取消订单'
print okcoinFuture.future_cancel('ltc_usd','this_week','47231499')

print u'期货获取订单信息'
print okcoinFuture.future_orderinfo('ltc_usd','this_week','47231812','0','1','2')

print u'期货逐仓账户信息'
print okcoinFuture.future_userinfo_4fix()
Пример #3
0
else:
    print('输入不合法,自动退出')
    sys.exit()

print('start>>>>>>>>>>>>>>>>>>>>>>>')

while True:

    try:
        # 获取订单信息
        # 有挂单就继续向下,等待持仓成交, 没挂单,则自动退出
        orders = okcoinFuture.future_orderinfo('btc_usd', 'quarter', '-1', '1', '1', '50')
        orders = json.loads(orders)['orders']

        # 全仓持仓信息
        holding = json.loads(okcoinFuture.future_position('btc_usd','quarter'))['holding'][0]
        buy_available = holding['buy_available']
        sell_available = holding['sell_available']

        # 在没有挂单同时也没有持仓的情况下就要退出
        if not len(orders) and buy_available == 0 and sell_available == 0:
            sys.exit()

        # 平多仓
        if category == 'duo' and buy_available > 0:
            amount = buy_available

            # 获取当前价格参数
            current_price = get_btc_price()
            if current_price:
                current_price = float(current_price)
Пример #4
0
#Load Spot last/bid/ask
#print (u' 期货市场深度信息')
#Fut_Data =okcoinFuture.future_depth('btc_usd','this_week','6')
#Fut_Ask=Fut_Data.get("asks")
#print (Fut_Ask)

#Load next week fut spot/bid/last
print (u' 期货行情信息')
while True:
    try:
        Fut_Data_Next_Quarter_BTC = okcoinFuture.future_ticker('btc_usd','quarter')
        Fut_Data_Next_Quarter_LTC = okcoinFuture.future_ticker('ltc_usd','quarter')
        LTC_Index = okcoinFuture.future_index('ltc_usd')
        BTC_Index = okcoinFuture.future_index('btc_usd')
        USDT_Index = okcoinFuture.exchange_rate()
        LTC_Fut_Pos = json.loads(okcoinFuture.future_position('ltc_usd','quarter')).get('holding')[0].get('sell_amount')
        BTC_Fut_Pos = json.loads(okcoinFuture.future_position('btc_usd','quarter')).get('holding')[0].get('sell_amount')
        Total_Pos = json.loads(okcoinFuture.future_userinfo())
        BTC_Spot_OKCoin = okcoinSpot.ticker('btc_usdt').get('ticker').get('last')
        LTC_Spot_OKCoin = okcoinSpot.ticker('ltc_usdt').get('ticker').get('last')
        #USDT_Spot_OKCoin
        
    except:
        time.sleep(3)
        continue
    else:
        Spot_Price_BTC = BTC_Index["future_index"]
        Spot_Price_LTC = LTC_Index["future_index"]
        Spot_Price_USD = USDT_Index["rate"]
        Fut_Next_Quarter_LTC = float(Fut_Data_Next_Quarter_LTC.get("ticker").get("last"))
        Fut_Next_Quarter_BTC = float(Fut_Data_Next_Quarter_BTC.get("ticker").get("last"))
Пример #5
0
#print (okcoinFuture.future_trades('ltc_usd','this_week'))

#print (u'期货指数信息')
#print (okcoinFuture.future_index('ltc_usd'))

#print (u'美元人民币汇率')
#print (okcoinFuture.exchange_rate())

#print (u'获取预估交割价') 
#print (okcoinFuture.future_estimated_price('ltc_usd'))

#print (u'获取全仓账户信息')
print (okcoinFuture.future_userinfo())

#print (u'获取全仓持仓信息')
print (okcoinFuture.future_position('ltc_usd','quarter'))

#print (u'期货下单')
print (okcoinFuture.future_trade('ltc_usd','quarter','40.00','1','1','0','10'))
# amount:合约张数
# price:美元计价
print (okcoinFuture.future_trade(symbol='ltc_usd',contractType='quarter',
 price='40',amount='1',tradeType='1',matchPrice='0',leverRate='10'))
#print (u'期货批量下单')
#print (okcoinFuture.future_batchTrade('ltc_usd','this_week','[{price:0.1,amount:1,type:1,match_price:0},{price:0.1,amount:3,type:1,match_price:0}]','20'))

#print (u'期货取消订单')
print (okcoinFuture.future_cancel('ltc_usd','quarter','6896600986'))

#print (u'期货获取订单信息')
print (okcoinFuture.future_orderinfo('ltc_usd','quarter','6896592048','0','1','2'))