Class MarketDepth
- Namespace
- StockSharp.BusinessEntities
- Assembly
- StockSharp.BusinessEntities.dll
Order book.
[DataContract]
[Obsolete("Use IOrderBookMessage.")]
public class MarketDepth : Cloneable<MarketDepth>, IEnumerable<QuoteChange>, IEnumerable, IOrderBookMessage, ISecurityIdMessage, ISeqNumMessage, IServerTimeMessage, IGeneratedMessage, ICurrencyMessage, ILocalTimeMessage, ICloneable
- Inheritance
-
MarketDepth
- Implements
- Extension Methods
Constructors
MarketDepth(Security)
Create order book.
public MarketDepth(Security security)
Parameters
security
SecuritySecurity.
Properties
Asks
Quotes to sell.
[Display(ResourceType = typeof(LocalizedStrings), Name = "Asks", Description = "QuotesSell", GroupName = "Common", Order = 1)]
public QuoteChange[] Asks { get; set; }
Property Value
BestAsk
The best ask. If the order book does not contain asks, will be returned null.
[Display(ResourceType = typeof(LocalizedStrings), Name = "BestAsk")]
public QuoteChange? BestAsk { get; }
Property Value
BestBid
The best bid. If the order book does not contain bids, will be returned null.
[Display(ResourceType = typeof(LocalizedStrings), Name = "BestBid")]
public QuoteChange? BestBid { get; }
Property Value
BestPair
The best pair. If the order book is empty, will be returned null.
[Display(ResourceType = typeof(LocalizedStrings), Name = "BestPair")]
public MarketDepthPair BestPair { get; }
Property Value
Bids
Quotes to buy.
[Display(ResourceType = typeof(LocalizedStrings), Name = "Bids", Description = "QuotesBuy", GroupName = "Common", Order = 0)]
public QuoteChange[] Bids { get; set; }
Property Value
BuildFrom
Determines the message is generated from the specified DataType.
public DataType BuildFrom { get; set; }
Property Value
Count
Total quotes count (bids + asks).
[Display(ResourceType = typeof(LocalizedStrings), Name = "TotalQuotesCount")]
public int Count { get; }
Property Value
Currency
Trading security currency.
[Display(ResourceType = typeof(LocalizedStrings), Name = "Currency")]
public CurrencyTypes? Currency { get; set; }
Property Value
- CurrencyTypes?
Depth
Depth of book.
[Display(ResourceType = typeof(LocalizedStrings), Name = "DepthOfBook")]
public int Depth { get; }
Property Value
LastChangeTime
Last change time.
[Browsable(false)]
[Obsolete("Use ServerTime property.")]
public DateTimeOffset LastChangeTime { get; set; }
Property Value
LocalTime
Local timestamp when a message was received/created.
[Display(ResourceType = typeof(LocalizedStrings), Name = "LocalTime", Description = "LocalTimeDesc", GroupName = "Common", Order = 3)]
public DateTimeOffset LocalTime { get; set; }
Property Value
Security
Security.
public Security Security { get; }
Property Value
SeqNum
Sequence number.
public long SeqNum { get; set; }
Property Value
Remarks
Zero means no information.
ServerTime
Server time.
[Display(ResourceType = typeof(LocalizedStrings), Name = "ServerTime", Description = "ChangeServerTime", GroupName = "Common", Order = 2)]
public DateTimeOffset ServerTime { get; set; }
Property Value
TotalAsksPrice
To get the total price size by offers.
[Display(ResourceType = typeof(LocalizedStrings), Name = "TotalAsksPrice")]
public decimal TotalAsksPrice { get; }
Property Value
TotalAsksVolume
Get asks total volume.
[Display(ResourceType = typeof(LocalizedStrings), Name = "TotalAsksVolume")]
public decimal TotalAsksVolume { get; }
Property Value
TotalBidsPrice
To get the total price size by bids.
[Display(ResourceType = typeof(LocalizedStrings), Name = "TotalBidsPrice")]
public decimal TotalBidsPrice { get; }
Property Value
TotalBidsVolume
Get bids total volume.
[Display(ResourceType = typeof(LocalizedStrings), Name = "TotalBidsVolume")]
public decimal TotalBidsVolume { get; }
Property Value
TotalPrice
To get the total price size.
[Display(ResourceType = typeof(LocalizedStrings), Name = "TotalPrice")]
public decimal TotalPrice { get; }
Property Value
TotalVolume
Get total volume.
[Display(ResourceType = typeof(LocalizedStrings), Name = "TotalVolume")]
public decimal TotalVolume { get; }
Property Value
UseAggregatedQuotes
Whether to use aggregated quotes InnerQuotes at the join of the volumes with the same price.
public bool UseAggregatedQuotes { get; set; }
Property Value
Remarks
The default is disabled for performance.
Methods
AddAsk(decimal, decimal)
Add sell quote.
public void AddAsk(decimal price, decimal volume)
Parameters
AddBid(decimal, decimal)
Add buy quote.
public void AddBid(decimal price, decimal volume)
Parameters
AddQuote(QuoteChange, Sides)
To add the quote. If a quote with the same price is already in the order book, they are combined into the InnerQuotes.
public void AddQuote(QuoteChange quote, Sides side)
Parameters
quote
QuoteChangeThe new quote.
side
SidesSide.
Clone()
Create a copy of MarketDepth.
public override MarketDepth Clone()
Returns
- MarketDepth
Copy.
Decrease(int)
To reduce the order book to the required depth.
public void Decrease(int newDepth)
Parameters
newDepth
intNew order book depth.
GetBestQuote(Sides)
To get the best quote by the direction Sides.
public QuoteChange? GetBestQuote(Sides orderDirection)
Parameters
orderDirection
SidesOrder side.
Returns
- QuoteChange?
The best quote. If the order book is empty, then the null will be returned.
GetEnumerator()
To get the enumerator object.
public IEnumerator<QuoteChange> GetEnumerator()
Returns
- IEnumerator<QuoteChange>
The enumerator object.
GetPair(int)
To get a pair of quotes (bid + offer) by the depth index.
public MarketDepthPair GetPair(int depthIndex)
Parameters
depthIndex
intDepth index. Zero index means the best pair of quotes.
Returns
- MarketDepthPair
The pair of quotes. If the index is larger than book order depth Depth, then the null is returned.
GetQuote(Sides, int)
To get a quote by the direction Sides and the depth index.
public QuoteChange? GetQuote(Sides orderDirection, int depthIndex)
Parameters
Returns
- QuoteChange?
Quote. If a quote does not exist for specified depth, then the null will be returned.
GetQuote(decimal)
To get a quote by the price.
public QuoteChange? GetQuote(decimal price)
Parameters
price
decimalQuote price.
Returns
- QuoteChange?
Found quote. If there is no quote in the order book for the passed price, then the null will be returned.
GetQuotes(Sides)
To get quotes by the direction Sides.
public QuoteChange[] GetQuotes(Sides orderDirection)
Parameters
orderDirection
SidesOrders side.
Returns
- QuoteChange[]
Quotes.
GetTopPairs(int)
To get a pair of quotes for a given book depth.
public IEnumerable<MarketDepthPair> GetTopPairs(int depth)
Parameters
depth
intBook depth. The counting is from the best quotes.
Returns
- IEnumerable<MarketDepthPair>
Spread.
GetTopQuotes(int)
To get quotes for a given book depth.
public IEnumerable<QuoteChange> GetTopQuotes(int depth)
Parameters
depth
intBook depth. Quotes are in order of price increasing from bids to offers.
Returns
- IEnumerable<QuoteChange>
Spread.
Remove(Sides, decimal, decimal, DateTimeOffset)
Remove the volume for the price.
public void Remove(Sides direction, decimal price, decimal volume = 0, DateTimeOffset lastChangeTime = default)
Parameters
direction
SidesOrder side.
price
decimalRemove the quote for the price.
volume
decimalThe volume to be deleted. If it is not specified, then all the quote is removed.
lastChangeTime
DateTimeOffsetOrder book change time.
Remove(decimal, decimal, DateTimeOffset)
Remove the volume for the price.
public void Remove(decimal price, decimal volume = 0, DateTimeOffset lastChangeTime = default)
Parameters
price
decimalRemove the quote for the price.
volume
decimalThe volume to be deleted. If it is not specified, then all the quote is removed.
lastChangeTime
DateTimeOffsetOrder book change time.
ToPairs()
To get all pairs from the order book.
public IEnumerable<MarketDepthPair> ToPairs()
Returns
- IEnumerable<MarketDepthPair>
Pairs from which the order book is composed.
ToString()
public override string ToString()
Returns
Update(QuoteChange[], QuoteChange[], DateTimeOffset)
To update the order book. The version without checks and blockings.
public MarketDepth Update(QuoteChange[] bids, QuoteChange[] asks, DateTimeOffset lastChangeTime)
Parameters
bids
QuoteChange[]Sorted bids.
asks
QuoteChange[]Sorted asks.
lastChangeTime
DateTimeOffsetChange time.
Returns
- MarketDepth
Market depth.
UpdateQuote(QuoteChange, Sides)
To refresh the quote. If a quote with the same price is already in the order book, it is updated as passed. Otherwise, it automatically rebuilds the order book.
public void UpdateQuote(QuoteChange quote, Sides side)
Parameters
quote
QuoteChangeThe new quote.
side
SidesSide.