braverock / braverock/quantstrat

Enhancement for good-after-time orders

Open
#73 7 comments 0 reactions 0 assignees View on GitHub
Dominant language
R
Stars
310
Forks
121
PR merge metrics
No merged PRs in 30d

Description

I'd like to model [good-after-time](https://www.interactivebrokers.com/en/index.php?f=587) orders. That is, at time (t) a signal is generated that a rule fires upon, and at time (t + 1) an open order is placed for an order that will not go into affect until, say, time (t+90). The anticipation being that the order would close on time (t+90).

Currently, quantstrat supports a 'delay' arugment in 'addOrders'; however, as described [here](https://stackoverflow.com/questions/10441614/quantstrat-in-r-setting-a-date-based-exit-signal), it's more of a hack to make it work in quantstrat. That is, the 'delay' argument does not delay the ordertime, but rather it delays the time the order is inserted into the orderbook.

I propose something like the following: When delay is used while ordertype = 'goodaftertime', the order is opened at the current timestamp, but it does not attempt to close until +delay periods, where delay is given as the periodicity of the mktdata object.

It looks like the following:
* Open an order via ruleSignal at time 'timestamp' for an order to be closed at time timestamp + delay (ordertime)
* During fill simulation, have a 'goodaftertime' ordertype attempt to close the order at ordertime given the current market price.

4f98239070a35af39d282e78338452e078ff78c2

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.