braverock / braverock/quantstrat

[R-Forge #5783] save.strategy() does not save position limits

Open
#24 0 comments 0 reactions 0 assignees View on GitHub
bug
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=5783&group_id=316&atid=1269)

I discovered this while using apply.paramset() for a strategy having a trade rule that specifies osFUN=osMaxPos. The base strategy script has a call to addPosLimit and runs as expected.

When I clear the environment, reload with load.strategy() and then run apply.paramset(), I receive an error message stating 'no position limit defined for portfolio'. Adding a call to addPosLimit in my paramset script gets around this error. It appears that the position limits are saved in the .blotter env instead of .strategy env and are therefore not restored when a strategy is reloaded.

The question is is this as expected? I can see arguments for and against storing the position limits within the strategy. Since osMaxPos is defined within a rule, the strategy is not able to run without these limits being defined, so if this is behavior is as expected, additional documentation or a more direct error message would be useful (this error is buried in the results from the apply.paramset() runs, which can be more challenging identify).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.