Added get user trades

This commit is contained in:
algizn97
2025-08-21 14:22:54 +05:00
parent 8293c44864
commit d0577f163b

View File

@@ -14,6 +14,7 @@ from app.telegram.database.models import User_Additional_Settings as UAS
from app.telegram.database.models import Trading_Mode
from app.telegram.database.models import Margin_type
from app.telegram.database.models import Trigger
from app.telegram.database.models import USER_DEALS
import app.telegram.functions.functions as func # functions
@@ -133,6 +134,13 @@ async def get_symbol(tg_id):
symbol = await session.scalar(select(User_Symbol.symbol).where(User_Symbol.tg_id == tg_id))
return symbol
async def get_user_trades(tg_id):
async with async_session() as session:
query = select(USER_DEALS.symbol, USER_DEALS.side, USER_DEALS.open_price).where(USER_DEALS.tg_id == tg_id)
result = await session.execute(query)
trades = result.all()
return trades
async def get_for_registration_trading_mode():
async with async_session() as session:
mode = await session.scalar(select(Trading_Mode.mode).where(Trading_Mode.id == 1))
@@ -302,4 +310,6 @@ async def update_commission_fee(tg_id, num):
async with async_session() as session:
await session.execute(update(URMS).where(URMS.tg_id == tg_id).values(commission_fee = num))
await session.commit()
await session.commit()