-
Notifications
You must be signed in to change notification settings - Fork 1k
Processing TradeTick from bar fails in backtest if bar.volume / 4 and instrument.size_increment both evaluate to < 1 #2275
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
Comments
Thanks for the report, I've implemented this code recently, I'll fix it today or tomorrow, I know what to do. |
I don't understand why cdef double size_value = max(bar.volume.as_double() / 4.0, self.instrument.size_increment.as_double()) is not enough. Can you please send an example reproducing the issue ? |
As I understood it, the code is OK, but just checked condition is failing: But let's wait for MRE if needed 👍 |
I don't have an MRE ready but I will try to work one up if you still need one after the following attempted explanation. Basically:
Therefore, nautilus_trader/nautilus_trader/model/data.pyx Line 4249 in b36d002
|
Thanks for the report! I think the issue was in the quote tick processing from bars (rather than trade tick processing). Now fixed on develop branch from commit 7f4e982. |
Apologies, I see you specifically mentioned This condition check is on the So I suspect this may be a mismatch in data vs |
Ok yes, that's reasonable. I had not thought of that. I'll try to work up an MRE which will hopefully guide what to do if anything. I since overwrote all my catalog bars to have a bigger volume to get through the backtest but, by memory, one error occurred with AAVEUSDT-PERP which had a bar volume of 1 and instrument size_precision and size_increment of 1 and 0.1, respectively. I'm not smart enough to say whether those facts are useful to you or not. |
@hi @miller-moore , |
Hey @miller-moore Thanks! For context, the issue you experienced was due to the trade size being zero. It's also a common preprocessing step to inflate trade volumes if you're going to use bars for processing execution (as you've done), because inferring top-of-book size available from trade volumes alone probably has low accuracy. |
@cjdsellers should I reopen the PR I did yesterday? I don't think we want the backtests to crash, an approximation may be better like what was suggested. |
Uh oh!
There was an error while loading. Please reload this page.
Bug Report
When the order matching engine processes a trade tick from a bar with a small volume and the instrument size increment is less than 1, the creation of TradeTick fails on Condition.positive_int error because TradeTick enforces
size
to be a positive int.Expected Behavior
Take
max(bar.volume / 4, instrument.size_increment, 1)
instead of justmax(bar.volume / 4, instrument.size_increment)
:nautilus_trader/nautilus_trader/backtest/matching_engine.pyx
Line 646 in 234b491
Actual Behavior
Sometimes the bar.volume / 4 combined with instrument.size_increment < 1 results in a float trade tick size of < 1, leading to the Condition.positive_int error on
size
.Steps to Reproduce the Problem
Specifications
nautilus_trader
version: 1.211.0The text was updated successfully, but these errors were encountered: