Table of Contents

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 Security

Security.

Properties

Asks

Quotes to sell.

[Display(ResourceType = typeof(LocalizedStrings), Name = "Asks", Description = "QuotesSell", GroupName = "Common", Order = 1)]
public QuoteChange[] Asks { get; set; }

Property Value

QuoteChange[]

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

QuoteChange?

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

QuoteChange?

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

MarketDepthPair

Bids

Quotes to buy.

[Display(ResourceType = typeof(LocalizedStrings), Name = "Bids", Description = "QuotesBuy", GroupName = "Common", Order = 0)]
public QuoteChange[] Bids { get; set; }

Property Value

QuoteChange[]

BuildFrom

Determines the message is generated from the specified DataType.

public DataType BuildFrom { get; set; }

Property Value

DataType

Count

Total quotes count (bids + asks).

[Display(ResourceType = typeof(LocalizedStrings), Name = "TotalQuotesCount")]
public int Count { get; }

Property Value

int

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

int

LastChangeTime

Last change time.

[Browsable(false)]
[Obsolete("Use ServerTime property.")]
public DateTimeOffset LastChangeTime { get; set; }

Property Value

DateTimeOffset

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

DateTimeOffset

Security

Security.

public Security Security { get; }

Property Value

Security

SeqNum

Sequence number.

public long SeqNum { get; set; }

Property Value

long

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

DateTimeOffset

TotalAsksPrice

To get the total price size by offers.

[Display(ResourceType = typeof(LocalizedStrings), Name = "TotalAsksPrice")]
public decimal TotalAsksPrice { get; }

Property Value

decimal

TotalAsksVolume

Get asks total volume.

[Display(ResourceType = typeof(LocalizedStrings), Name = "TotalAsksVolume")]
public decimal TotalAsksVolume { get; }

Property Value

decimal

TotalBidsPrice

To get the total price size by bids.

[Display(ResourceType = typeof(LocalizedStrings), Name = "TotalBidsPrice")]
public decimal TotalBidsPrice { get; }

Property Value

decimal

TotalBidsVolume

Get bids total volume.

[Display(ResourceType = typeof(LocalizedStrings), Name = "TotalBidsVolume")]
public decimal TotalBidsVolume { get; }

Property Value

decimal

TotalPrice

To get the total price size.

[Display(ResourceType = typeof(LocalizedStrings), Name = "TotalPrice")]
public decimal TotalPrice { get; }

Property Value

decimal

TotalVolume

Get total volume.

[Display(ResourceType = typeof(LocalizedStrings), Name = "TotalVolume")]
public decimal TotalVolume { get; }

Property Value

decimal

UseAggregatedQuotes

Whether to use aggregated quotes InnerQuotes at the join of the volumes with the same price.

public bool UseAggregatedQuotes { get; set; }

Property Value

bool

Remarks

The default is disabled for performance.

Methods

AddAsk(decimal, decimal)

Add sell quote.

public void AddAsk(decimal price, decimal volume)

Parameters

price decimal

Sell price.

volume decimal

Sell volume.

AddBid(decimal, decimal)

Add buy quote.

public void AddBid(decimal price, decimal volume)

Parameters

price decimal

Buy price.

volume decimal

Buy volume.

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 QuoteChange

The new quote.

side Sides

Side.

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 int

New order book depth.

GetBestQuote(Sides)

To get the best quote by the direction Sides.

public QuoteChange? GetBestQuote(Sides orderDirection)

Parameters

orderDirection Sides

Order 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 int

Depth 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

orderDirection Sides

Orders side.

depthIndex int

Depth index. Zero index means the best quote.

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 decimal

Quote 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 Sides

Orders 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 int

Book 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 int

Book 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 Sides

Order side.

price decimal

Remove the quote for the price.

volume decimal

The volume to be deleted. If it is not specified, then all the quote is removed.

lastChangeTime DateTimeOffset

Order 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 decimal

Remove the quote for the price.

volume decimal

The volume to be deleted. If it is not specified, then all the quote is removed.

lastChangeTime DateTimeOffset

Order 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

string

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 DateTimeOffset

Change 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 QuoteChange

The new quote.

side Sides

Side.