Cleanup some nitpicks

This commit is contained in:
Matthias 2024-03-03 12:46:46 +01:00
parent 1176c16b93
commit 30b4f27152
3 changed files with 3 additions and 3 deletions

View File

@ -107,6 +107,7 @@ class CustomDataWrapper:
@staticmethod
def delete_custom_data(trade_id: int) -> None:
_CustomData.session.query(_CustomData).filter(_CustomData.ft_trade_id == trade_id).delete()
_CustomData.session.commit()
@staticmethod
def get_custom_data(*, trade_id: int, key: Optional[str] = None) -> List[_CustomData]:

View File

@ -343,7 +343,6 @@ class LocalTrade:
id: int = 0
orders: List[Order] = []
custom_data: List[_CustomData] = []
exchange: str = ''
pair: str = ''
@ -1507,7 +1506,7 @@ class Trade(ModelBase, LocalTrade):
innerjoin=True) # type: ignore
custom_data: Mapped[List[_CustomData]] = relationship(
"_CustomData", cascade="all, delete-orphan",
lazy="raise") # type: ignore
lazy="raise")
exchange: Mapped[str] = mapped_column(String(25), nullable=False) # type: ignore
pair: Mapped[str] = mapped_column(String(25), nullable=False, index=True) # type: ignore
@ -1613,7 +1612,6 @@ class Trade(ModelBase, LocalTrade):
CustomDataWrapper.delete_custom_data(trade_id=self.id)
_CustomData.session.commit()
Trade.session.delete(self)
Trade.commit()

View File

@ -2099,6 +2099,7 @@ def test_Trade_object_idem():
'get_mix_tag_performance',
'get_trading_volume',
'validate_string_len',
'custom_data'
)
EXCLUDES2 = ('trades', 'trades_open', 'bt_trades_open_pp', 'bt_open_open_trade_count',
'total_profit', 'from_json',)