Describe the bug
When the stop loss order is created with small delta from the market price, I am getting the error: "stop price must be less than base_price - 0.01", even though I am taking care to send < base_price-0.01 value. See the code and response below:
Response:
Connected to pydev debugger (build 193.6494.30)
13.969
13.93
13.94
13.93
Traceback (most recent call last):
File "C:\Users\xxxxx.virtualenvs\Git_level_python-l32kb49C\lib\site-packages\alpaca_trade_api\rest.py", line 146, in _one_request
resp.raise_for_status()
File "C:\Users\xxxxx.virtualenvs\Git_level_python-l32kb49C\lib\site-packages\requests\models.py", line 943, in raise_for_status
raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 422 Client Error: Unprocessable Entity for url: https://paper-api.alpaca.markets/v2/orders
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "C:\Users\xxxxx.virtualenvs\Git_level_python-l32kb49C\lib\site-packages\alpaca_trade_api\rest.py", line 125, in _request
return self._one_request(method, url, opts, retry)
File "C:\Users\xxxxx.virtualenvs\Git_level_python-l32kb49C\lib\site-packages\alpaca_trade_api\rest.py", line 154, in _one_request
raise APIError(error, http_error)
alpaca_trade_api.rest.APIError: stop price must be less than base_price - 0.01
Describe the bug When the stop loss order is created with small delta from the market price, I am getting the error: "stop price must be less than base_price - 0.01", even though I am taking care to send < base_price-0.01 value. See the code and response below:
code: ticker = 'OCGN' quantity = 1 symbol_price = api.get_last_trade(ticker).price print(symbol_price) k = min(round(symbol_price - 0.04,2), round(symbol_price 0.998, 2)) print(round(symbol_price - 0.04,2)) print(round(symbol_price 0.998, 2)) print(k) api.submit_order( symbol=ticker, qty=quantity, side='buy', type='market', time_in_force='day', order_class='oto', stop_loss={'stop_price': k} # stop loss )
Response: Connected to pydev debugger (build 193.6494.30) 13.969 13.93 13.94 13.93 Traceback (most recent call last): File "C:\Users\xxxxx.virtualenvs\Git_level_python-l32kb49C\lib\site-packages\alpaca_trade_api\rest.py", line 146, in _one_request resp.raise_for_status() File "C:\Users\xxxxx.virtualenvs\Git_level_python-l32kb49C\lib\site-packages\requests\models.py", line 943, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 422 Client Error: Unprocessable Entity for url: https://paper-api.alpaca.markets/v2/orders
During handling of the above exception, another exception occurred:
Traceback (most recent call last): File "C:\Users\xxxxx.virtualenvs\Git_level_python-l32kb49C\lib\site-packages\alpaca_trade_api\rest.py", line 125, in _request return self._one_request(method, url, opts, retry) File "C:\Users\xxxxx.virtualenvs\Git_level_python-l32kb49C\lib\site-packages\alpaca_trade_api\rest.py", line 154, in _one_request raise APIError(error, http_error) alpaca_trade_api.rest.APIError: stop price must be less than base_price - 0.01
Process finished with exit code 1