Beispiel #1
0
 async def deleteSelfStock(self, stock_name: str) -> str:
     dbo = DataBaseOperator()
     orders = dbo.searchAllWithField(AliveOrder, AliveOrder.stock_name, stock_name)
     holdings = dbo.searchAllWithField(UserHoldings, UserHoldings.stock_name, stock_name)
     if orders or holdings:
         return "已有订单或持仓,不能删除"
     else:
         name = stock_name
         dbo.delete(StockInformation, StockInformation.stock_name, stock_name)
         return stock_name + "删除成功"
Beispiel #2
0
 async def searchUserInformation(self, user_id: str) -> str:
     dbo = DataBaseOperator()
     user = dbo.searchOne(UserInformation, UserInformation.user_id, user_id)
     if not user:
         return "查询失败,您尚未注册"
     holdings = dbo.searchAllWithField(UserHoldings, UserHoldings.user_id,
                                       user_id)
     user.total_money_amount = 0
     for holding in holdings:
         try:
             price_now = dbo.searchOne(StockInformation,
                                       StockInformation.stock_name,
                                       holding.stock_name).now_price
             user.total_money_amount += holding.stock_amount * price_now
         except:
             return "查询个人信息失败,自选股被非法删除,请联系管理员"
     user.total_money_amount += user.free_money_amount
     dbo.update()
     rst = "您好,{},您当前的账户信息如下:\n".format(user_id)
     if type(user) == list:
         for item in user:
             rst += str(item) + "\n"
             rst += "-------------\n"
     else:
         rst += str(user)
     return rst
Beispiel #3
0
    async def searchUserHoldings(self, user_id: str) -> str:
        dbo = DataBaseOperator()
        dbo.delete(UserHoldings, UserHoldings.stock_amount, 0)
        userHoldings = dbo.searchAllWithField(UserHoldings, UserHoldings.user_id, user_id)
        if not userHoldings:
            return "您当前没有持仓"
        else:
            rst = "您好,{},您当前的持仓情况是:\n".format(user_id)
            if type(userHoldings) == list:
                for item in userHoldings:
                    rst += str(item) + "\n"
                    rst += "-------------\n"
            else:
                rst += str(userHoldings)

            return rst
Beispiel #4
0
    async def searchAliveOrders(self, user_id: str) -> str:
        dbo = DataBaseOperator()
        dbo.delete(AliveOrder, AliveOrder.is_alive, False)
        flushAliveOrders()
        aliveorders = dbo.searchAllWithField(AliveOrder, AliveOrder.user_id, user_id)
        if not aliveorders:
            return "您当前没有有效订单"
        else:
            rst = "您好,{},您当前的订单情况是:\n".format(user_id)
            if type(aliveorders) == list:
                for item in aliveorders:
                    rst += str(item) + "\n"
                    rst += "-------------\n"
            else:
                rst += str(aliveorders)

            return rst