Skip to content

Commit

Permalink
Fixes #34: Add support for Product.BaseIncrement.
Browse files Browse the repository at this point in the history
Add support for Product.TradingDisabled.
Add support for MarketData.GetSingleProductAsync.
More XML docs to Coinbase.Pro.Models.Product.
Update HISTORY.md
Update Verify files regarding Product
  • Loading branch information
bchavez committed Feb 13, 2021
1 parent 1e9ba1d commit c7717b1
Show file tree
Hide file tree
Showing 9 changed files with 215 additions and 651 deletions.
6 changes: 6 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,9 @@
## v4.1.1
* Issue 34: Add support for Product.BaseIncrement.
* Add support for Product.TradingDisabled.
* Add support for MarketData.GetSingleProductAsync.
* More XML docs to Coinbase.Pro.Models.Product.

## v4.0.1
* PR 33: Changes Before and After pagination types from `long` to `string` because some endpoints use date/time strings. Thanks devax!

Expand Down
16 changes: 15 additions & 1 deletion Source/Coinbase.Pro/CoinbaseProClient.MarketData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,14 +13,20 @@ public interface IMarketDataEndpoint
/// <summary>
/// Get a list of available currency pairs for trading.
/// </summary>
/// <param name="cancellationToken"></param>
/// <remarks>
/// The base_min_size and base_max_size fields define the min and max order size. The quote_increment field specifies the min order price as well as the price increment.
/// The order price must be a multiple of this increment(i.e. if the increment is 0.01, order prices of 0.001 or 0.021 would be rejected).
/// Product ID will not change once assigned to a product but the min/max/quote sizes can be updated in the future.
/// </remarks>
Task<List<Product>> GetProductsAsync(CancellationToken cancellationToken = default);

/// <summary>
/// Get market data for a specific currency pair.
/// </summary>
/// <param name="productId">Required; the product id. eg: 'BTC-USD'</param>
/// <returns></returns>
Task<Product> GetSingleProductAsync(string productId, CancellationToken cancellationToken = default);

/// <summary>
/// Get a list of open orders for a product. The amount of detail shown can be customized with the level parameter.
/// </summary>
Expand Down Expand Up @@ -86,6 +92,14 @@ Task<List<Product>> IMarketDataEndpoint.GetProductsAsync(CancellationToken cance
.GetJsonAsync<List<Product>>(cancellationToken);
}

Task<Product> IMarketDataEndpoint.GetSingleProductAsync(string productId, CancellationToken cancellationToken)
{
return this.ProductsEndpoint
.AppendPathSegment(productId)
.WithClient(this)
.GetJsonAsync<Product>(cancellationToken);
}

Task<OrderBook> IMarketDataEndpoint.GetOrderBookAsync(string productId, int level, CancellationToken cancellationToken)
{
return this.ProductsEndpoint
Expand Down
44 changes: 44 additions & 0 deletions Source/Coinbase.Pro/Models/Objects.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,22 @@ public partial class Product : Json
[JsonProperty("base_currency")]
public string BaseCurrency { get; set; }

/// <summary>
/// The base_min_size and base_max_size fields define the min and max order size.
/// </summary>
[JsonProperty("base_max_size")]
public decimal BaseMaxSize { get; set; }

/// <summary>
/// The base_min_size and base_max_size fields define the min and max order size.
/// </summary>
[JsonProperty("base_min_size")]
public decimal BaseMinSize { get; set; }

/// <summary>
/// cancel_only indicates whether this product only accepts cancel requests for orders.
/// Only a maximum of one of trading_disabled, cancel_only, post_only, limit_only can be true at once. If none are true, the product is trading normally.
/// </summary>
[JsonProperty("cancel_only")]
public bool CancelOnly { get; set; }

Expand All @@ -27,30 +37,64 @@ public partial class Product : Json
[JsonProperty("id")]
public string Id { get; set; }

/// <summary>
/// limit_only indicates whether this product only accepts limit orders.
/// Only a maximum of one of trading_disabled, cancel_only, post_only, limit_only can be true at once. If none are true, the product is trading normally.
/// </summary>
[JsonProperty("limit_only")]
public bool LimitOnly { get; set; }

[JsonProperty("margin_enabled")]
public bool MarginEnabled { get; set; }

/// <summary>
/// The min_market_funds and max_market_funds fields define the min and max funds allowed in a market order.
/// </summary>
[JsonProperty("max_market_funds")]
public decimal? MaxMarketFunds { get; set; }

/// <summary>
/// The min_market_funds and max_market_funds fields define the min and max funds allowed in a market order.
/// </summary>
[JsonProperty("min_market_funds")]
public decimal? MinMarketFunds { get; set; }

/// <summary>
/// post_only indicates whether only maker orders can be placed. No orders will be matched when post_only mode is active.
/// Only a maximum of one of trading_disabled, cancel_only, post_only, limit_only can be true at once. If none are true, the product is trading normally.
/// </summary>
[JsonProperty("post_only")]
public bool PostOnly { get; set; }

/// <summary>
/// trading_disabled indicates whether trading is currently restricted on this product, this includes whether both new orders and order cancelations are restricted.
/// Only a maximum of one of trading_disabled, cancel_only, post_only, limit_only can be true at once. If none are true, the product is trading normally.
/// </summary>
[JsonProperty("trading_disabled")]
public bool TradingDisabled { get; set; }

[JsonProperty("quote_currency")]
public string QuoteCurrency { get; set; }

/// <summary>
/// The quote_increment field specifies the min order price as well as the price increment.
/// The order price must be a multiple of this increment (i.e. if the increment is 0.01, order prices of 0.001 or 0.021 would be rejected).
/// </summary>
[JsonProperty("quote_increment")]
public decimal QuoteIncrement { get; set; }

/// <summary>
/// The base_increment field specifies the minimum increment for the base_currency.
/// </summary>
[JsonProperty("base_increment")]
public decimal BaseIncrement { get; set; }

[JsonProperty("status")]
public string Status { get; set; }

/// <summary>
/// status_message provides any extra information regarding the status if available.
/// </summary>
[JsonProperty("status_message")]
public object StatusMessage { get; set; }
}
Expand Down
Loading

0 comments on commit c7717b1

Please sign in to comment.