mirror of
https://github.com/freqtrade/freqtrade.git
synced 2025-12-17 05:11:15 +00:00
Merge branch 'develop' into add-current-drawdown-in-telegram-profit-command
This commit is contained in:
@@ -1,6 +1,6 @@
|
||||
import logging
|
||||
import secrets
|
||||
from datetime import datetime, timedelta, timezone
|
||||
from datetime import UTC, datetime, timedelta
|
||||
from typing import Any
|
||||
|
||||
import jwt
|
||||
@@ -89,15 +89,15 @@ async def validate_ws_token(
|
||||
def create_token(data: dict, secret_key: str, token_type: str = "access") -> str: # noqa: S107
|
||||
to_encode = data.copy()
|
||||
if token_type == "access": # noqa: S105
|
||||
expire = datetime.now(timezone.utc) + timedelta(minutes=15)
|
||||
expire = datetime.now(UTC) + timedelta(minutes=15)
|
||||
elif token_type == "refresh": # noqa: S105
|
||||
expire = datetime.now(timezone.utc) + timedelta(days=30)
|
||||
expire = datetime.now(UTC) + timedelta(days=30)
|
||||
else:
|
||||
raise ValueError()
|
||||
to_encode.update(
|
||||
{
|
||||
"exp": expire,
|
||||
"iat": datetime.now(timezone.utc),
|
||||
"iat": datetime.now(UTC),
|
||||
"type": token_type,
|
||||
}
|
||||
)
|
||||
|
||||
@@ -8,6 +8,7 @@ from typing import Any
|
||||
from fastapi import APIRouter, BackgroundTasks, Depends
|
||||
from fastapi.exceptions import HTTPException
|
||||
|
||||
from freqtrade.configuration import remove_exchange_credentials
|
||||
from freqtrade.configuration.config_validation import validate_config_consistency
|
||||
from freqtrade.constants import Config
|
||||
from freqtrade.data.btanalysis import (
|
||||
@@ -20,7 +21,6 @@ from freqtrade.data.btanalysis import (
|
||||
)
|
||||
from freqtrade.enums import BacktestState
|
||||
from freqtrade.exceptions import ConfigurationError, DependencyException, OperationalException
|
||||
from freqtrade.exchange.common import remove_exchange_credentials
|
||||
from freqtrade.ft_types import get_BacktestResultType_default
|
||||
from freqtrade.misc import deep_merge_dicts, is_file_in_dir
|
||||
from freqtrade.rpc.api_server.api_schemas import (
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
from typing import Any, Literal
|
||||
from typing import Any, Literal, NotRequired
|
||||
from uuid import uuid4
|
||||
|
||||
from typing_extensions import NotRequired, TypedDict
|
||||
from typing_extensions import TypedDict
|
||||
|
||||
from freqtrade.exchange.exchange import Exchange
|
||||
|
||||
|
||||
@@ -102,7 +102,7 @@ class WebSocketChannel:
|
||||
self._send_times.append(total_time)
|
||||
|
||||
self._calc_send_limit()
|
||||
except asyncio.TimeoutError:
|
||||
except TimeoutError:
|
||||
logger.info(f"Connection for {self} timed out, disconnecting")
|
||||
raise
|
||||
|
||||
@@ -201,8 +201,8 @@ class WebSocketChannel:
|
||||
try:
|
||||
await task
|
||||
except (
|
||||
TimeoutError,
|
||||
asyncio.CancelledError,
|
||||
asyncio.TimeoutError,
|
||||
WebSocketDisconnect,
|
||||
ConnectionClosed,
|
||||
RuntimeError,
|
||||
|
||||
@@ -266,7 +266,7 @@ class ExternalMessageConsumer:
|
||||
except Exception as e:
|
||||
logger.exception(f"Error handling producer message: {e}")
|
||||
|
||||
except (asyncio.TimeoutError, websockets.exceptions.ConnectionClosed):
|
||||
except (TimeoutError, websockets.exceptions.ConnectionClosed):
|
||||
# We haven't received data yet. Check the connection and continue.
|
||||
try:
|
||||
# ping
|
||||
|
||||
@@ -5,7 +5,7 @@ This module contains class to define a RPC communications
|
||||
import logging
|
||||
from abc import abstractmethod
|
||||
from collections.abc import Generator, Sequence
|
||||
from datetime import date, datetime, timedelta, timezone
|
||||
from datetime import UTC, date, datetime, timedelta
|
||||
from typing import TYPE_CHECKING, Any
|
||||
|
||||
import psutil
|
||||
@@ -375,7 +375,7 @@ class RPC:
|
||||
"""
|
||||
:param timeunit: Valid entries are 'days', 'weeks', 'months'
|
||||
"""
|
||||
start_date = datetime.now(timezone.utc).date()
|
||||
start_date = datetime.now(UTC).date()
|
||||
if timeunit == "weeks":
|
||||
# weekly
|
||||
start_date = start_date - timedelta(days=start_date.weekday()) # Monday
|
||||
@@ -1099,7 +1099,7 @@ class RPC:
|
||||
trade = Trade.get_trades(trade_filter=[Trade.id == trade_id]).first()
|
||||
if not trade:
|
||||
logger.warning("delete trade: Invalid argument received")
|
||||
raise RPCException("invalid argument")
|
||||
raise RPCException(f"Trade with id '{trade_id}' not found.")
|
||||
|
||||
# Try cancelling regular order if that exists
|
||||
for open_order in trade.open_orders:
|
||||
@@ -1120,13 +1120,16 @@ class RPC:
|
||||
c_count += 1
|
||||
except ExchangeError:
|
||||
pass
|
||||
|
||||
trade_pair = trade.pair
|
||||
trade.delete()
|
||||
self._freqtrade.wallets.update()
|
||||
return {
|
||||
"result": "success",
|
||||
"trade_id": trade_id,
|
||||
"result_msg": f"Deleted trade {trade_id}. Closed {c_count} open orders.",
|
||||
"result_msg": (
|
||||
f"Deleted trade #{trade_id} for pair {trade_pair}. "
|
||||
f"Closed {c_count} open orders."
|
||||
),
|
||||
"cancel_order_count": c_count,
|
||||
}
|
||||
|
||||
@@ -1264,7 +1267,7 @@ class RPC:
|
||||
|
||||
for lock in locks:
|
||||
lock.active = False
|
||||
lock.lock_end_time = datetime.now(timezone.utc)
|
||||
lock.lock_end_time = datetime.now(UTC)
|
||||
|
||||
Trade.commit()
|
||||
|
||||
|
||||
@@ -1488,7 +1488,7 @@ class Telegram(RPCHandler):
|
||||
trade_id = int(context.args[0])
|
||||
msg = self._rpc._rpc_delete(trade_id)
|
||||
await self._send_msg(
|
||||
f"`{msg['result_msg']}`\n"
|
||||
f"{msg['result_msg']}\n"
|
||||
"Please make sure to take care of this asset on the exchange manually."
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user