Improvements - tests runnable again

This commit is contained in:
Matthias 2023-02-19 19:51:25 +01:00
parent 65a5cf64df
commit 101d9ab87f
2 changed files with 10 additions and 11 deletions

View File

@ -1,5 +1,5 @@
from datetime import datetime, timezone
from typing import Any, Dict, Optional
from typing import Any, ClassVar, Dict, Optional
from sqlalchemy import String, or_
from sqlalchemy.orm import Mapped, Query, mapped_column
@ -14,7 +14,7 @@ class PairLock(ModelBase):
"""
__tablename__ = 'pairlocks'
# TODO: Properly type query.
query: Any
query: ClassVar[Any]
id: Mapped[int] = mapped_column(primary_key=True)

View File

@ -5,10 +5,9 @@ import logging
from collections import defaultdict
from datetime import datetime, timedelta, timezone
from math import isclose
from typing import Any, Dict, List, Optional
from typing import Any, ClassVar, Dict, List, Optional
from sqlalchemy import (Boolean, DateTime, Enum, Float, ForeignKey, Integer, String,
UniqueConstraint, desc, func)
from sqlalchemy import Enum, Float, ForeignKey, Integer, String, UniqueConstraint, desc, func
from sqlalchemy.orm import Mapped, Query, lazyload, mapped_column, relationship
from freqtrade.constants import (DATETIME_PRINT_FORMAT, MATH_CLOSE_PREC, NON_OPEN_EXCHANGE_STATES,
@ -37,7 +36,7 @@ class Order(ModelBase):
"""
__tablename__ = 'orders'
# TODO: Properly type query.
query: Any
query: ClassVar[Any]
# Uniqueness should be ensured over pair, order_id
# its likely that order_id is unique per Pair on some exchanges.
__table_args__ = (UniqueConstraint('ft_pair', 'order_id', name="_order_pair_order_id"),)
@ -1174,8 +1173,8 @@ class Trade(ModelBase, LocalTrade):
"""
__tablename__ = 'trades'
# TODO: Type query type throughout.
query: Any
session: Any = None
query: ClassVar[Any]
session: ClassVar[Any] = None
use_db: bool = True
@ -1197,11 +1196,11 @@ class Trade(ModelBase, LocalTrade):
fee_close_cost: Mapped[Optional[float]] = mapped_column(Float(), nullable=True)
fee_close_currency: Mapped[Optional[str]] = mapped_column(String(25), nullable=True)
open_rate: Mapped[float] = mapped_column(Float())
open_rate_requested: float = mapped_column(Float())
open_rate_requested: Mapped[float] = mapped_column(Float())
# open_trade_value - calculated via _calc_open_trade_value
open_trade_value = mapped_column(Float())
close_rate: Optional[float] = mapped_column(Float())
close_rate_requested: Optional[float] = mapped_column(Float())
close_rate: Mapped[Optional[float]] = mapped_column(Float())
close_rate_requested: Mapped[Optional[float]] = mapped_column(Float())
realized_profit: Mapped[float] = mapped_column(Float(), default=0.0)
close_profit: Mapped[Optional[float]] = mapped_column(Float())
close_profit_abs: Mapped[Optional[float]] = mapped_column(Float())