Esempio n. 1
0
 def sell(self, symbol, amount_as_target_currency):
     try:
         return self.coinex.order_market(symbol, "sell",
                                         amount_as_target_currency)
     except CoinExApiError as e:
         logprint(e, symbol, amount_as_target_currency)
         return dict(status="undone", msg="order not handled")
Esempio n. 2
0
 def long_task(self):
     for ctr, c in enumerate(coin_instance_list):
         c.long_per_task()
         print(sepet[ctr], c.current_target_low, c.current_target_high,
               c.current_degree)
         logprint(
             dict(symbol=sepet[ctr],
                  target_low=c.current_target_low,
                  target_high=c.current_target_high,
                  degree=c.current_degree))
     print("long task executed", datetime.now())
Esempio n. 3
0
def sell_order(symbol):
    # symbol = "ETHUSDT"
    if asm.is_in_open_position(symbol=symbol):
        amount = asm.get_one_balance_from_open_positions(symbol)
        ret = b.sell(symbol, amount)
        logprint("sell", ret)
        print(ret)
        if ret["status"] == "done":
            avg_price = float(ret.get("avg_price", 0))
            asm.add_trade_history(symbol, "sell", amount, avg_price)
            asm.remove_from_open_positions(symbol)
            asm.update_free_base_balance()
Esempio n. 4
0
def buy_order(symbol):
    # symbol = "ETHUSDT"
    if not asm.is_in_open_position(symbol) and asm.is_left_free_pos():
        pos_base_amount = asm.get_pos_base_amount()
        ret = b.buy(symbol, pos_base_amount)
        print(ret)
        logprint("buy", ret)
        if ret["status"] == "done":
            avg_price = float(ret.get("avg_price", 0))
            amount = asm.get_one_balance_from_exchange(symbol=symbol)
            asm.add_trade_history(symbol, "buy", amount, avg_price)
            asm.add_open_position(symbol, amount)
            asm.update_free_base_balance()