Skip to content

trading_agent.risk.order_request

What a desk wants to do, described for the risk engine.

Typical usage example:

request = OrderRequest(desk='main', instrument_id='...', exchange='nse', segment='nse_equities', symbol='INFY', transaction_type='buy', quantity=10, product='cnc', price=1500.0)

OrderRequest dataclass

OrderRequest(desk, instrument_id, exchange, segment, symbol, transaction_type, quantity, product, price)

One order before it is sent.

Attributes:

Name Type Description
desk str

The desk sending it.

instrument_id str

UBI's id for the instrument.

exchange str

The exchange, such as nse or mcx.

segment str

UBI's segment, such as nse_equities or nse_equity_index_options.

symbol str

The instrument's symbol, or its underlying's for a future or option.

transaction_type str

"buy" or "sell".

quantity int

How many units, which is lots times lot size for derivatives; always positive.

product str

"cnc", "mis" or "nrml".

price float

The price the order is valued at: its limit or trigger price, or the last price for a market order.

signed_quantity property

signed_quantity

The change the order makes to the position: positive for a buy, negative for a sell.

is_option property

is_option

Whether the instrument is an option.

is_future property

is_future

Whether the instrument is a future.

describe

describe()

A one-line description for messages and the journal.

Returns:

Type Description
str

For example "buy 10 INFY (nse_equities, cnc) at 1500.0".

Source code in src/trading_agent/risk/order_request.py
def describe(self) -> str:
    """A one-line description for messages and the journal.

    Returns:
        str: For example "buy 10 INFY (nse_equities, cnc) at 1500.0".
    """
    return f'{self.transaction_type} {self.quantity} {self.symbol} ({self.segment}, {self.product}) at {self.price:g}'