Lean  $LEAN_TAG$
QuantConnect.Orders.Fills.EquityFillModel Class Reference

Represents the fill model used to simulate order fills for equities More...

Inheritance diagram for QuantConnect.Orders.Fills.EquityFillModel:
[legend]

Public Member Functions

override OrderEvent LimitIfTouchedFill (Security asset, LimitIfTouchedOrder order)
 Default limit if touched fill model implementation in base class security. More...
 
override OrderEvent MarketFill (Security asset, MarketOrder order)
 Default market fill model for the base security class. Fills at the last traded price. More...
 
override OrderEvent StopMarketFill (Security asset, StopMarketOrder order)
 Stop fill model implementation for Equity. More...
 
override OrderEvent StopLimitFill (Security asset, StopLimitOrder order)
 Default stop limit fill model implementation in base class security. (Stop Limit Order Type) More...
 
override OrderEvent LimitFill (Security asset, LimitOrder order)
 Limit fill model implementation for Equity. More...
 
override OrderEvent MarketOnOpenFill (Security asset, MarketOnOpenOrder order)
 Market on Open Fill Model. Return an order event with the fill details More...
 
override OrderEvent MarketOnCloseFill (Security asset, MarketOnCloseOrder order)
 Market on Close Fill Model. Return an order event with the fill details More...
 
- Public Member Functions inherited from QuantConnect.Orders.Fills.FillModel
void SetPythonWrapper (FillModelPythonWrapper pythonWrapper)
 Used to set the FillModelPythonWrapper instance if any More...
 
virtual Fill Fill (FillModelParameters parameters)
 Return an order event with the fill details More...
 
virtual List< OrderEventComboMarketFill (Order order, FillModelParameters parameters)
 Default combo market fill model for the base security class. Fills at the last traded price for each leg. More...
 
virtual List< OrderEventComboLimitFill (Order order, FillModelParameters parameters)
 Default combo limit fill model for the base security class. Fills at the sum of prices for the assets of every leg. More...
 
virtual List< OrderEventComboLegLimitFill (Order order, FillModelParameters parameters)
 Default combo limit fill model for the base security class. Fills at the limit price for each leg More...
 
virtual OrderEvent TrailingStopFill (Security asset, TrailingStopOrder order)
 Default trailing stop fill model implementation in base class security. (Trailing Stop Order Type) More...
 

Protected Member Functions

override HashSet< Type > GetSubscribedTypes (Security asset)
 Get data types the Security is subscribed to More...
 
override Prices GetPricesCheckingPythonWrapper (Security asset, OrderDirection direction)
 This is required due to a limitation in PythonNet to resolved overriden methods. GetPrices More...
 
override Prices GetPrices (Security asset, OrderDirection direction)
 Get the minimum and maximum price for this security in the last bar: More...
 
- Protected Member Functions inherited from QuantConnect.Orders.Fills.FillModel
virtual bool IsExchangeOpen (Security asset, bool isExtendedMarketHours)
 Determines if the exchange is open using the current time of the asset More...
 

Additional Inherited Members

- Properties inherited from QuantConnect.Orders.Fills.FillModel
FillModelParameters Parameters [get, set]
 The parameters instance to be used by the different XxxxFill() implementations More...
 
FillModelPythonWrapper PythonWrapper [get, set]
 This is required due to a limitation in PythonNet to resolved overriden methods. When Python calls a C# method that calls a method that's overriden in python it won't run the python implementation unless the call is performed through python too. More...
 

Detailed Description

Represents the fill model used to simulate order fills for equities

Definition at line 33 of file EquityFillModel.cs.

Member Function Documentation

◆ LimitIfTouchedFill()

override OrderEvent QuantConnect.Orders.Fills.EquityFillModel.LimitIfTouchedFill ( Security  asset,
LimitIfTouchedOrder  order 
)
virtual

Default limit if touched fill model implementation in base class security.

Parameters
assetSecurity asset we're filling
orderOrder packet to model
Returns
Order fill information detailing the average price and quantity filled.

There is no good way to model limit orders with OHLC because we never know whether the market has gapped past our fill price. We have to make the assumption of a fluid, high volume market.

With Limit if Touched orders, whether or not a trigger is surpassed is determined by the high (low) of the previous tradebar when making a sell (buy) request. Following the behaviour of StopLimitFill, current quote information is used when determining fill parameters (e.g., price, quantity) as the tradebar containing the incoming data is not yet consolidated. This conservative approach, however, can lead to trades not occuring as would be expected when compared to future consolidated data.

Reimplemented from QuantConnect.Orders.Fills.FillModel.

Definition at line 52 of file EquityFillModel.cs.

Here is the call graph for this function:

◆ MarketFill()

override OrderEvent QuantConnect.Orders.Fills.EquityFillModel.MarketFill ( Security  asset,
MarketOrder  order 
)
virtual

Default market fill model for the base security class. Fills at the last traded price.

Parameters
assetSecurity asset we're filling
orderOrder packet to model
Returns
Order fill information detailing the average price and quantity filled.

Reimplemented from QuantConnect.Orders.Fills.FillModel.

Definition at line 124 of file EquityFillModel.cs.

Here is the call graph for this function:

◆ StopMarketFill()

override OrderEvent QuantConnect.Orders.Fills.EquityFillModel.StopMarketFill ( Security  asset,
StopMarketOrder  order 
)
virtual

Stop fill model implementation for Equity.

Parameters
assetSecurity asset we're filling
orderOrder packet to model
Returns
Order fill information detailing the average price and quantity filled.

A Stop order is an instruction to submit a buy or sell market order if and when the user-specified stop trigger price is attained or penetrated.

