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

[R-Forge #5834] unexpected order date if symbol index is Date class #29

Open
joshuaulrich opened this issue May 13, 2016 · 0 comments
Open
Labels

Comments

@joshuaulrich
Copy link
Collaborator

Submitted by: Jonathan Owen
Assigned to: Nobody
R-Forge link

I'm not sure is this is a bug or shows a need for additional input data checks/documentation. When running the attached script (provided by Samo Pahor), which uses daily symbol data with a Date class index and a exit rule delay=1, there is both an order and transaction dated on 2/11, but the transaction uses the price from 2/10.

Signals are generated on 2/9, so using allowMagicalThinking one would expect to see an enter order and transaction on 2/9 and, due to the delay=1, an exit order and transaction on 2/10. It appears that the price logic is working as expected, but the order date (and transaction date) is not. This may have something to do with how the delay is handled in addOrder (lines 386-7) in orders.R--instead of is.timeBased, should the validation be that timestamp is POSIXct? The discrepancy is gone if the index on the symbol data is changed to be POSIXct (see line 37 of attached script).

I think it would make sense to add some logic to applyStrategy that validates that the index class for the symbol and mktdata is POSIXct, and if not either throw a warning and/or convert. Any thoughts?

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

No branches or pull requests

1 participant