Esempio n. 1
0
def get_gate_price(symbol, prin):
    gate_price = 0
    try:
        gate_content = GateClient.gate_query.ticker(symbol)
        gate_price = gate_content["last"]
        if prin:
            print common_utils.get_json(gate_content, map)
    except Exception, e:
        print "获取gate的%s价格出错:%s" % (symbol, e.message)
Esempio n. 2
0
def sell_soc(sell_nums):
    # 限价卖  币币交易使用‘spot’账户的
    # buy_soc_result = HuobiService.send_order(amount = "1",source = "api", symbol = "socusdt",_type = "sell-limit",price = "0.0650")
    # 市价卖
    sell_result = HuobiService.send_order(amount=str(sell_nums),
                                          source="api",
                                          symbol="socusdt",
                                          _type="sell-market")
    print common_utils.get_json(sell_result, map)
    if sell_result["status"] == "ok":
        return str(sell_result["data"])
    return ""
Esempio n. 3
0
def buy_wicc():
    usdt_balance = get_coin_balance("usdt")
    print common_utils.get_json(usdt_balance, map)
    if usdt_balance:
        # 这里不抓异常, 出错就把程序停掉, 避免更大的损失
        buy_result = HuobiService.send_order(usdt_balance,
                                             source="api",
                                             symbol="wiccusdt",
                                             _type="buy-market")
        print common_utils.get_json(buy_result, map)
        if buy_result["status"] == "ok":
            return str(buy_result["data"])
    return ""
Esempio n. 4
0
def sell_wicc(sell_nums):
    # 限价卖  币币交易使用‘spot’账户的
    # buy_soc_result = HuobiService.send_order(amount = "1",source = "api", symbol = "wiccusdt",_type = "sell-limit",price = "0.0650")
    # 市价卖
    print "sell_wicc方法中sell_nums:%s" % (str(sell_nums))
    sell_result = HuobiService.send_order(amount=float(sell_nums),
                                          source="api",
                                          symbol="wiccusdt",
                                          _type="sell-market")
    print common_utils.get_json(sell_result, map)
    if sell_result["status"] == "ok":
        return True
    return False
Esempio n. 5
0
def get_soc_wicc_balance():
    balance = HuobiService.get_balance()
    soc_balance = 0
    wicc_balance = 0
    for e in balance["data"]["list"]:
        if e["type"] == "trade" and e["currency"] == "soc":
            soc_balance = int(float(e["balance"]))
        if e["type"] == "trade" and e["currency"] == "wicc":
            wicc_balance = int(float(e["balance"]))
        if soc_balance and wicc_balance:
            break
    j_balance = common_utils.get_json(balance, map)
    # print j_balance
    print "soc_balance = %s; wicc_balance = %s" % (str(soc_balance),
                                                   str(wicc_balance))
Esempio n. 6
0
    # soc_kline = HuobiService.get_kline("socusdt", "1day", "100")
    '''
     2018-09-18 11:11 今天取百日数据算的 k = 6.9950; n = 0.1150; 用这组数据回测收益较低, 所以这里取106日的数据试试
     2018-09-18 106日的数据算出来 k = 9.1002; n = 0.0458
    '''
    days = 106
    soc_kline = HuobiService.get_kline("socusdt", "1day", "%d" % days)
    soc_day_prices = []
    for soc_bean in soc_kline['data']:
        soc_day_prices.append(float(soc_bean['close']))
    print soc_day_prices
    common_utils.write_json("soc_day_prices.txt", soc_day_prices, list)

    time.sleep(5)

    wicc_kline = HuobiService.get_kline("wiccusdt", "1day", "%d" % days)
    wicc_day_prices = []
    for wicc_bean in wicc_kline['data']:
        wicc_day_prices.append(float(wicc_bean['close']))
    print wicc_day_prices
    common_utils.write_json("wicc_day_prices.txt", wicc_day_prices, list)


if __name__ == "__main__":
    print "test main start"
    # get_soc_wicc_day_prices()
    # content = HuobiService.orders_matchresults("socusdt")
    # 12350913620
    content = HuobiService.order_matchresults("12808178820")
    print common_utils.get_json(content, map)