You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
dt
open
high
low
close
entry_signal
exit_signal
type
price
0
2017-01-03 00:00:00
730
733
722.5
727
1
0
nan
nan
1
2017-01-04 00:00:00
735
760
735
760
0
0
buy
727
2
2017-01-05 00:00:00
767
790
760.5
790
0
0
nan
nan
3
2017-01-06 00:00:00
780
794.5
780
786.5
0
0
nan
nan
4
2017-01-09 00:00:00
786.5
790
770.5
784.5
0
0
nan
nan
5
2017-01-10 00:00:00
787.5
797
784
793
0
1
nan
nan
6
2017-01-11 00:00:00
794
797
787
796
0
0
sell
796
7
2017-01-12 00:00:00
796.5
799.5
790.5
793.5
0
0
nan
nan
8
2017-01-13 00:00:00
793.5
797.5
790
792
0
0
nan
nan
9
2017-01-16 00:00:00
795.5
795.5
773
786.5
0
0
nan
nan
When the entry signal is generated at 2017-01-03, the closing price is 727
Then the order is executed the following day. However the price (727) is not within the bounds of high and low at 2017-01-04
Example
Use fastquant.indicators.custom.CustomIndicator for creating entry and exit signals
# Explicitly setting exectype=bt.Order.Close will make the next day's closing the reference price
self.order = self.buy(size=final_size, exectype=bt.Order.Close)
Environment
platform: Linux
fastquant version : commit: 94d9383 ("Update setup version")
installation method: source
The text was updated successfully, but these errors were encountered:
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)
@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 329fb5e 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:fastquant/python/fastquant/strategies/base.py
Line 358 in 94d9383
Environment
The text was updated successfully, but these errors were encountered: