Отдельно разберём TaskGroup, который пришел на замену gather в Python 3.11.
Ключевые отличия
▫️create_task() возвращает объект asyncio.Task, у которого есть соответствюущие методы управления. То есть у нас больше контроля
▫️это контекстный менеджер, который гарантирует что все таски будут остановлены по выходу из контекста
▫️ошибка автоматически отменяет незавершенные задачи,
▫️except* передает нам ExceptionGroup, в котором каждую ошибку можно обработать отдельно
import asyncio
import random
async def do_it() -> str:
if random.random() < 0.1:
raise ValueError('Oops')
delay = random.uniform(0.5, 1.5)
await asyncio.sleep(delay)
return delay
async def main():
try:
async with asyncio.TaskGroup() as tg:
for _ in range(10):
tasks.append(tg.create_task(do_it()))
for t in tasks:
print(t.result())
except *ValueError as e:
for err in e.exceptions:
print(err)
asyncio.run(main())
Рекомендую изучить страницу Coroutines and Tasks из документации, где представлено больше интересных примеров и механизмов
- таймауты
- отмена задач
- создание задач из другого потока
#async
#LEVER/USDT analysis :
#LEVER is in a downtrend, trading below the 200 EMA. The price is testing the resistance zone and is anticipated to decline from there and test lower levels.
TF : 1H
Entry : $0.000895
Target : $0.000814
SL : $0.000950
#LEVER/USDT analysis :
#LEVER is currently testing the previously respected resistance zone. A rejection is anticipated from this level, and it is expected that the price will subsequently test the previous swing low.
TF : 2h
Entry : $0.001405
Target : $0.001282
SL : $0.001487
#LEVER/USDT analysis :
#LEVER is currently in a correction phase within an overall uptrend, retracing back to the 200 EMA support zone. The price is expected to test this zone and bounce back, which would allow it to continue its bullish momentum and potentially test previous highs.
TF : 2H
Entry : $0.002570
Target : $0.002910
SL : $0.002384
#LEVER/USDT analysis :
#LEVER is currently rejecting from the resistance zone. A decline in price is expected to be seen soon until the previous lows are tested.
TF : 4H
Entry : $0.00214
Target : $0.00180 and $0.00166
SL : $0.00238
#LEVER/USDT analysis :
#Lever has broken out and retested the previous resistance zone. It is now ready to move upside and test the previous swing high.
TF : 15min
Entry : $0.00171
Target : $0.00176
SL : $0.00167
#LEVER/USDT analysis -
#LEVER has broken down below the support level with strong bearish momentum. Wait for the price to retest the broken zone for a short entry. The previous low will be tested.
TF : 4h
Entry : $0.00245
Target : $0.00199
SL : $0.00264
#LEVER/USDT analysis -
#LEVER is currently trading in a downtrend on the higher time frame. The price is currently going through a sideways correction phase. Price is currently trading near the 200 EMA and is expected to reject from there to decline further. The previous low is expected to be tested.
TF : 30min
Entry : $0.00218
Target : $0.00199
SL : $0.00229
#LEVER/USDT analysis -
#LEVER is currently in a downtrend, establishing new lows while trading below the 200EMA. The price is currently rejecting from the 200EMA and resistance zone after a corrective pullback. Price is likely to continue its downward momentum. Further declines are expected to test new lows.
TF : 30min
Entry : $0.00250
Target : $0.00214
SL : $0.00277
🔫Double Kill: #LEVER & #PYTH
Yesterday bot dropped two longs.
Today both detonated with +1000% profit (10x lev)in just one day.
• LEVER → +1284%
• PYTH → +1086%
___
📊Full stats for both strategies are on the screenshot ^^
🔍