using System; using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using CryptoExchange.Net.Objects; namespace CryptoExchange.Net.Interfaces { /// /// Interface for order book /// public interface ISymbolOrderBook { /// /// The exchange the book is for /// string Exchange { get; } /// /// The Api the book is for /// string Api { get; } /// /// The status of the order book. Order book is up to date when the status is `Synced` /// OrderBookStatus Status { get; set; } /// /// Last update identifier /// long LastSequenceNumber { get; } /// /// The symbol of the order book /// string Symbol { get; } /// /// Event when the state changes /// event Action OnStatusChange; /// /// Event when order book was updated. Be careful! It can generate a lot of events at high-liquidity markets /// event Action<(IEnumerable Bids, IEnumerable Asks)> OnOrderBookUpdate; /// /// Event when the BestBid or BestAsk changes ie a Pricing Tick /// event Action<(ISymbolOrderBookEntry BestBid, ISymbolOrderBookEntry BestAsk)> OnBestOffersChanged; /// /// Timestamp of the last update /// DateTime UpdateTime { get; } /// /// The number of asks in the book /// int AskCount { get; } /// /// The number of bids in the book /// int BidCount { get; } /// /// Get a snapshot of the book at this moment /// (IEnumerable bids, IEnumerable asks) Book { get; } /// /// The list of asks /// IEnumerable Asks { get; } /// /// The list of bids /// IEnumerable Bids { get; } /// /// The best bid currently in the order book /// ISymbolOrderBookEntry BestBid { get; } /// /// The best ask currently in the order book /// ISymbolOrderBookEntry BestAsk { get; } /// /// BestBid/BesAsk returned as a pair /// (ISymbolOrderBookEntry Bid, ISymbolOrderBookEntry Ask) BestOffers { get; } /// /// Start connecting and synchronizing the order book /// /// A cancellation token to stop the order book when canceled /// Task> StartAsync(CancellationToken? ct = null); /// /// Stop syncing the order book /// /// Task StopAsync(); /// /// Get the average price that a market order would fill at at the current order book state. This is no guarentee that an order of that quantity would actually be filled /// at that price since between this calculation and the order placement the book might have changed. /// /// The quantity in base asset to fill /// The type /// Average fill price CallResult CalculateAverageFillPrice(decimal quantity, OrderBookEntryType type); /// /// Get the amount of base asset which can be traded with the quote quantity when placing a market order at at the current order book state. /// This is no guarentee that an order of that quantity would actually be fill the quantity returned by this since between this calculation and the order placement the book might have changed. /// /// The quantity in quote asset looking to trade /// The type /// Amount of base asset tradable with the specified amount of quote asset CallResult CalculateTradableAmount(decimal quoteQuantity, OrderBookEntryType type); /// /// String representation of the top x entries /// /// string ToString(int rows); } }