Skip to navigation

Positions by Model

View as MarkdownOpen in Claude

Introduction

The function EClient.reqPositionsMulti can be used with any account structure to subscribe to positions updates for multiple accounts and/or models. The account and model parameters are optional if there are not multiple accounts or models available. It is more efficient to use this function for a specific subset of accounts than using EClient.reqPositions. A profile name can be accepted in place of group in the account parameter.


Request Positions by Model

EClient.reqPositionsMulti(requestId, account, modelCode)

Requests position subscription for account and/or model. Initially all positions are returned, and then updates are returned for any position changes in real time.

requestId
int

Request’s identifier.

account
string

If an account Id is provided, only the account’s positions belonging to the specified model will be delivered.

modelCode
string

The code of the model’s positions we are interested in.


self.reqPositionsMulti(requestid, "U1234567", "")

Receive Positions by Model

EWrapper.positionMulti

EWrapper.positionMulti(requestId, account, modelCode, contract, pos, avgCost)

Provides the portfolio’s open positions.

requestId
int

The id of request.

account
string

The account holding the position.

modelCode
string

The model code holding the position.

contract
Contract

The position’s Contract.

pos
decimal

The number of positions held.

avgCost
double

The average cost of the position.


def positionMulti(self, reqId: int, account: str, modelCode: str, contract: Contract, pos: Decimal, avgCost: float):
print("PositionMulti. RequestId:", reqId, "Account:", account, "ModelCode:", modelCode, "Contract:", contract, ",Position:", pos, "AvgCost:", avgCost)

EWrapper.positionMultiEnd

EWrapper.positionMultiEnd(requestId)

Indicates all the positions have been transmitted.

requestId
int

The id of request.


def positionMultiEnd(self, reqId: int):
print("PositionMultiEnd. RequestId:", reqId)

Cancel Positions by Model

EClient.cancelPositionsMulti(requestId)

Cancels positions request for account and/or model.

requestId
int

The identifier of the request to be canceled.


self.cancelPositionsMulti(requestid)