Exemple #1
0
def sell(amount, symbol):
    if not DEBUG:
        HuobiService.send_order(amount, '', symbol, 'sell-market')
    coinid = symbol.replace('usdt', '')
    usdtcoins[coinid]['buyprice'] = 0
    usdtcoins[coinid]['buy'] = False
    usdtcoins['usdt']['balance'] += amount * kline[symbol]['close']
    usdtcoins[coinid]['balance'] -= amount
    print 'sell', amount, symbol
Exemple #2
0
def buy(amount, symbol):
    if not DEBUG:
        HuobiService.send_order(amount, '', symbol, 'buy-market')
    coinid = symbol.replace('usdt', '')
    usdtcoins[coinid]['buyprice'] = kline[symbol]['close']
    usdtcoins[coinid]['buy'] = True
    usdtcoins['usdt']['balance'] -= amount
    usdtcoins[coinid]['balance'] += amount / kline[symbol]['close']
    print 'buy', amount, symbol
Exemple #3
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 ""
Exemple #4
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 ""
Exemple #5
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