Exemplo n.º 1
0
    def api_get(self, method, params={}):
        # 现货API
        if self.account:
            apikey, secretkey = get_account_key("okex", self.account)
        okcoinSpot = OKCoinFuture(okcoinRESTURL, apikey, secretkey)
        if method == "future_userinfo_4fix":
            api_do = "okcoinSpot.%s()" % (method)
            return eval(api_do)

        elif method == "future_position_4fix":
            return okcoinSpot.future_position_4fix(params["symbol"],
                                                   params["contractType"],
                                                   params["type"])

        elif method == "trade":
            return okcoinSpot.future_trade(params["symbol"],
                                           params["contractType"],
                                           params["price"], params["amount"],
                                           params["type"],
                                           params["match_price"],
                                           params["lever_rate"])

        elif method == "ticker":
            return okcoinSpot.future_ticker(params["symbol"],
                                            params["contractType"])

        elif method == "order_info":
            return okcoinSpot.future_orderinfo(params["symbol"],
                                               params["contractType"],
                                               params["id"])

        elif method == "orders_info":
            return okcoinSpot.future_orderinfo(params["symbol"],
                                               params["contractType"],
                                               -1,
                                               status=1)

        elif method == "cancelOrder":
            return okcoinSpot.future_cancel(params["symbol"],
                                            params["contractType"],
                                            params["id"])
        elif method == "future_estimated_price":
            return okcoinSpot.future_estimated_price(params["symbol"])

        elif method == "future_depth":
            return okcoinSpot.future_depth(params.get("symbol"),
                                           params.get("contractType"),
                                           params.get("size"))
        elif method == "cancelOrders":
            return okcoinSpot.future_cancelorders(params["symbol"],
                                                  params["contractType"],
                                                  params["id"])
Exemplo n.º 2
0
hedge_2 = {'buy': buy_next_week, 'sell': sell_this_week}

my_outlier = Outlier(dbconfig)
##slope, intercept, r_value, p_value, std_err  = my_outlier.generate_linear('btc_usd', '1min', 'this_week')

hedge_1_position = 0
hedge_2_position = 0

while True:
    time.sleep(0.2)
    sample_mean = my_outlier.generate_anchor('btc_usd', '1min', 'this_week')
    print(sample_mean)

    okcoinFuture = OKCoinFuture(okcoinRESTURL, apikey, secretkey)

    this_week_depth = okcoinFuture.future_depth('btc_usd', 'this_week', '5')
    this_week_depth_asks = this_week_depth['asks']
    this_week_depth_bids = this_week_depth['bids']
    '''
    print('this_week_depth_asks')
    print(this_week_depth_asks)
    
    print('this_week_depth_bids')
    print(this_week_depth_bids)
    '''

    next_week_depth = okcoinFuture.future_depth('btc_usd', 'next_week', '5')
    next_week_depth_asks = next_week_depth['asks']
    next_week_depth_bids = next_week_depth['bids']
    '''
    print('next_week_depth_asks')
Exemplo n.º 3
0
print okcoinSpot.cancelOrder('ltc_usd','18243073')

print u' 现货订单信息查询 '
print okcoinSpot.orderinfo('ltc_usd','18243644')

print u' 现货批量订单信息查询 '
print okcoinSpot.ordersinfo('ltc_usd','18243800,18243801,18243644','0')

print u' 现货历史订单信息查询 '
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()
Exemplo n.º 4
0
#print (okcoinSpot.cancelOrder('ltc_usd','18243073'))

#print (u' 现货订单信息查询 ')
#print (okcoinSpot.orderinfo(Species[i],'18243644'))

#print (u' 现货批量订单信息查询 ')
#print (okcoinSpot.ordersinfo('ltc_usd','18243800,18243801,18243644','0'))

#print (u' 现货历史订单信息查询 ')
#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','quarter','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())