Skip to content

Get Closed PnL not working for DEMO account #353

Description

@tarantimofey

Hi everyone! I have found that when I try to get PnL history using session.get_closed_pnl(), I receive the following error stating that it's not available for demo trading:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Users\Taran\Documents\venvs\trading\Lib\site-packages\pybit\_v5_position.py", line 264, in get_closed_pnl
    return self._submit_request(
  File "C:\Users\Taran\Documents\venvs\trading\Lib\site-packages\pybit\_http_manager.py", line 197, in _submit_request
    return self._handle_response(response, method, path, req_params, recv_window, retries_attempted)
           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\Users\Taran\Documents\venvs\trading\Lib\site-packages\pybit\_http_manager.py", line 282, in _handle_response
    raise InvalidRequestError(
pybit.exceptions.InvalidRequestError: Demo trading are not supported. (ErrCode: 10032) (ErrTime: 12:10:31).
Request → GET https://api-demo.bybit.com/v5/position/closed-pnl: .

When I use Postman, however, I can get the history without a problem:

Image

So, I'm wondering whether this is a problem with pybit and could it be resolved?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions