Open jbdelmundo opened 3 years ago
Also, the size
(or amount of shares) is determined on the day the signal is generated
However, if the size * price > cash
, where price
is based on the execution date and not on the signal day (exectype=bt.Order.Close
), the buy order will fail (order.status == order.Margin
)
This usually happens when BUY_PROP = 1
@jbdelmundo what's your proposed fix?
@jpdeleon in a recent PR, enzo and i were looking at the execution type and making the execution type bt.Close caused issues in intraday. Removing it has then fixed the problem.
By default it reverts to bt.Market which gets the close of the day the signal was created.
In line 496 here https://github.com/enzoampil/fastquant/pull/396/commits/329fb5e01678dd5dc8a45fef358e035b571dc611 the exectype=bt.Order.Close was removed
Problem description
When setting custom buy/sell signals, the order was executed the following day. However the execution price was still based on the current day. The execution price can be impossible because it was trying to execute today's price that may not be available the following day.
When the entry signal is generated at
2017-01-03
, the closing price is727
Then the order is executed the following day. However the price (727
) is not within the bounds ofhigh
andlow
at2017-01-04
Example
fastquant.indicators.custom.CustomIndicator
for creating entry and exit signalsExpected behavior
It can be modified in
strategies/base.py
by specifying the exectype here: https://github.com/enzoampil/fastquant/blob/94d938397b7ee61aa82bf0f72875d6499458200c/python/fastquant/strategies/base.py#L358Environment