Пример #1
0
                quote = float(okcoinSpot.ticker(symbol + '_btc')['ticker']['last'])
            freeamount += float(freeinfo[symbol]) * quote
            freezedamount += float(freezedinfo[symbol]) * quote

            pass

spotamount = freezedamount + freeamount
btcquote = 110000
print('Okex')
print('SpotAccount')
print('BTC: ' + str(spotamount))
print('RMB: ' + str(btcquote * spotamount))

# tradeinfo = okcoinFuture.future_trades(symbol=symbol, contractType='this_week')

futinfo = okcoinFuture.future_userinfo()
futinfo = json.loads(futinfo)
accountrights = 0

if futinfo['result']:
    futaccount = futinfo['info']
    for symbol in futaccount:
        if symbol == 'btc':
            accountrights += futaccount[symbol]['account_rights']
        else:
            quote = float(okcoinSpot.ticker(symbol + '_btc')['ticker']['last'])
            accountrights += futaccount[symbol]['account_rights'] * quote

print('FutAccount')
print('BTC: ' + str(accountrights))
print('RMB: ' + str(btcquote * accountrights))
Пример #2
0
    addRate = [1, 0.5, 0.25, 0.125, 0.06125]  # 单次加仓比例
    addCount = 0  # 加仓次数
    addMaxTime = 3  # 最大加仓次数
    addTime = 0  # 可加仓次数,用于计算
    addCoin = 0  # 加仓币数
    addPositionStop = 0.3  # 加仓到50%仓位时停止
    breakAtrRate = [5, 3, 3, 3, 3, 1]  # 价格顺势突破2倍atr,则加仓

    slideProtect = 0.0015  # 防滑点修正参数

    # 资金参数
    # 获取本金数量
    initialCoin = 0
    try:
        initialCoin = float(
            json.loads(okcoinFuture.future_userinfo())['info'][coinType]
            ['account_rights'])
    except:
        restart_program()
    restCoin = initialCoin  # 剩余币数,初始为1000
    leverRate = 20  # 杠杆倍率
    useCoin = 0  # 开仓币数
    leverFullCoin = initialCoin * leverRate  # 满仓可开资金 = 本金 * 杠杆
    useLeverCoin = useCoin * leverRate  # 持仓量 = 开仓币数 * 杠杆
    useAmount = 0  # 已开合约张数
    addCoin = 0  # 加仓币数
    addAmount = 0  # 加仓合约张数
    handFee = 0.001  # 手续费:0.05%

    operatePrice = 0  # 开仓价格
    operateState = 'empty'  # 初始仓位状态:空仓
Пример #3
0
#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"))
        #Compute Basis
        
Пример #4
0
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')

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')
Пример #5
0
#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'))

#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'))