alpacahq / alpaca-trade-api-python

Python client for Alpaca's trade API
https://pypi.org/project/alpaca-trade-api/
Apache License 2.0
1.73k stars 538 forks source link

[Bug]: OTO take profit bypass the PDT Protection #644

Closed sshcli closed 2 years ago

sshcli commented 2 years ago

Is there an existing issue for this?

Current Behavior

The OTO take profit is bypassing the PDT Protection

For example: if your daytrade_count = 3, but you already have some sell orders that were previously placed by an OTO order a few minutes ago.

Expected Behavior

The sell orders submitted by OTO should not be filled if there are possible PDT violation by doing so. Only fill it if no violation will occur

SDK Version I encountered this issue in

alpaca-trade-api version: 2.3.0

Steps To Reproduce

Tested in Paper Trading
Try to bypass the PDT protection by placing OTO orders

Filled out the Steps to Reproduce section?

Anything else?

No response

sshcli commented 2 years ago

Can't reproduce this anymore. I'm closing this one