Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stop_limit inconsistency with backtrader (stop_price = pricelimit vs. stop_price = price) #185

Open
mksqllc opened this issue Sep 17, 2021 · 0 comments

Comments

@mksqllc
Copy link

mksqllc commented Sep 17, 2021

Hi there, I think there is an inconsistency between the implementation of backtrader StopLimit order and the alpaca-backtrader-api implemntation of Stop-Limits.

According to backtrader (https://www.backtrader.com/docu/order-creation-execution/order-creation-execution/#stoplimit):

  • parameter price is the trigger price
  • paremeter plimit is the limit price

For instance:

order = self.buy(exectype=Order.StopLimit, price=self.data.close[0] * 1.02, plimit=self.data.close[0] * 1.07)

But according to line 707 from here: https://github.com/alpacahq/alpaca-backtrader-api/blob/master/alpaca_backtrader_api/alpacastore.py:

if order.exectype in [bt.Order.StopLimit, bt.Order.Stop]: okwargs['stop_price'] = order.created.pricelimit

In other words, the limit price I give to backtrader is used as a trigger price in alpaca.

Please let me know if I missed something. Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant