SizeRisk#

API documentation for tradeexecutor.state.size_risk.SizeRisk Python class in Trading Strategy framework.

class SizeRisk[source]#

Bases: object

Result of a price impact estimation during decide_trades().

  • Used by py:class:~tradeexecutor.strategy.trade_sizer.TradeSizer to return the estimations of the safe trade sizes (not too much price impact, not too much liquidity risk)

  • Capture and save data about the price impact, so we can diagnose this later. Not just the result, but the variables that lead to the result.

  • Allows us to use this to cap the max position size when we enter to a position.

Note

A position size is different from a trade size, as we may grow a larger position using a multiple trades to enter

See also

__init__(timestamp, pair, sizing_type, path, capped, block_number=None, mid_price=None, avg_price=None, asked_quantity=None, asked_size=None, accepted_quantity=None, accepted_size=None, diagnostics_data=None)#
Parameters:
Return type:

None

Methods

__init__(timestamp, pair, sizing_type, path, ...)

from_dict(kvs, *[, infer_missing])

from_json(s, *[, parse_float, parse_int, ...])

schema(*[, infer_missing, only, exclude, ...])

to_dict([encode_json])

to_json(*[, skipkeys, ensure_ascii, ...])

Attributes

timestamp

For which timepoint this price impact estimation was made

pair

sizing_type

Buy or sell

path

Path of the trade One trade can have multiple swaps if there is an intermediary pair.

capped

Was this trade hitting the maximum cap.

block_number

Block number we used for onchain estimation

mid_price

Venue mid price per token

avg_price

Avg price per token when accepted size is filled

asked_quantity

How much we want to get

asked_size

How much we want to get

accepted_quantity

What was the capped size by the

accepted_size

What was the capped size

diagnostics_data

Store various diagnostics data items ehre

timestamp: datetime.datetime | None#

For which timepoint this price impact estimation was made

Can be set to None if not relevant.

sizing_type: SizingType#

Buy or sell

path: list[tradeexecutor.state.identifier.TradingPairIdentifier]#

Path of the trade One trade can have multiple swaps if there is an intermediary pair.

capped: bool#

Was this trade hitting the maximum cap.

This means the trade size was reduced due to risk.

block_number: int | None#

Block number we used for onchain estimation

mid_price: float | None#

Venue mid price per token

avg_price: float | None#

Avg price per token when accepted size is filled

asked_quantity: decimal.Decimal | None#

How much we want to get

asked_size: float | None#

How much we want to get

accepted_quantity: decimal.Decimal | None#

What was the capped size by the

accepted_size: float | None#

What was the capped size

diagnostics_data: dict | None#

Store various diagnostics data items ehre

Each implementation can store e.g. percents

__init__(timestamp, pair, sizing_type, path, capped, block_number=None, mid_price=None, avg_price=None, asked_quantity=None, asked_size=None, accepted_quantity=None, accepted_size=None, diagnostics_data=None)#
Parameters:
Return type:

None