Quoting algorithm allows you to control the position of the registered orders in the order book. The necessary of such functionality occurs when you need to
quickly open and close positions at favorable prices. Also, due to the quick monitoring of the order book, the quoting allows to realize scalping tools
for over small time frames.
Also, the quoting can emulate market orders on a exchanges, where the OrderTypesMarket
type of orders is not supported.
Prerequisites
To implement the quoting the S# includes the QuotingStrategy
class. This is the base abstract class for all derivative algorithms:
- MarketQuotingStrategy – this algorithm monitors the best quote
(SecurityBestBid for buy
or SecurityBestAsk for sell),
registering its orders for the same price or a little better, depending on the
MarketQuotingStrategyPriceOffset value.
Additionally, the MarketQuotingStrategy includes the
MarketQuotingStrategyPriceType,
parameter, which controls the position of the order movement in spread:
MarketPriceTypesFollowing – the algorithm looks the best quote,
MarketQuotingStrategyPriceType,
MarketPriceTypesMiddle – the algorithm will put the order in the middle
of the spread. This parameter affects how soon the order will be matched.
- BestByVolumeQuotingStrategy – looks what total volume has a better price than quoted order
and if it exceeds the permitted limit VolumeExchange,
the order is moved to the edge of the spread.
- BestByPriceQuotingStrategy – looks how far the quoted order is from the best quote.
If the tolerance interval BestPriceOffset has been exceeded,
the order is moved to the edge of the spread.
- LastTradeQuotingStrategy – is similar to the MarketQuotingStrategy
except that it monitors not order book depth, but the last trade SecurityLastTrade.
- LevelQuotingStrategy – quoting by the specified level in the order book.
- LimitQuotingStrategy – quoting by the limited price.
Quoting adding to the SampleSMA
It is necessary to enable the export of the order book before starting work, so the moving average algorithm described in the
iteration model,
section begin to work in association with the strategy:
if (!_isAaplOrderBookStarted)
{
_connector.SubscribeMarketDepth(aapl);
_isAaplOrderBookStarted = true;
}
It is necessary to replace the code in the SmaStrategy class from:
base.RegisterOrder(order);
to:
var strategy = new MarketQuotingStrategy(direction, volume);
ChildStrategies.Add(strategy);
Next Steps