2
0
forked from kodorvan/stcs

Compare commits

18 Commits

Author SHA1 Message Date
algizn97
29c168e31d Added error information output 2025-10-30 12:45:22 +05:00
245cadf650 Merge pull request 'devel' (#27) from Alex/stcs:devel into stable
Reviewed-on: kodorvan/stcs#27
2025-10-30 12:28:18 +07:00
8d32439a15 Merge pull request 'Switched to demo mode' (#26) from Alex/stcs:devel into stable
Reviewed-on: kodorvan/stcs#26
2025-10-27 21:45:00 +07:00
690d793e8c Merge pull request 'Fixed the counting of the series, added a request to set the serial number' (#25) from Alex/stcs:devel into stable
Reviewed-on: kodorvan/stcs#25
2025-10-26 22:09:25 +07:00
ab752b5dd8 Merge pull request 'adjusted profit' (#24) from Alex/stcs:devel into stable
Reviewed-on: kodorvan/stcs#24
2025-10-26 21:18:20 +07:00
ca7bd5c795 Merge pull request 'Shtoto' (#23) from Alex/stcs:devel into stable
Reviewed-on: kodorvan/stcs#23
2025-10-26 16:39:41 +07:00
46c890f7af Merge pull request 'The range of TP and SL settings has been changed' (#22) from Alex/stcs:devel into stable
Reviewed-on: kodorvan/stcs#22
2025-10-25 23:43:24 +07:00
2d7acb491e Merge pull request 'разъебаться по полной' (#21) from Alex/stcs:devel into stable
Reviewed-on: kodorvan/stcs#21
2025-10-25 21:05:58 +07:00
12d1db16d3 вот бы ебануло нормально...
Reviewed-on: kodorvan/stcs#20
2025-10-25 19:54:27 +07:00
0a369b10f2 Merge pull request 'devel' (#19) from Alex/stcs:devel into stable
Reviewed-on: kodorvan/stcs#19
2025-10-23 14:35:32 +07:00
7b1a803db4 Merge pull request 'Fixed the switch trading mode, adjusted the take profit, added a trading cycle' (#18) from Alex/stcs:devel into stable
Reviewed-on: kodorvan/stcs#18
2025-10-22 22:20:21 +07:00
9fcd92cc72 Merge pull request 'The formula for calculating the number of contracts by price has been changed' (#17) from Alex/stcs:devel into stable
Reviewed-on: kodorvan/stcs#17
2025-10-21 20:33:42 +07:00
97a199f31e Merge pull request 'devel' (#16) from Alex/stcs:devel into stable
Reviewed-on: kodorvan/stcs#16
2025-10-18 18:09:23 +07:00
951bc15957 Merge pull request 'devel' (#15) from Alex/stcs:devel into stable
Reviewed-on: kodorvan/stcs#15
2025-10-12 17:26:11 +07:00
5937058899 Merge pull request 'The database has been converted to SQLite' (#14) from Alex/stcs:devel into stable
Reviewed-on: kodorvan/stcs#14
2025-10-12 14:35:54 +07:00
f0732607e2 Merge pull request 'The instruction has been corrected' (#13) from Alex/stcs:devel into stable
Reviewed-on: kodorvan/stcs#13
2025-10-11 16:36:48 +07:00
56af1d8f3b Merge pull request 'Added migrations for the database' (#12) from Alex/stcs:devel into stable
Reviewed-on: kodorvan/stcs#12
2025-10-11 15:49:40 +07:00
9f069df68a Merge pull request 'devel' (#11) from Alex/stcs:devel into stable
Reviewed-on: kodorvan/stcs#11
2025-10-11 11:58:36 +07:00
3 changed files with 221 additions and 209 deletions

View File

@@ -107,7 +107,8 @@ async def start_trading_cycle(
"position idx not match position mode", "position idx not match position mode",
"Qty invalid", "Qty invalid",
"The number of contracts exceeds maximum limit allowed", "The number of contracts exceeds maximum limit allowed",
"The number of contracts exceeds minimum limit allowed" "The number of contracts exceeds minimum limit allowed",
"Order placement failed as your position may exceed the max",
} }
else None else None
) )
@@ -193,6 +194,7 @@ async def trading_cycle_profit(
"ab not enough for new order", "ab not enough for new order",
"InvalidRequestError", "InvalidRequestError",
"The number of contracts exceeds maximum limit allowed", "The number of contracts exceeds maximum limit allowed",
"Order placement failed as your position may exceed the max",
} }
else None else None
) )
@@ -293,6 +295,7 @@ async def trading_cycle(
"ab not enough for new order", "ab not enough for new order",
"InvalidRequestError", "InvalidRequestError",
"The number of contracts exceeds maximum limit allowed", "The number of contracts exceeds maximum limit allowed",
"Order placement failed as your position may exceed the max",
} }
else None else None
) )
@@ -363,6 +366,7 @@ async def open_positions(
"Qty invalid": "Qty invalid", "Qty invalid": "Qty invalid",
"The number of contracts exceeds maximum limit allowed": "The number of contracts exceeds maximum limit allowed", "The number of contracts exceeds maximum limit allowed": "The number of contracts exceeds maximum limit allowed",
"The number of contracts exceeds minimum limit allowed": "The number of contracts exceeds minimum limit allowed", "The number of contracts exceeds minimum limit allowed": "The number of contracts exceeds minimum limit allowed",
"Order placement failed as your position may exceed the max": "Order placement failed as your position may exceed the max",
} }
for key, msg in known_errors.items(): for key, msg in known_errors.items():
if key in error_text: if key in error_text:

View File

@@ -64,6 +64,14 @@ class TelegramMessageHandler:
exec_fees = format_value(execution.get("execFee")) exec_fees = format_value(execution.get("execFee"))
fee_rate = format_value(execution.get("feeRate")) fee_rate = format_value(execution.get("feeRate"))
side = format_value(execution.get("side")) side = format_value(execution.get("side"))
user_auto_trading = await rq.get_user_auto_trading(
tg_id=tg_id, symbol=symbol
)
auto_trading = (
user_auto_trading.auto_trading if user_auto_trading else False
)
if auto_trading:
side_rus = ( side_rus = (
"Покупка" "Покупка"
if side == "Buy" if side == "Buy"
@@ -81,9 +89,7 @@ class TelegramMessageHandler:
tg_id=tg_id, symbol=symbol, fee=safe_float(exec_fee) tg_id=tg_id, symbol=symbol, fee=safe_float(exec_fee)
) )
user_auto_trading = await rq.get_user_auto_trading(
tg_id=tg_id, symbol=symbol
)
get_total_fee = user_auto_trading.total_fee get_total_fee = user_auto_trading.total_fee
total_fee = safe_float(exec_fee) + safe_float(get_total_fee) total_fee = safe_float(exec_fee) + safe_float(get_total_fee)
@@ -96,15 +102,11 @@ class TelegramMessageHandler:
"Сделка закрыта:" if safe_float(closed_size) > 0 else "Сделка открыта:" "Сделка закрыта:" if safe_float(closed_size) > 0 else "Сделка открыта:"
) )
text = f"{header}\n" f"Торговая пара: {symbol}\n" text = f"{header}\n" f"Торговая пара: {symbol}\n"
auto_trading = (
user_auto_trading.auto_trading if user_auto_trading else False
)
user_deals_data = await rq.get_user_deal_by_symbol( user_deals_data = await rq.get_user_deal_by_symbol(
tg_id=tg_id, symbol=symbol tg_id=tg_id, symbol=symbol
) )
commission_fee = user_deals_data.commission_fee commission_fee = user_deals_data.commission_fee or "Yes_commission_fee"
commission_place = user_deals_data.commission_place commission_place = user_deals_data.commission_place or "Commission_for_qty"
current_series = user_deals_data.current_series current_series = user_deals_data.current_series
current_step = user_deals_data.current_step current_step = user_deals_data.current_step
order_quantity = user_deals_data.order_quantity order_quantity = user_deals_data.order_quantity
@@ -181,8 +183,8 @@ class TelegramMessageHandler:
stop_loss_price=stop_loss_price, stop_loss_price=stop_loss_price,
position_idx=0) position_idx=0)
take_profit_truncated = await truncate_float(take_profit_price, 4) take_profit_truncated = await truncate_float(take_profit_price, 6)
stop_loss_truncated = await truncate_float(stop_loss_price, 4) stop_loss_truncated = await truncate_float(stop_loss_price, 6)
text += (f"Движение: {side_rus}\n" text += (f"Движение: {side_rus}\n"
f"Тейк-профит: {take_profit_truncated}\n" f"Тейк-профит: {take_profit_truncated}\n"
@@ -192,8 +194,8 @@ class TelegramMessageHandler:
new_pnl = safe_float(pnl_series) + total_pnl new_pnl = safe_float(pnl_series) + total_pnl
await rq.set_pnl_series_by_symbol( await rq.set_pnl_series_by_symbol(
tg_id=tg_id, symbol=symbol, pnl_series=new_pnl) tg_id=tg_id, symbol=symbol, pnl_series=new_pnl)
text += f"\nДоход: {ex_pnl:.4f}\n" text += f"\nПрибыль без комиссии: {ex_pnl:.4f}\n"
text += f"Реализованный PNL: {total_pnl:.4f}\n" text += f"Реализованная прибыль: {total_pnl:.4f}\n"
text += f"Прибыль серии: {safe_float(new_pnl):.4f}\n" text += f"Прибыль серии: {safe_float(new_pnl):.4f}\n"
await self.telegram_bot.send_message( await self.telegram_bot.send_message(
@@ -240,6 +242,7 @@ class TelegramMessageHandler:
"ab not enough for new order": "❗️ Недостаточно средств для продолжения торговли", "ab not enough for new order": "❗️ Недостаточно средств для продолжения торговли",
"InvalidRequestError": "❗️ Недостаточно средств для размещения нового ордера с заданным количеством и плечом.", "InvalidRequestError": "❗️ Недостаточно средств для размещения нового ордера с заданным количеством и плечом.",
"The number of contracts exceeds maximum limit allowed": "❗️ Превышен максимальный лимит ставки", "The number of contracts exceeds maximum limit allowed": "❗️ Превышен максимальный лимит ставки",
"Order placement failed as your position may exceed the max": "❗️ Превышен максимальный лимит ставки",
} }
error_text = errors.get( error_text = errors.get(
res, "❗️ Не удалось открыть новую сделку" res, "❗️ Не удалось открыть новую сделку"
@@ -283,6 +286,7 @@ class TelegramMessageHandler:
"ab not enough for new order": "❗️ Недостаточно средств для продолжения торговли", "ab not enough for new order": "❗️ Недостаточно средств для продолжения торговли",
"InvalidRequestError": "❗️ Недостаточно средств для размещения нового ордера с заданным количеством и плечом.", "InvalidRequestError": "❗️ Недостаточно средств для размещения нового ордера с заданным количеством и плечом.",
"The number of contracts exceeds maximum limit allowed": "❗️ Превышен максимальный лимит ставки", "The number of contracts exceeds maximum limit allowed": "❗️ Превышен максимальный лимит ставки",
"Order placement failed as your position may exceed the max": "❗️ Превышен максимальный лимит ставки",
} }
error_text = errors.get( error_text = errors.get(
res, "❗️ Не удалось открыть новую сделку" res, "❗️ Не удалось открыть новую сделку"

View File

@@ -97,7 +97,8 @@ async def start_trading(callback_query: CallbackQuery, state: FSMContext) -> Non
"Limit price is out min price": "Цена лимитного ордера меньше допустимого", "Limit price is out min price": "Цена лимитного ордера меньше допустимого",
"Limit price is out max price": "Цена лимитного ордера больше допустимого", "Limit price is out max price": "Цена лимитного ордера больше допустимого",
"Risk is too high for this trade": "Риск сделки превышает допустимый убыток", "Risk is too high for this trade": "Риск сделки превышает допустимый убыток",
"estimated will trigger liq": "Лимитный ордер может вызвать мгновенную ликвидацию. Проверьте параметры ордера.", "estimated will trigger liq": "Лимитный ордер может вызвать мгновенную ликвидацию. "
"Проверьте параметры ордера.",
"ab not enough for new order": "Недостаточно средств для создания нового ордера", "ab not enough for new order": "Недостаточно средств для создания нового ордера",
"InvalidRequestError": "Произошла ошибка при запуске торговли.", "InvalidRequestError": "Произошла ошибка при запуске торговли.",
"Order does not meet minimum order value": "Сумма ставки меньше допустимого для запуска торговли. " "Order does not meet minimum order value": "Сумма ставки меньше допустимого для запуска торговли. "
@@ -106,6 +107,9 @@ async def start_trading(callback_query: CallbackQuery, state: FSMContext) -> Non
"Qty invalid": "Некорректное значение ставки для данного инструмента", "Qty invalid": "Некорректное значение ставки для данного инструмента",
"The number of contracts exceeds maximum limit allowed": "️️Превышен максимальный лимит ставки", "The number of contracts exceeds maximum limit allowed": "️️Превышен максимальный лимит ставки",
"The number of contracts exceeds minimum limit allowed": "️️Лимит ставки меньше минимально допустимого", "The number of contracts exceeds minimum limit allowed": "️️Лимит ставки меньше минимально допустимого",
"Order placement failed as your position may exceed the max":
"Не удалось разместить ордер, так как ваша позиция может превышать максимальный лимит."
"Пожалуйста, уменьшите кредитное плечо, чтобы увеличить максимальное значение"
} }
if res == "OK": if res == "OK":