Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.
10 changes: 5 additions & 5 deletions docs/strategy-callbacks.md
Original file line number Diff line number Diff line change
Expand Up @@ -774,6 +774,11 @@ The combined stake currently allocated to the position is held in `trade.stake_a

Same thing also can happen with partial exit. So be sure to have a strict logic and/or check for the last filled order.

!!! Warning "Performance with many position adjustments"
Position adjustments can be a good approach to increase a strategy's output - but it can also have drawbacks if using this feature extensively.
Each of the orders will be attached to the trade object for the duration of the trade - hence increasing memory usage.
Trades with long duration and 10s or even 100ds of position adjustments are therefore not recommended, and should be closed at regular intervals to not affect performance.

!!! Warning "Backtesting"
During backtesting this callback is called for each candle in `timeframe` or `timeframe_detail`, so run-time performance will be affected.
This can also cause deviating results between live and backtesting, since backtesting can adjust the trade only once per candle, whereas live could adjust the trade multiple times per candle.
Expand Down Expand Up @@ -810,11 +815,6 @@ Back to the example above, since current rate is 200, the current USDT value of

While `/stopentry` command stops the bot from entering new trades, the position adjustment feature will continue buying new orders on existing trades.

!!! Warning "Performance with many position adjustments"
Position adjustments can be a good approach to increase a strategy's output - but it can also have drawbacks if using this feature extensively.
Each of the orders will be attached to the trade object for the duration of the trade - hence increasing memory usage.
Trades with long duration and 10s or even 100ds of position adjustments are therefore not recommended, and should be closed at regular intervals to not affect performance.

``` python
# Default imports

Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ pycoingecko==3.2.0
jinja2==3.1.5
joblib==1.4.2
rich==13.9.4
pyarrow==18.1.0; platform_machine != 'armv7l'
pyarrow==19.0.0; platform_machine != 'armv7l'

# find first, C search in arrays
py_find_1st==1.1.7
Expand Down
15 changes: 8 additions & 7 deletions tests/exchange/test_exchange_ws.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,12 +67,12 @@ async def test_exchangews_ohlcv(mocker, time_machine):

async def sleeper(*args, **kwargs):
# pass
await asyncio.sleep(1)
await asyncio.sleep(0.12)
return MagicMock()

ccxt_object.watch_ohlcv = AsyncMock(side_effect=sleeper)
ccxt_object.close = AsyncMock()
time_machine.move_to("2024-11-01 01:00:00 +00:00")
time_machine.move_to("2024-11-01 01:00:02 +00:00")

mocker.patch("freqtrade.exchange.exchange_ws.ExchangeWS._start_forever", MagicMock())

Expand All @@ -84,7 +84,7 @@ async def sleeper(*args, **kwargs):

exchange_ws.schedule_ohlcv("ETH/BTC", "1m", CandleType.SPOT)
exchange_ws.schedule_ohlcv("XRP/BTC", "1m", CandleType.SPOT)
await asyncio.sleep(0.5)
await asyncio.sleep(0.2)

assert exchange_ws._klines_watching == {
("ETH/BTC", "1m", CandleType.SPOT),
Expand All @@ -95,20 +95,21 @@ async def sleeper(*args, **kwargs):
("XRP/BTC", "1m", CandleType.SPOT),
}
await asyncio.sleep(0.1)
assert ccxt_object.watch_ohlcv.call_count == 2
assert ccxt_object.watch_ohlcv.call_count == 6
ccxt_object.watch_ohlcv.reset_mock()

time_machine.shift(timedelta(minutes=5))
await asyncio.sleep(0.1)
exchange_ws.schedule_ohlcv("ETH/BTC", "1m", CandleType.SPOT)
await asyncio.sleep(0.1)
await asyncio.sleep(1)
# XRP/BTC should be cleaned up.
assert exchange_ws._klines_watching == {
("ETH/BTC", "1m", CandleType.SPOT),
}
# Cleanup happened.
await asyncio.sleep(0.1)
exchange_ws.schedule_ohlcv("ETH/BTC", "1m", CandleType.SPOT)
assert exchange_ws._klines_watching == {
("ETH/BTC", "1m", CandleType.SPOT),
}
assert exchange_ws._klines_scheduled == {
("ETH/BTC", "1m", CandleType.SPOT),
}
Expand Down
Loading