Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Feature] fetch public trades #9066

Open
wants to merge 283 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
283 commits
Select commit Hold shift + click to select a range
4364572
Don't fetch trades for informatitve pairs
TheJoeSchr Feb 2, 2024
f6a8e03
Remove invoke self code for test_converter_public_trades
TheJoeSchr Feb 2, 2024
0153fd8
Update constants.py
TheJoeSchr Feb 2, 2024
8337bf3
Fix typo
TheJoeSchr Feb 2, 2024
5487e02
Merge branch 'develop' into feature/fetch-public-trades
TheJoeSchr Feb 2, 2024
1f783b2
Start writing orderflow documentation
TheJoeSchr Feb 6, 2024
aa663b9
Fix tests for use public trades
TheJoeSchr Feb 6, 2024
c04cce5
Fix unnecessary deep intend
TheJoeSchr Feb 6, 2024
3ae5667
Fix merge regression regarding _pairs_last_refresh_time
TheJoeSchr Feb 6, 2024
f61c75f
Fix isort imports
TheJoeSchr Feb 6, 2024
9c07043
Fix isort after ruff changes
TheJoeSchr Feb 6, 2024
e6c1c3d
Fix immediate rename of argument
TheJoeSchr Feb 7, 2024
b117f1b
Fix superfluous changes
TheJoeSchr Feb 7, 2024
72a20e9
Ruff changes for clean_duplicate_trades, populate_dataframe_with_trad…
TheJoeSchr Feb 7, 2024
39ba6fe
Ruff --fix
TheJoeSchr Feb 7, 2024
79074ea
Fix untrue ruff error by adding line ignore
TheJoeSchr Feb 7, 2024
634e81c
Fix ruff
TheJoeSchr Feb 7, 2024
118ca78
Adds TRADESResponse
TheJoeSchr Feb 7, 2024
b8f92ec
Ruff fixes
TheJoeSchr Feb 7, 2024
69eb35d
Ruff fixes
TheJoeSchr Feb 7, 2024
ca8cb73
Ruff fixes
TheJoeSchr Feb 7, 2024
d6e3464
Flake8 fix
TheJoeSchr Feb 7, 2024
2925a2a
Fix regression BaseException
TheJoeSchr Feb 7, 2024
0647ce5
Fix error if until is undefined
TheJoeSchr Feb 8, 2024
14fb295
Removes unused code path
TheJoeSchr Feb 8, 2024
1a0610f
mypy fixes
TheJoeSchr Feb 8, 2024
c40f3d9
Ruff fix
TheJoeSchr Feb 8, 2024
5b264d6
Ruff and flake fixes
TheJoeSchr Feb 8, 2024
3d92b40
Ruff fix: E303 too many blank lines
TheJoeSchr Feb 8, 2024
9ec45ce
Ruff fix
TheJoeSchr Feb 8, 2024
4ae63d7
Fix superfluous formatting
TheJoeSchr Feb 9, 2024
849413c
Changes scale from type int to float
TheJoeSchr Feb 10, 2024
cfcc8f9
Ensure docs are rendered in the navigation pane
xmatthias Feb 10, 2024
7ae69a9
update imports
xmatthias Feb 10, 2024
a216a08
Formatting ...
xmatthias Feb 10, 2024
4b0383f
Fix overly long lines
xmatthias Feb 10, 2024
fc15f98
Reduce unnecessary newlines
xmatthias Feb 10, 2024
d23079f
improve tests slighly
xmatthias Feb 10, 2024
e8c911e
Remove since/until superfluous arguments
TheJoeSchr Feb 11, 2024
0fd2aca
Remove `if since`
TheJoeSchr Feb 11, 2024
eaa85e8
Removes `do_plot` and old comments
TheJoeSchr Feb 11, 2024
0a4da26
Resolve using trades directly from `trades_load` when backtesting
TheJoeSchr Feb 12, 2024
e8714d5
Removes nonsensical if gate
TheJoeSchr Feb 12, 2024
e60b997
Pass on missed argument `stop_on_from_id`
TheJoeSchr Feb 12, 2024
50070bc
Removes unused import
TheJoeSchr Feb 12, 2024
aab3c07
Use `_max_trades_candle_limit` directly
TheJoeSchr Feb 12, 2024
71e36be
Use `get_historic_trades` directly
TheJoeSchr Feb 12, 2024
c85ded1
Extract `_if_enabled_populate_trades`
TheJoeSchr Feb 12, 2024
a7e4a5e
Removes `clean_duplicate_trades`
TheJoeSchr Feb 12, 2024
c610c44
Removes unrequired `drop_incomplete`
TheJoeSchr Feb 12, 2024
6e7a536
Replaces public_trades_to_dataframe with trades_list_to_df
TheJoeSchr Feb 12, 2024
d7b8819
Resolve various issues and comments
TheJoeSchr Feb 12, 2024
64e9784
Remove formatting changes
TheJoeSchr Feb 12, 2024
bff93e3
Moves orderflow logic to it's own file
TheJoeSchr Feb 12, 2024
b68afb4
Fix markdown
TheJoeSchr Feb 13, 2024
7296ce7
Adds more infos to docs
TheJoeSchr Feb 13, 2024
3a1bb83
EOF fix
TheJoeSchr Feb 13, 2024
7248f20
Direct import to avoid circular import error
TheJoeSchr Feb 13, 2024
c4a024e
Improve docs
TheJoeSchr Feb 20, 2024
b15e47d
fix tests: use testdatadir
TheJoeSchr Feb 26, 2024
3df0400
fix tests: move orderflow tests into own dir
TheJoeSchr Feb 26, 2024
5b637bc
tests: use orderflow row that actually has stacked imbalances
TheJoeSchr Feb 26, 2024
6bdf6be
fix tests: add comments
TheJoeSchr Feb 26, 2024
d15f17a
chore: remove unused parameter `pairs` from `populate_dataframe_with_…
TheJoeSchr Feb 26, 2024
79066c3
enable sub-minute backtest detail timeframes
xmatthias Feb 3, 2024
d530dd5
Improve formatting of leverage
xmatthias Feb 3, 2024
7bfb6a0
Update cached binance leverage tiers
xmatthias Feb 3, 2024
c1eadb1
Update Tests data to work with new cached levtiers
xmatthias Feb 3, 2024
0a97d03
Bump uvicorn from 0.27.0 to 0.27.0.post1
dependabot[bot] Feb 5, 2024
4a8553b
Bump urllib3 from 2.1.0 to 2.2.0
dependabot[bot] Feb 5, 2024
9c70c65
Bump ccxt from 4.2.25 to 4.2.35
dependabot[bot] Feb 5, 2024
693ca56
Bump aiohttp from 3.9.2 to 3.9.3
dependabot[bot] Feb 5, 2024
d4e1b22
Bump mkdocs-material from 9.5.6 to 9.5.7
dependabot[bot] Feb 5, 2024
ef5b71d
Bump peter-evans/create-pull-request from 5 to 6
dependabot[bot] Feb 5, 2024
1a79dc1
Bump cryptography from 42.0.1 to 42.0.2
dependabot[bot] Feb 5, 2024
43e23d2
Bump fastapi from 0.109.0 to 0.109.2
dependabot[bot] Feb 5, 2024
470a051
Bump orjson from 3.9.12 to 3.9.13
dependabot[bot] Feb 5, 2024
a11aacc
Bump pydantic from 2.5.3 to 2.6.1
dependabot[bot] Feb 5, 2024
5b98878
Bump ruff from 0.1.15 to 0.2.0
dependabot[bot] Feb 5, 2024
3e89343
Remove unused argument
xmatthias Feb 3, 2024
1255517
update tool.ruff configuration to match 2.0 version
xmatthias Feb 5, 2024
cc9d4d3
chore: update pre-commit hooks
xmatthias Feb 6, 2024
52c7105
Bump technical to 1.4.3
xmatthias Feb 6, 2024
51a4d25
chore: Update ordering of requirements in setup.py
xmatthias Feb 6, 2024
caf169c
fix: logical error
ShaneOss Jan 19, 2024
e84bc14
Fix wording fully.
xmatthias Feb 3, 2024
5b13540
fix strategy-updater docs
stash86 Feb 7, 2024
5dd856a
Allow int as trade-id parameter
xmatthias Feb 8, 2024
705ee7d
chore: add dependency groups for regular updates,
xmatthias Feb 8, 2024
3ca0130
Bump pre-commit/action from 3.0.0 to 3.0.1
dependabot[bot] Feb 8, 2024
992faad
Bump ccxt from 4.2.35 to 4.2.39
dependabot[bot] Feb 8, 2024
9a3955d
Bump numpy from 1.26.3 to 1.26.4
dependabot[bot] Feb 8, 2024
9c72eed
Bump ruff from 0.2.0 to 0.2.1
dependabot[bot] Feb 8, 2024
df1f073
Bump mkdocs-material from 9.5.7 to 9.5.8
dependabot[bot] Feb 8, 2024
2d7efca
Bump nbconvert from 7.14.2 to 7.16.0
dependabot[bot] Feb 8, 2024
bbd68a5
Align new-config documentation examples
xmatthias Feb 9, 2024
4351d93
Allow limiting kraken pairs to `--pairs` selection
xmatthias Feb 10, 2024
34b0463
Allow wildcards for pairs filter
xmatthias Feb 10, 2024
82771cf
Slightly improve memory-usage of kraken-convert
xmatthias Feb 10, 2024
329039d
Bump uvicorn from 0.27.0.post1 to 0.27.1
dependabot[bot] Feb 12, 2024
ee4ff45
Bump pre-commit from 3.6.0 to 3.6.1
dependabot[bot] Feb 12, 2024
7f58496
Bump ccxt from 4.2.39 to 4.2.42
dependabot[bot] Feb 12, 2024
a51f7a3
Bump tqdm from 4.66.1 to 4.66.2
dependabot[bot] Feb 12, 2024
cf4f571
Bump sqlalchemy from 2.0.25 to 2.0.26
dependabot[bot] Feb 12, 2024
f15b931
Update sqlalchemy pre-commit
xmatthias Feb 12, 2024
aeb5e90
Bump mkdocs-material from 9.5.8 to 9.5.9
dependabot[bot] Feb 12, 2024
541b7a2
Bump python-telegram-bot from 20.7 to 20.8
dependabot[bot] Feb 12, 2024
3341964
use query.edit_message_text to simplify telegram class
xmatthias Feb 12, 2024
0796f49
telegram: ensure msg update test uses the correct edit_message_text call
xmatthias Feb 12, 2024
7c33c82
Bump tensorboard from 2.15.1 to 2.15.2
dependabot[bot] Feb 12, 2024
0a3b276
Bump the pytest group with 2 updates
dependabot[bot] Feb 12, 2024
9a8ae99
Add debug output showing the pair to be converted
xmatthias Feb 13, 2024
27556f9
Don't load empty dataframes - skip these
xmatthias Feb 14, 2024
e696c92
Clarify processing_mode for RemotePairlist
froggleston Feb 15, 2024
e63da23
Simplify some pairlist conditions
xmatthias Feb 14, 2024
731fbe6
Improve log message
xmatthias Feb 14, 2024
c491c2a
Adjust for ccxt exception hierarchy change
xmatthias Feb 15, 2024
cb95298
Add dt_ts_none helper
xmatthias Feb 15, 2024
d004509
Simplify trade_model serializations
xmatthias Feb 15, 2024
f7eb14a
Add open_fill_date stuff to json schema
xmatthias Feb 15, 2024
90c0b55
Adjust tests for new fields
xmatthias Feb 15, 2024
ff5364a
Fix duplicate parentheses
xmatthias Feb 15, 2024
aa1d549
Double newlines between functions ...
xmatthias Feb 15, 2024
ec1b676
Fix edge-case when calculating cagr
xmatthias Feb 16, 2024
c99184a
Added escaping to enter and exit tags on telegram performance messages.
Feb 16, 2024
51d7998
Change enter_tag, exit_reason, mix_tag performance messages from HTML…
Feb 16, 2024
103af46
Use Markdown V1 - update tests
xmatthias Feb 17, 2024
25ee332
Don't tick on ttl cache
xmatthias Feb 17, 2024
0a04cac
docs: Update sql_cheatsheet.md
tar-xz Feb 17, 2024
4c07d2f
Improve validate_exchange
xmatthias Feb 18, 2024
6da6842
enhance volumpairlist range test
xmatthias Feb 15, 2024
099996c
Add additional test case for VolumePairlist in range mode
xmatthias Feb 15, 2024
a0dc21e
Enable caching for "filter only" Volumepairlist
xmatthias Feb 15, 2024
a19dafe
Update pairlist cache behavior in VolumePairList
xmatthias Feb 17, 2024
6714265
Refactor ohlcv caching to exchange class
xmatthias Feb 17, 2024
6a68ced
Add explicit test for ohlcv_with_cache
xmatthias Feb 17, 2024
440a843
Use "ohlcv_with_cache" for further pairlists
xmatthias Feb 17, 2024
0f4bffc
Remove unused import
xmatthias Feb 17, 2024
2473594
Add log message for Bybit accout type
xmatthias Feb 18, 2024
165003e
Fail if unified account is detected.
xmatthias Feb 18, 2024
b67f2dd
Update telegram help with new wording
xmatthias Feb 18, 2024
9792e44
Fix bybit spot live tests
xmatthias Feb 18, 2024
d554330
Bump the pytest group with 1 update
dependabot[bot] Feb 19, 2024
e65199d
Bump urllib3 from 2.2.0 to 2.2.1
dependabot[bot] Feb 19, 2024
9aa01c0
Bump cryptography from 42.0.2 to 42.0.3
dependabot[bot] Feb 19, 2024
1b00f4a
Bump plotly from 5.18.0 to 5.19.0
dependabot[bot] Feb 19, 2024
b6c1925
Further increase test coverate of max_drawdown
xmatthias Feb 19, 2024
bb6c31c
Improve formatting in drawdown calc
xmatthias Feb 19, 2024
e3a128f
Bump orjson from 3.9.13 to 3.9.14
dependabot[bot] Feb 19, 2024
77e0dfd
Bump scikit-learn from 1.4.0 to 1.4.1.post1
dependabot[bot] Feb 19, 2024
82791bb
Bump pre-commit from 3.6.1 to 3.6.2
dependabot[bot] Feb 19, 2024
96efaca
Bump sqlalchemy from 2.0.26 to 2.0.27
dependabot[bot] Feb 19, 2024
c38c3c7
Update sqlalchemy in pre-commit
xmatthias Feb 19, 2024
fca9147
Bump ruff from 0.2.1 to 0.2.2
dependabot[bot] Feb 19, 2024
45bf3c8
Bump the types group with 1 update
dependabot[bot] Feb 19, 2024
2de303e
bump types-requests pre-commit
xmatthias Feb 19, 2024
80e9e20
Fix / improve styling in test class
xmatthias Feb 19, 2024
0eb1602
chore: update pre-commit hooks
xmatthias Feb 20, 2024
871fa25
Bump tensorboard from 2.15.2 to 2.16.2
dependabot[bot] Feb 19, 2024
322a3a3
Add fetch_order_emulated to support exchanges without proper fetch_or…
xmatthias Feb 18, 2024
35be790
Add test for fetch_order_emulated
xmatthias Feb 18, 2024
b187338
Update "exchange_has" validation with new fallbacks
xmatthias Feb 18, 2024
fc34398
Fix some tests due to new method
xmatthias Feb 18, 2024
acb34c5
Bump ccxt to 4.2.47
xmatthias Feb 20, 2024
eb175ee
Add type-hint to exchange_has dict
xmatthias Feb 20, 2024
b9f361b
Bump cryptography from 42.0.3 to 42.0.4
dependabot[bot] Feb 21, 2024
392d5ae
Use set to reduce iterations
xmatthias Feb 22, 2024
0b9e7be
Fix range-stability filter downloading too little data
xmatthias Feb 22, 2024
7db2367
Improve ohlcv pair cache with since_ms
xmatthias Feb 22, 2024
426e7c4
Update typehint for candle_cache
xmatthias Feb 22, 2024
983aefe
Remove duplicate pairlistmanager init
xmatthias Feb 22, 2024
f16d1a7
chore: Remove wrong typehint
xmatthias Feb 22, 2024
cfa8fd8
Remove pointless comment
xmatthias Feb 22, 2024
7d9ecb7
Add check to verify that "since" is properly respected.
xmatthias Feb 22, 2024
f3f4a65
Improve some type safety
xmatthias Feb 24, 2024
21eecb2
Ensure pytz is updated regularily by pinning it
xmatthias Feb 25, 2024
b811775
Enhance funding-fee call test to account for different timezones
xmatthias Feb 25, 2024
0649fe3
Update comment around funding fees
xmatthias Feb 25, 2024
74f01c4
Clearer wallets variable/parameter wording
xmatthias Feb 25, 2024
1620c1e
Bump Docker Python version from 3.11.7 to 3.11.8
xmatthias Feb 25, 2024
cb00cd7
Bump the pytest group with 1 update
dependabot[bot] Feb 26, 2024
27e0054
Bump mkdocs-material from 9.5.9 to 9.5.11
dependabot[bot] Feb 26, 2024
8944615
Bump orjson from 3.9.14 to 3.9.15
dependabot[bot] Feb 26, 2024
4b6eab2
Bump pydantic from 2.6.1 to 2.6.2
dependabot[bot] Feb 26, 2024
36fede7
Bump nbconvert from 7.16.0 to 7.16.1
dependabot[bot] Feb 26, 2024
c66d7bc
Add warning about excessive use of position_adjustment
xmatthias Feb 26, 2024
2b6a38b
Bump cryptography from 42.0.4 to 42.0.5
dependabot[bot] Feb 26, 2024
9c0c578
Bump fastapi from 0.109.2 to 0.110.0
dependabot[bot] Feb 26, 2024
091d827
Merge branch 'develop' into feature/fetch-public-trades
TheJoeSchr Feb 26, 2024
baf2cf6
Fix import error in one test case
xmatthias Mar 1, 2024
6c1d70d
Merge remote-tracking branch 'upstream/develop' into feature/fetch-pu…
TheJoeSchr Mar 4, 2024
1f6046d
work through open TODOs
TheJoeSchr Mar 11, 2024
174c830
formatting changes
TheJoeSchr Mar 11, 2024
6827e17
raise error if populate_dataframe_with_trades fails
TheJoeSchr Mar 11, 2024
c12e203
Merge remote-tracking branch 'upstream/develop' into feature/fetch-pu…
TheJoeSchr Mar 11, 2024
bce5dc4
Simplify formatting
xmatthias Mar 16, 2024
0f3d538
Avoid duplicate pandas imports
xmatthias Mar 16, 2024
88e25df
Merge branch 'develop' into feature/fetch-public-trades
xmatthias Mar 16, 2024
9020c32
Fix imports after dev merge
xmatthias Mar 16, 2024
86fe765
Improved naming on max_trades
xmatthias Mar 16, 2024
21bca95
Group things logically in exchange class
xmatthias Mar 16, 2024
b5307f8
Fix bug caused by any typing
xmatthias Mar 16, 2024
7e387f9
Fix comments in config sample
xmatthias Mar 16, 2024
1d5f2b6
Add simple verification that orderflow is configured correctly
xmatthias Mar 17, 2024
f663b53
Add basic config validation
xmatthias Mar 17, 2024
d226e70
fix: remove unused stop_on_from_id
TheJoeSchr Mar 28, 2024
53702bf
fix: make `until` non-optional
TheJoeSchr Mar 28, 2024
63ac183
Merge branch 'develop' into feature/fetch-public-trades
xmatthias Apr 5, 2024
59dee5f
Update config test exception due to changes on dev
xmatthias Apr 5, 2024
843c68b
Don't use noqa.
xmatthias Apr 5, 2024
34d3389
Avoid some unnecessary linebreaks
xmatthias Apr 5, 2024
e0f1b1e
Attempt to reduce diff as much as possible
xmatthias Apr 5, 2024
28e4711
Enhance test for dataprovider
xmatthias Apr 5, 2024
f32154f
Exchange assert is only relevant for live mode.
xmatthias Apr 5, 2024
69d098e
Dataprovider test
xmatthias Apr 5, 2024
56b0738
fix `_now_is_time_to_refresh_trades` so it checks for latest fetched …
TheJoeSchr May 8, 2024
10cbc76
use `timeframe_to_next_date` and `date` to calculate `candle_start`/`…
TheJoeSchr May 8, 2024
dd432ff
cleanup ruff and isort errors
TheJoeSchr May 14, 2024
ec9d181
add `test_refresh_latest_trades` to test_exchange
TheJoeSchr May 14, 2024
b9035da
Merge remote-tracking branch 'upstream/develop' into feature/fetch-pu…
TheJoeSchr May 15, 2024
f87cd5d
Enables `use_public_trades` only in `test_refresh_latest_trades`
TheJoeSchr May 15, 2024
6c696e1
`test_refresh_latest_trades`: mock `datadir` with `tmp_path`
TheJoeSchr May 15, 2024
a56faf5
ruff format: orderflow / public trades
TheJoeSchr May 15, 2024
d33a14a
`test_refresh_latest_trades`: removes TODO
TheJoeSchr May 16, 2024
839827c
`refresh_latest_trades`: remove "-cached" from trades pair files
TheJoeSchr May 16, 2024
f99e8f1
`refresh_latest_trades`: removes TODO
TheJoeSchr May 16, 2024
0460ce4
ruff format: exchange/trades_load
TheJoeSchr May 16, 2024
ab7f8b3
`imbalance_ratio`: use ratio instead of percentage
TheJoeSchr May 17, 2024
8afcaee
`trades()`: add lookahead warning to docstring
TheJoeSchr May 17, 2024
1167917
`constants`: add ranges for orderflow config properties
TheJoeSchr May 17, 2024
d0eb55a
Small type fixes
xmatthias May 18, 2024
0673f3e
Remove unused function
xmatthias May 18, 2024
32f931c
Revert "`refresh_latest_trades`: remove "-cached" from trades pair fi…
TheJoeSchr May 28, 2024
bf3eeeb
Use `.exception` instead of `.error` for trace logging
TheJoeSchr May 28, 2024
4629362
Fixing merge error
TheJoeSchr May 28, 2024
24707ab
orderflow: raise DependencyException instead of raising generic excep…
TheJoeSchr May 28, 2024
07034ed
orderflow: add comment with insight about imbalances
TheJoeSchr May 28, 2024
82e8901
orderflow: remove unused function `orderflow_to_volume_profile`
TheJoeSchr May 29, 2024
5dcf75f
exchange: replace `OperationalException` with `logger.error` message
TheJoeSchr May 29, 2024
41def8b
orderflow: removes unnecessary code
TheJoeSchr May 29, 2024
bfb29d3
orderflow: fix ask/bid & buy/sell mixup
TheJoeSchr May 31, 2024
d5361d8
use np.where instead of apply
xmatthias Jun 2, 2024
f075d72
constants: make "orderflow" fields required
TheJoeSchr Jun 4, 2024
50bf770
Merge branch 'develop' into feature/fetch-public-trades
xmatthias Jun 4, 2024
4e31976
Slightly update docs with warnings
xmatthias Jun 6, 2024
3121929
Don't fail trades loop if one pair fails
xmatthias Jun 6, 2024
84e8a19
Remove duplicate log message
xmatthias Jun 6, 2024
2d6408a
feat: adds `max_candles` to orderflow config
TheJoeSchr Jun 19, 2024
ffda564
Merge remote-tracking branch 'upstream/develop' into feature/fetch-pu…
TheJoeSchr Jun 19, 2024
08a27ab
orderflow: clean up populate_dataframe_with_trades code
TheJoeSchr Jun 21, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
96 changes: 96 additions & 0 deletions docs/advanced-orderflow.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
# Advanced Orderflow

