Ejemplo n.º 1
0
    current_accounts = broker.get_accounts()    
    
    buy_orders = []
    for coin in coin_data:
        cond_buy, cond_sell = myStrategyRSI(coin)
        account = current_accounts.get(coin.coin_name)
        if account:
            if account["balance"] > 0 and not account["locked"]: # 현재 코인 있음
                if cond_sell and cond_buy:
                    continue
                elif cond_sell:
                    broker.sell(coin.coin_name, account["balance"], coin.df["trade_price"][-2]) #전일종가에 판매           

        else:
            market_info = broker.marketCheck(coin.coin_name)
            if not market_info["market"]["state"] == "active":
                continue
            if cash_per_order<5000:
                continue

            if cond_buy:
                order_volume = (cash_per_order * (1-float(market_info["bid_fee"])) / coin.last_price)
                order = {
                    "coin": coin,
                    "coin_name": coin.coin_name,
                    "volume": order_volume,
                    "price" : coin.last_price,
                }
                buy_orders.append(order)