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

PythonData OHLC Security properties update logic #7808

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

D1mi3
Copy link

@D1mi3 D1mi3 commented Feb 22, 2024

Added logic to allow PythonData with OHLC attributes to update Security properties.

Description

Added code in SecurityCache.cs between Tick and IBars updates. This block allows any OHLC attribute contained on PythonData _storage to set _lastOHLCUpdate.

Related Issue

Close #7793

Motivation and Context

Inaccurate backtesting results for OHLC PythonData used as price data. (e.g. Unrealistic fill prices for limit orders as high or low properties aren't taken into account).

Requires Documentation Change

Minor documentation changes explaining the required attribute format to correctly define OHLC PythonData bars.

How Has This Been Tested?

Backtesting results & unit tests.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • Refactor (non-breaking change which improves implementation)
  • Performance (non-breaking change which improves performance. Please add associated performance test and results)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to change)
  • Non-functional change (xml comments/documentation/etc)

Checklist:

  • My code follows the code style of this project.
  • I have read the CONTRIBUTING document.
  • I have added tests to cover my changes.
  • All new and existing tests passed.
  • My branch follows the naming convention bug-<issue#>-<description> or feature-<issue#>-<description>

@jaredbroad
Copy link
Member

Hi @D1mi3 - interesting PR thank you.

Can you please shuffle the the end of the method so it doesn't impact speed, and also confirm the data is added to the cache (and thus available for fill models) with a test.

It may be easier to convert the object to an IBar instance and store that in cache vs keeping it in PythonData format.

@D1mi3
Copy link
Author

D1mi3 commented Apr 5, 2024

Hi @D1mi3 - interesting PR thank you.

Can you please shuffle the the end of the method so it doesn't impact speed, and also confirm the data is added to the cache (and thus available for fill models) with a test.

It may be easier to convert the object to an IBar instance and store that in cache vs keeping it in PythonData format.

Hi @jaredbroad, thanks for the feedback. I'll soon update the PR with the shuffling suggested. With respect to the tests you mentioned; they're already implemented, please refer to them at SecurityCacheTests.cs#L365.

Finally, I agree with the simplicity of just converting PythonData to IBar, since that was my first instinct. The problem of that approach is that PythonData doesn't implement the IBar interface at all, thus it's not possible to cast. I thought about making PythonData implement IBar but ended up not doing that since it could have unintended side effects.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Custom data can't update OHLC security properties
2 participants