alpacahq / alpacahq/Alpaca-API

GTC braker order

Open
#283 0 comments 0 reactions 0 assignees View on GitHub
Dominant language
No language data
Stars
173
Forks
17
PR merge metrics
No merged PRs in 30d

Description

**Describe the bug**
When plasing an order with stop loss and target, the inner time_in_force is ignored

**To Reproduce**
with this body in the request
body = {
"symbol": ticker,
"qty": str(qty),
"side": "buy",
"type": "market",
"time_in_force": "day",
"order_class": "bracket",
"take_profit": {
"limit_price": str(round(take_profit, 2)),
"time_in_force": "gtc"
},
"stop_loss": {
"stop_price": str(round(stop_loss, 2)),
"time_in_force": "gtc"
}
}

the take_profit and stop_loss are not respecting the time_in_force as gtc, so it is always setting them as "day"

**Expected behavior**
take_profit and stop_loss should be "gtc" while the main order should be "day"

**Screenshots**
If applicable, add screenshots to help explain your problem.

**Desktop (please complete the following information):**
- OS: [e.g. iOS]
- Browser [e.g. chrome, safari]
- Version [e.g. 22]

**Smartphone (please complete the following information):**
- Device: [e.g. iPhone6]
- OS: [e.g. iOS8.1]
- Browser [e.g. stock browser, safari]
- Version [e.g. 22]

**Additional context**
the walk around for this is to first add the normal order and then post the bracket order, the problem is that if there is a delay in Alpaca I get penalized with " potential wash trade detected. use complex orders"
so I have to put timers and delays on the code which is not great.

Contributor guide

No contributing guide indexed for this repository

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.