diff --git a/src/ExchangeSharp/API/Exchanges/_Base/ExchangeAPI.cs b/src/ExchangeSharp/API/Exchanges/_Base/ExchangeAPI.cs index fed7a696..0ef9d84b 100644 --- a/src/ExchangeSharp/API/Exchanges/_Base/ExchangeAPI.cs +++ b/src/ExchangeSharp/API/Exchanges/_Base/ExchangeAPI.cs @@ -743,6 +743,34 @@ public virtual async Task> GetMarketSymbolsMetadataA return null; } + /// + /// Gets the address to deposit to and applicable details. + /// + /// Currency to get address for. + /// Regenerate the address + /// Deposit address details (including tag if applicable, such as XRP) + public virtual async Task GetDepositAddressAsync(string currency, bool forceRegenerate = false) + { + if (forceRegenerate) + { + // force regenetate, do not cache + return await OnGetDepositAddressAsync(currency, forceRegenerate); + } + else + { + return await Cache.CacheMethod(MethodCachePolicy, async () => await OnGetDepositAddressAsync(currency, forceRegenerate), nameof(GetDepositAddressAsync), nameof(currency), currency); + } + } + + /// + /// Gets the deposit history for a symbol + /// + /// Collection of ExchangeCoinTransfers + public virtual async Task> GetDepositHistoryAsync(string currency) + { + return await Cache.CacheMethod(MethodCachePolicy, async () => await OnGetDepositHistoryAsync(currency), nameof(GetDepositHistoryAsync), nameof(currency), currency); + } + /// /// Get exchange ticker /// @@ -811,34 +839,6 @@ public virtual async Task> GetRecentTradesAsync(strin //return await Cache.CacheMethod(MethodCachePolicy, async () => await OnGetRecentTradesAsync(marketSymbol), nameof(GetRecentTradesAsync), nameof(marketSymbol), marketSymbol); } - /// - /// Gets the address to deposit to and applicable details. - /// - /// Currency to get address for. - /// Regenerate the address - /// Deposit address details (including tag if applicable, such as XRP) - public virtual async Task GetDepositAddressAsync(string currency, bool forceRegenerate = false) - { - if (forceRegenerate) - { - // force regenetate, do not cache - return await OnGetDepositAddressAsync(currency, forceRegenerate); - } - else - { - return await Cache.CacheMethod(MethodCachePolicy, async() => await OnGetDepositAddressAsync(currency, forceRegenerate), nameof(GetDepositAddressAsync), nameof(currency), currency); - } - } - - /// - /// Gets the deposit history for a symbol - /// - /// Collection of ExchangeCoinTransfers - public virtual async Task> GetDepositHistoryAsync(string currency) - { - return await Cache.CacheMethod(MethodCachePolicy, async() => await OnGetDepositHistoryAsync(currency), nameof(GetDepositHistoryAsync), nameof(currency), currency); - } - /// /// Get candles (open, high, low, close) /// @@ -855,6 +855,15 @@ public virtual async Task> GetCandlesAsync(string mark nameof(marketSymbol), marketSymbol, nameof(periodSeconds), periodSeconds, nameof(startDate), startDate, nameof(endDate), endDate, nameof(limit), limit); } + /// + /// Get fees + /// + /// The customer trading fees + public virtual async Task> GetFeesAync() + { + return await Cache.CacheMethod(MethodCachePolicy, async () => await OnGetFeesAsync(), nameof(GetFeesAync)); + } + /// /// Get total amounts, symbol / amount dictionary /// @@ -867,15 +876,6 @@ public virtual async Task> GetAmountsAsync() return globalAmounts; } - /// - /// Get fees - /// - /// The customer trading fees - public virtual async Task> GetFeesAync() - { - return await Cache.CacheMethod(MethodCachePolicy, async() => await OnGetFeesAsync(), nameof(GetFeesAync)); - } - /// /// Get amounts available to trade, symbol / amount dictionary /// diff --git a/src/ExchangeSharp/API/Exchanges/_Base/IExchangeAPI.cs b/src/ExchangeSharp/API/Exchanges/_Base/IExchangeAPI.cs index 4864b5ff..58cb7f5f 100644 --- a/src/ExchangeSharp/API/Exchanges/_Base/IExchangeAPI.cs +++ b/src/ExchangeSharp/API/Exchanges/_Base/IExchangeAPI.cs @@ -68,7 +68,7 @@ public interface IExchangeAPI : IDisposable, IBaseAPI, IOrderBookProvider #endregion Utility Methods - #region REST + #region REST API /// /// Gets currencies and related data such as IsEnabled and TxFee (if available) @@ -76,21 +76,6 @@ public interface IExchangeAPI : IDisposable, IBaseAPI, IOrderBookProvider /// Collection of Currencies Task> GetCurrenciesAsync(); - /// - /// Gets the address to deposit to and applicable details. - /// - /// Currency to get address for. - /// True to regenerate the address - /// Deposit address details (including tag if applicable, such as XRP) - Task GetDepositAddressAsync(string currency, bool forceRegenerate = false); - - /// - /// Gets the deposit history for a currency - /// - /// The currency to check. May be null. - /// Collection of ExchangeCoinTransfers - Task> GetDepositHistoryAsync(string currency); - /// /// Get symbols for the exchange markets /// @@ -109,6 +94,29 @@ public interface IExchangeAPI : IDisposable, IBaseAPI, IOrderBookProvider /// Collection of ExchangeMarkets Task> GetMarketSymbolsMetadataAsync(); + /// + /// Gets the exchange market from this exchange's SymbolsMetadata cache. This will make a network request if needed to retrieve fresh markets from the exchange using GetSymbolsMetadataAsync(). + /// Please note that sending a symbol that is not found over and over will result in many network requests. Only send symbols that you are confident exist on the exchange. + /// + /// The market symbol. Ex. ADA/BTC. This is assumed to be normalized and already correct for the exchange. + /// The ExchangeMarket or null if it doesn't exist in the cache or there was an error + Task GetExchangeMarketFromCacheAsync(string marketSymbol); + + /// + /// Gets the address to deposit to and applicable details. + /// + /// Currency to get address for. + /// True to regenerate the address + /// Deposit address details (including tag if applicable, such as XRP) + Task GetDepositAddressAsync(string currency, bool forceRegenerate = false); + + /// + /// Gets the deposit history for a currency + /// + /// The currency to check. May be null. + /// Collection of ExchangeCoinTransfers + Task> GetDepositHistoryAsync(string currency); + /// /// Get latest ticker /// @@ -132,6 +140,10 @@ public interface IExchangeAPI : IDisposable, IBaseAPI, IOrderBookProvider Task GetHistoricalTradesAsync(Func, bool> callback, string marketSymbol, DateTime? startDate = null, DateTime? endDate = null, int? limit = null); //Task GetHistoricalTradesAsync(Func, bool> callback, string marketSymbol, DateTime? startDate = null, DateTime? endDate = null); + // Task GetOrderBookAsync(string marketSymbol, int maxCount = 100); is in IOrderBookProvider + + // Task>> GetOrderBooksAsync(int maxCount = 100); is in IOrderBookProvider + /// /// Get the latest trades /// @@ -151,6 +163,12 @@ public interface IExchangeAPI : IDisposable, IBaseAPI, IOrderBookProvider /// Candles Task> GetCandlesAsync(string marketSymbol, int periodSeconds, DateTime? startDate = null, DateTime? endDate = null, int? limit = null); + /// + /// Get fees + /// + /// The customer trading fees + Task> GetFeesAync(); + /// /// Get total amounts, symbol / amount dictionary /// @@ -163,6 +181,13 @@ public interface IExchangeAPI : IDisposable, IBaseAPI, IOrderBookProvider /// Dictionary of symbols and amounts available to trade Task> GetAmountsAvailableToTradeAsync(); + /// + /// Get margin amounts available to trade, symbol / amount dictionary + /// + /// Include currencies with zero balance in return value + /// Dictionary of symbols and amounts available to trade in margin account + Task> GetMarginAmountsAvailableToTradeAsync(bool includeZeroBalances = false); + /// /// Place an order /// @@ -208,11 +233,16 @@ public interface IExchangeAPI : IDisposable, IBaseAPI, IOrderBookProvider Task CancelOrderAsync(string orderId, string? marketSymbol = null); /// - /// Get margin amounts available to trade, symbol / amount dictionary + /// Asynchronous withdraws request. /// - /// Include currencies with zero balance in return value - /// Dictionary of symbols and amounts available to trade in margin account - Task> GetMarginAmountsAvailableToTradeAsync(bool includeZeroBalances = false); + /// The withdrawal request. + Task WithdrawAsync(ExchangeWithdrawalRequest withdrawalRequest); + + /// + /// Gets the withdraw history for a symbol + /// + /// Collection of ExchangeCoinTransfers + Task> GetWithdrawHistoryAsync(string currency); /// /// Get open margin position @@ -228,15 +258,9 @@ public interface IExchangeAPI : IDisposable, IBaseAPI, IOrderBookProvider /// Close margin position result Task CloseMarginPositionAsync(string marketSymbol); - /// - /// Get fees - /// - /// The customer trading fees - Task> GetFeesAync(); - #endregion REST - #region Web Socket + #region Web Socket API /// /// Gets Candles (OHLC) websocket /// @@ -285,6 +309,12 @@ public interface IExchangeAPI : IDisposable, IBaseAPI, IOrderBookProvider /// Web socket, call Dispose to close Task GetCompletedOrderDetailsWebSocketAsync(Action callback); + /// + /// Get user detail over web socket + /// + /// Callback + /// Listen key + /// Web socket, call Dispose to close Task GetUserDataWebSocketAsync(Action callback, string listenKey); #endregion Web Socket }