Exemplo n.º 1
0
#print (okcoinSpot.orderHistory('ltc_usd','0','1','2'))

#print (u' 期货行情信息')
#print (okcoinFuture.future_ticker('ltc_usd','this_week'))

#print (u' 期货市场深度信息')
#print (okcoinFuture.future_depth('btc_usd','this_week','6'))

#print (u'期货交易记录信息') 
#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'))
Exemplo n.º 2
0
okcoinSpot = OKCoinSpot(okcoinRESTURL,apikey,secretkey)
#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"))
Exemplo n.º 3
0
print okcoinSpot.orderHistory('ltc_usd','0','1','2')

print u' 期货行情信息'
print okcoinFuture.future_ticker('ltc_usd','this_week')

print u' 期货市场深度信息'
print okcoinFuture.future_depth('ltc_usd','this_week','6')

print u'期货交易记录信息' 
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')
Exemplo n.º 4
0
    is_continue = False

price = float(input_price)
if not 1000 <= price <= 100000:
    print('价格输入格式不正确, 重新输入')
    is_continue = False

if is_continue:
    print('-' * 30)
    print('你将开始一个计划委托:当价格 %s %s 时,平%s单' % (trend, price, category))
    print('-' * 30)
else:
    print('输入不合法,自动退出')
    sys.exit()

rate = okcoinFuture.exchange_rate()['rate']
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']