A Sell Stop order is always placed below the current market price. We assume a fluid/continuous, high volume market. Therefore, it is filled at the stop trigger price if the current low price of trades is less than or equal to this price.

A Buy Stop order is always placed above the current market price. We assume a fluid, high volume market. Therefore, it is filled at the stop trigger price if the current high price of trades is greater or equal than this price.

The continuous market assumption is not valid if the market opens with an unfavorable gap. In this case, a new bar opens below/above the stop trigger price, and the order is filled with the opening price.

See also
MarketFill(Security, MarketOrder)

Reimplemented from QuantConnect.Orders.Fills.FillModel.

Definition at line 180 of file EquityFillModel.cs.

Here is the call graph for this function:

◆ StopLimitFill()

override OrderEvent QuantConnect.Orders.Fills.EquityFillModel.StopLimitFill ( Security  asset,
StopLimitOrder  order 
)
virtual

Default stop limit fill model implementation in base class security. (Stop Limit Order Type)

Parameters
assetSecurity asset we're filling
orderOrder packet to model
Returns
Order fill information detailing the average price and quantity filled.
See also
StopMarketFill(Security, StopMarketOrder)

There is no good way to model limit orders with OHLC because we never know whether the market has gapped past our fill price. We have to make the assumption of a fluid, high volume market.

Stop limit orders we also can't be sure of the order of the H - L values for the limit fill. The assumption was made the limit fill will be done with closing price of the bar after the stop has been triggered..

Reimplemented from QuantConnect.Orders.Fills.FillModel.

Definition at line 258 of file EquityFillModel.cs.

Here is the call graph for this function:

◆ LimitFill()

override OrderEvent QuantConnect.Orders.Fills.EquityFillModel.LimitFill ( Security  asset,
LimitOrder  order 
)
virtual

Limit fill model implementation for Equity.

Parameters
assetSecurity asset we're filling
orderOrder packet to model
Returns
Order fill information detailing the average price and quantity filled.

A Limit order is an order to buy or sell at a specified price or better. The Limit order ensures that if the order fills, it will not fill at a price less favorable than your limit price, but it does not guarantee a fill.

A Buy Limit order is always placed above the current market price. We assume a fluid/continuous, high volume market. Therefore, it is filled at the limit price if the current low price of trades is less than this price.

A Sell Limit order is always placed below the current market price. We assume a fluid, high volume market. Therefore, it is filled at the limit price if the current high price of trades is greater than this price.

This model does not trigger the limit order when the limit is attained (equals to). Since the order may not be filled in reality if it is not the top of the order book (first come, first served), we assume our order is the last in the book with its limit price, thus it will be filled when the limit price is penetrated.

The continuous market assumption is not valid if the market opens with a favorable gap. If the buy/sell limit order is placed below/above the current market price, the order is filled with the opening price.

See also
StopMarketFill(Security, StopMarketOrder), MarketFill(Security, MarketOrder)

Reimplemented from QuantConnect.Orders.Fills.FillModel.

Definition at line 364 of file EquityFillModel.cs.

Here is the call graph for this function:

◆ MarketOnOpenFill()

override OrderEvent QuantConnect.Orders.Fills.EquityFillModel.MarketOnOpenFill ( Security  asset,
MarketOnOpenOrder  order 
)
virtual

Market on Open Fill Model. Return an order event with the fill details

Parameters
assetAsset we're trading with this order
orderOrder to be filled
Returns
Order fill information detailing the average price and quantity filled.

Reimplemented from QuantConnect.Orders.Fills.FillModel.

Definition at line 440 of file EquityFillModel.cs.

Here is the call graph for this function:

◆ MarketOnCloseFill()

override OrderEvent QuantConnect.Orders.Fills.EquityFillModel.MarketOnCloseFill ( Security  asset,
MarketOnCloseOrder  order 
)
virtual

Market on Close Fill Model. Return an order event with the fill details

Parameters
assetAsset we're trading with this order
orderOrder to be filled
Returns
Order fill information detailing the average price and quantity filled.

Reimplemented from QuantConnect.Orders.Fills.FillModel.

Definition at line 581 of file EquityFillModel.cs.

Here is the call graph for this function:

◆ GetSubscribedTypes()

override HashSet<Type> QuantConnect.Orders.Fills.EquityFillModel.GetSubscribedTypes ( Security  asset)
protectedvirtual

Get data types the Security is subscribed to

Parameters
assetSecurity which has subscribed data types

Reimplemented from QuantConnect.Orders.Fills.FillModel.

Definition at line 698 of file EquityFillModel.cs.

Here is the caller graph for this function:

◆ GetPricesCheckingPythonWrapper()

override Prices QuantConnect.Orders.Fills.EquityFillModel.GetPricesCheckingPythonWrapper ( Security  asset,
OrderDirection  direction 
)
protectedvirtual

This is required due to a limitation in PythonNet to resolved overriden methods. GetPrices

Reimplemented from QuantConnect.Orders.Fills.FillModel.

Definition at line 979 of file EquityFillModel.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

◆ GetPrices()

override Prices QuantConnect.Orders.Fills.EquityFillModel.GetPrices ( Security  asset,
OrderDirection  direction 
)
protectedvirtual

Get the minimum and maximum price for this security in the last bar:

Parameters
assetSecurity asset we're checking
directionThe order direction, decides whether to pick bid or ask

Reimplemented from QuantConnect.Orders.Fills.FillModel.

Definition at line 994 of file EquityFillModel.cs.

Here is the call graph for this function:
Here is the caller graph for this function:

The documentation for this class was generated from the following file: