TradeBuilder
QuantConnect.Statistics.TradeBuilder
TradeBuilder(
grouping_method: FillGroupingMethod,
matching_method: FillMatchingMethod,
)
Bases: Object, ITradeBuilder
The TradeBuilder class generates trades from executions and market price updates
Initializes a new instance of the TradeBuilder class
apply_split
apply_split(
split: Split,
live_mode: bool,
data_normalization_mode: DataNormalizationMode,
) -> None
Applies a split to the trade builder
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
split
|
Split
|
The split to be applied |
required |
live_mode
|
bool
|
True if live mode, false for backtest |
required |
data_normalization_mode
|
DataNormalizationMode
|
The DataNormalizationMode for this security |
required |
has_open_position
has_open_position(
symbol: Union[Symbol, str, BaseContract],
) -> bool
Returns true if there is an open position for the symbol
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
Union[Symbol, str, BaseContract]
|
The symbol |
required |
Returns:
| Type | Description |
|---|---|
bool
|
true if there is an open position for the symbol. |
process_fill
process_fill(
fill: OrderEvent,
security_conversion_rate: float,
fee_in_account_currency: float,
multiplier: float = 1.0,
) -> None
Processes a new fill, eventually creating new trades
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fill
|
OrderEvent
|
The new fill order event |
required |
security_conversion_rate
|
float
|
The current security market conversion rate into the account currency |
required |
fee_in_account_currency
|
float
|
The current order fee in the account currency |
required |
multiplier
|
float
|
The contract multiplier |
1.0
|
set_live_mode
set_live_mode(live: bool) -> None
Sets the live mode flag
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
live
|
bool
|
The live mode flag |
required |
set_market_price
set_market_price(
symbol: Union[Symbol, str, BaseContract], price: float
) -> None
Sets the current market price for the symbol
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
symbol
|
Union[Symbol, str, BaseContract]
|
|
required |
price
|
float
|
|
required |
set_security_manager
set_security_manager(securities: SecurityManager) -> None
Sets the security manager instance
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
securities
|
SecurityManager
|
The security manager |
required |