Merge pull request #8264 from xmatthias/sqlalchemy_2

Sqlalchemy 2
This commit is contained in:
Matthias
2023-03-02 18:23:01 +01:00
committed by GitHub
18 changed files with 242 additions and 175 deletions

View File

@@ -2440,6 +2440,7 @@ def test_select_filled_orders(fee):
def test_order_to_ccxt(limit_buy_order_open):
order = Order.parse_from_ccxt_object(limit_buy_order_open, 'mocked', 'buy')
order.ft_trade_id = 1
order.query.session.add(order)
Order.query.session.commit()

View File

@@ -7,6 +7,7 @@ from datetime import datetime
from pandas import DataFrame
from freqtrade.persistence.trade_model import Order
from freqtrade.strategy.interface import IStrategy
@@ -35,7 +36,7 @@ class TestStrategyImplementBuyTimeout(TestStrategyNoImplementSell):
def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
return super().populate_exit_trend(dataframe, metadata)
def check_buy_timeout(self, pair: str, trade, order: dict,
def check_buy_timeout(self, pair: str, trade, order: Order,
current_time: datetime, **kwargs) -> bool:
return False
@@ -44,6 +45,6 @@ class TestStrategyImplementSellTimeout(TestStrategyNoImplementSell):
def populate_exit_trend(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
return super().populate_exit_trend(dataframe, metadata)
def check_sell_timeout(self, pair: str, trade, order: dict,
def check_sell_timeout(self, pair: str, trade, order: Order,
current_time: datetime, **kwargs) -> bool:
return False

View File

@@ -197,7 +197,7 @@ class StrategyTestV3(IStrategy):
if current_profit < -0.0075:
orders = trade.select_filled_orders(trade.entry_side)
return round(orders[0].cost, 0)
return round(orders[0].safe_cost, 0)
return None

View File

@@ -3036,6 +3036,7 @@ def test_handle_cancel_enter(mocker, caplog, default_conf_usdt, limit_order, is_
# Order remained open for some reason (cancel failed)
cancel_buy_order['status'] = 'open'
cancel_order_mock = MagicMock(return_value=cancel_buy_order)
trade.open_order_id = 'some_open_order'
mocker.patch(f'{EXMS}.cancel_order_with_result', cancel_order_mock)
assert not freqtrade.handle_cancel_enter(trade, l_order, reason)
assert log_has_re(r"Order .* for .* not cancelled.", caplog)
@@ -3231,6 +3232,7 @@ def test_handle_cancel_exit_cancel_exception(mocker, default_conf_usdt) -> None:
trade = MagicMock()
reason = CANCEL_REASON['TIMEOUT']
order = {'remaining': 1,
'id': '125',
'amount': 1,
'status': "open"}
assert not freqtrade.handle_cancel_exit(trade, order, reason)