braverock / braverock/quantstrat
[R-Forge #5801] getPrice in applyRules, ruleOrderProc and ruleSignal missing symbol parameter
- Dominant language
- R
- Stars
- 310
- Forks
- 121
- PR merge metrics
- No merged PRs in 30d
Description
Submitted by: Jonathan Owen
Assigned to: Nobody
[R-Forge link](http://r-forge.r-project.org/tracker/index.php?func=detail&aid=5801&group_id=316&atid=1269)
The missing parameter can cause an incorrect order/trade price to be used when mktdata includes more than 1 symbol. The bug can be reproduced by passing a mktdata object including more than 1 symbol to the applyStrategy function. This is not a problem when mktdata=NULL, as the applyStrategy retrieves data for a single symbol using get(symbol).
I believe a fix is to include the symbol=symbol parameter in the getPrice calls.
The function applyRules includes additional price logic that does not use the getPrice function (see posQty and neqQty around line 500 in rules.R). If this logic is still in use, to incorporate filtering by symbol it may be desirable to replace these lines with calls to getPrice, appropriately specifying prefer.
Followups:
Date: 2014-11-06 19:14
Sender: Jonathan Owen
I've added a diff file with proposed updates.
Contributor guide
Research direction
Start in rules.R, reading applyRules and the getPrice calls in ruleOrderProc and ruleSignal, then reproduce the issue through applyStrategy with mktdata containing more than one symbol. Check the posQty and neqQty logic around line 500 as well; done means symbol filtering is applied consistently without changing the single-symbol behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- fintech-quant
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100