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

NaN Handling #116

Open
pcgm-team opened this issue Nov 22, 2023 · 3 comments
Open

NaN Handling #116

pcgm-team opened this issue Nov 22, 2023 · 3 comments
Labels
docs Improve documentation question

Comments

@pcgm-team
Copy link

pcgm-team commented Nov 22, 2023

No description provided.

@enzbus
Copy link
Collaborator

enzbus commented Nov 22, 2023

Hello! I'm not sure I understand, sorry. Data that is fed to the optimization routines can never have np.nan. Historical market data is managed, in this case, by UserProvidedMarketData. Its default behavior is to look at the returns dataframe and at every time step only include in the back-test (or online execution) names that have non-nan return for the period and have had non-nan returns for at least a min_history time period. The interface is defined in the MarketData base class, so if you want a different behavior you can derive from there (it only has 3 public methods). The default one defines its logic in MarketDataInMemory so you may as well redefine the one or two methods that have to do with the asset selection (I may make it easier to do in the future). MarketSimulator also has logic to decide what to do if an asset is dropped during a back-test, the default behavior is to liquidate (transform in cash) without transaction cost, assuming it's an M&A kind of situation. In general the default behavior are designed around daily trading of stocks in the US, but any other can be achieved by deriving from the default objects.

@enzbus enzbus added question docs Improve documentation labels Nov 30, 2023
@enzbus enzbus reopened this Nov 30, 2023
@enzbus
Copy link
Collaborator

enzbus commented Nov 30, 2023

Reopening this because I need to improve docs on it.

@enzbus
Copy link
Collaborator

enzbus commented Dec 1, 2023

You should post the stack trace, there are many pieces that could throw a nan error. values_in_time is the method called by all elements of a policy at each point in time of a back-test. If you're sure the error comes from the ReturnsForecast then it could be a missing or misaligned timestamp, or a missing asset. Do you have constant or varying universe?

@pcgm-team pcgm-team changed the title NaN Handling I Dec 11, 2023
@pcgm-team pcgm-team changed the title I NaN Handling Dec 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Improve documentation question
Projects
None yet
Development

No branches or pull requests

2 participants