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

Fix for an occasional crash in the P&L Report #1500

Merged

Conversation

bug-or-feature
Copy link
Collaborator

This can happen when you have moved to a new strategy, and there are instruments for which there have been no trades yet.

P&L data for an instrument in a strategy is generated by first building a series of prices at merge_fill_prices_with_prices() from systems.accounts.pandl_calculators.pandl_using_fills.py. A series of P&L values is built from the prices, and then the P&L series are later concatenated into a dataframe at get_df_of_perc_pandl_series_for_strategy_all_instruments() in sysproduction.reporting.data.pandl.py

When there are no trades yet for the new strategy, the empty series of prices has an index of dtype object. That causes the P&L dataframe to be corrupted, only containing data for the final instrument. That causes the crash.

The fix is to set the index to be of datetime type, even for an empty series

Also changes the pandl module print() statements to log.info()

@bug-or-feature bug-or-feature merged commit c79bb41 into robcarver17:develop Feb 14, 2025
2 checks passed
@bug-or-feature bug-or-feature mentioned this pull request Feb 14, 2025
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.

1 participant