This guide walks you through utilizing public trade data for advanced orderflow analysis in Freqtrade.

!!! Warning "Experimental Feature"
The orderflow feature is currently in beta and may be subject to changes in future releases. Please report any issues or feedback on the [Freqtrade GitHub repository](https://github.com/freqtrade/freqtrade/issues).

!!! Warning "Performance"
Orderflow requires raw trades data. This data is rather large, and can cause a slow initial startup, when freqtrade needs to download the trades data for the last X candles. It can also cause increased memory usage. Please ensure you have sufficient resources available.

## Getting Started

1. **Enable Public Trades:** in your `config.json` file, set the `use_public_trades` option to true under the `exchange` section.

```json
"exchange": {
...
"use_public_trades": true,
}
```

2. **Configure Orderflow Processing:** Define your desired settings for orderflow processing within the orderflow section of config.json. Here, you can adjust factors like:

- `max_candles`: Filter how many candles get processed from the tail
- `scale`: This controls the price bin size for the footprint chart.
- `stacked_imbalance_range`: Defines the minimum consecutive imbalanced price levels required for consideration.
- `imbalance_volume`: Filters out imbalances with volume below this threshold.
- `imbalance_ratio`: Filters out imbalances with a ratio (difference between ask and bid volume) lower than this value.

```json
"orderflow": {
"max_candles": 1500,
"scale": 0.5,
"stacked_imbalance_range": 3, // needs at least this amount of imbalance next to each other
"imbalance_volume": 1, // filters out below
"imbalance_ratio": 3 // filters out ratio lower than
},
TheJoeSchr marked this conversation as resolved.
Show resolved Hide resolved
```

## Downloading Trade Data for Backtesting

To download historical trade data for backtesting, use the --dl-trades flag with the freqtrade download-data command.

```bash
freqtrade download-data -p BTC/USDT:USDT --timerange 20230101- --trading-mode futures --timeframes 5m --dl-trades
```

## Accessing Orderflow Data

Once activated, several new columns become available in your dataframe:
``` python

dataframe["trades"] # Contains information about each individual trade.
dataframe["orderflow"] # Represents a footprint chart dataframe (see below)
dataframe["bid"] # Total bid volume
dataframe["ask"] # Total ask volume
dataframe["delta"] # Difference between ask and bid volume.
dataframe["min_delta"] # Minimum delta within the candle
dataframe["max_delta"] # Maximum delta within the candle
dataframe["total_trades"] # Total number of trades
dataframe["stacked_imbalances_bid"] # Price level of stacked bid imbalance
dataframe["stacked_imbalances_ask"] # Price level of stacked ask imbalance
```

You can access these columns in your strategy code for further analysis. Here's an example:

``` python
def populate_indicators(self, dataframe: DataFrame, metadata: dict) -> DataFrame:
# Calculating cumulative delta
dataframe["cum_delta"] = cumulative_delta(dataframe["delta"])
# Accessing total trades
total_trades = dataframe["total_trades"]
...

def cumulative_delta(delta: Series):
cumdelta = delta.cumsum()
return cumdelta

```

### Footprint chart (dataframe["orderflow"])

This column provides a detailed breakdown of buy and sell orders at different price levels, offering valuable insights into order flow dynamics. The scale parameter in your configuration determines the price bin size for this representation

The `orderflow` dataframe includes columns like:

- `bid_amount`: Total volume bought at each price level.
- `ask_amount`: Total volume sold at each price level.
- `bid`: Number of buy orders at each price level.
- `ask`: Number of sell orders at each price level.
- `delta`: Difference between ask and bid volume at each price level.
- `total_volume`: Total volume (ask amount + bid amount) at each price level.
- `total_trades`: Total number of trades (ask + bid) at each price level.


By leveraging these features, you can gain valuable insights into market sentiment and potential trading opportunities based on order flow analysis.
9 changes: 9 additions & 0 deletions freqtrade/configuration/config_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,7 @@ def validate_config_consistency(conf: Dict[str, Any], *, preliminary: bool = Fal
_validate_freqai_include_timeframes(conf, preliminary=preliminary)
_validate_consumers(conf)
validate_migrated_strategy_settings(conf)
_validate_orderflow(conf)

# validate configuration before returning
logger.info("Validating configuration ...")
Expand Down Expand Up @@ -421,6 +422,14 @@ def _validate_consumers(conf: Dict[str, Any]) -> None:
)


def _validate_orderflow(conf: Dict[str, Any]) -> None:
if conf.get("exchange", {}).get("use_public_trades"):
if "orderflow" not in conf:
raise ConfigurationError(
"Orderflow is a required configuration key when using public trades."
)


def _strategy_settings(conf: Dict[str, Any]) -> None:
process_deprecated_setting(conf, None, "use_sell_signal", None, "use_exit_signal")
process_deprecated_setting(conf, None, "sell_profit_only", None, "exit_profit_only")
Expand Down
23 changes: 22 additions & 1 deletion freqtrade/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
bot constants
"""

from typing import Any, Dict, List, Literal, Tuple
from typing import Any, Dict, List, Literal, Optional, Tuple

from freqtrade.enums import CandleType, PriceType, RPCMessageType

Expand Down Expand Up @@ -68,6 +68,7 @@
# Don't modify sequence of DEFAULT_TRADES_COLUMNS
# it has wide consequences for stored trades files
DEFAULT_TRADES_COLUMNS = ["timestamp", "id", "type", "side", "price", "amount", "cost"]
DEFAULT_ORDERFLOW_COLUMNS = ["level", "bid", "ask", "delta"]
TRADES_DTYPES = {
"timestamp": "int64",
"id": "str",
Expand Down Expand Up @@ -533,6 +534,23 @@
},
"position_adjustment_enable": {"type": "boolean"},
"max_entry_position_adjustment": {"type": ["integer", "number"], "minimum": -1},
"orderflow": {
"type": "object",
"properties": {
"max_candles": {"type": "number", "minimum": 1, "default": 1500},
"scale": {"type": "number", "minimum": 0.0},
"stacked_imbalance_range": {"type": "number", "minimum": 0},
"imbalance_volume": {"type": "number", "minimum": 0},
"imbalance_ratio": {"type": "number", "minimum": 0.0},
},
"required": [
"max_candles",
"scale",
"stacked_imbalance_range",
"imbalance_volume",
"imbalance_ratio",
],
},
},
"definitions": {
"exchange": {
Expand Down Expand Up @@ -770,6 +788,9 @@

# Type for trades list
TradeList = List[List]
# ticks, pair, timeframe, CandleType
TickWithTimeframe = Tuple[str, str, CandleType, Optional[int], Optional[int]]
ListTicksWithTimeframes = List[TickWithTimeframe]

LongShort = Literal["long", "short"]
EntryExit = Literal["entry", "exit"]
Expand Down
2 changes: 2 additions & 0 deletions freqtrade/data/converter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
trim_dataframe,
trim_dataframes,
)
from freqtrade.data.converter.orderflow import populate_dataframe_with_trades
from freqtrade.data.converter.trade_converter import (
convert_trades_format,
convert_trades_to_ohlcv,
Expand All @@ -30,6 +31,7 @@
"trim_dataframes",
"convert_trades_format",
"convert_trades_to_ohlcv",
"populate_dataframe_with_trades",
"trades_convert_types",
"trades_df_remove_duplicates",
"trades_dict_to_list",
Expand Down