Skip to content

Commit

Permalink
Please round if requested
Browse files Browse the repository at this point in the history
  • Loading branch information
O-Mutt committed Jan 23, 2024
1 parent fdc5cfc commit 1608eb9
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions src/ExchangeSharp/API/Exchanges/Coinbase/ExchangeCoinbaseAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -396,14 +396,15 @@ protected override async Task<ExchangeOrderResult> OnPlaceOrderAsync(ExchangeOrd
payload["side"] = order.IsBuy ? BUY : "SELL";

Dictionary<string, object> orderConfig = new Dictionary<string, object>();
var amount = order.ShouldRoundAmount ? order.RoundAmount().ToStringInvariant() : order.Amount.ToStringInvariant();
switch (order.OrderType)
{
case OrderType.Limit:
if (order.ExtraParameters.ContainsKey("gtd_timestamp"))
{
orderConfig.Add("limit_limit_gtd", new Dictionary<string, object>()
{
{"base_size", order.Amount.ToStringInvariant() },
{"base_size", amount },
{"limit_price", order.Price.ToStringInvariant() },
{"end_time", order.ExtraParameters["gtd_timestamp"] },
{"post_only", order.ExtraParameters.TryGetValueOrDefault( "post_only", false) }
Expand All @@ -413,7 +414,7 @@ protected override async Task<ExchangeOrderResult> OnPlaceOrderAsync(ExchangeOrd
{
orderConfig.Add("limit_limit_gtc", new Dictionary<string, object>()
{
{"base_size", order.Amount.ToStringInvariant() },
{"base_size", amount },
{"limit_price", order.Price.ToStringInvariant() },
{"post_only", order.ExtraParameters.TryGetValueOrDefault( "post_only", "false") }
});
Expand All @@ -424,7 +425,7 @@ protected override async Task<ExchangeOrderResult> OnPlaceOrderAsync(ExchangeOrd
{
orderConfig.Add("stop_limit_stop_limit_gtd", new Dictionary<string, object>()
{
{"base_size", order.Amount.ToStringInvariant() },
{"base_size", amount },
{"limit_price", order.Price.ToStringInvariant() },
{"stop_price", order.StopPrice.ToStringInvariant() },
{"end_time", order.ExtraParameters["gtd_timestamp"] },
Expand All @@ -434,15 +435,15 @@ protected override async Task<ExchangeOrderResult> OnPlaceOrderAsync(ExchangeOrd
{
orderConfig.Add("stop_limit_stop_limit_gtc", new Dictionary<string, object>()
{
{"base_size", order.Amount.ToStringInvariant() },
{"base_size", amount },
{"limit_price", order.Price.ToStringInvariant() },
{"stop_price", order.StopPrice.ToStringInvariant() },
});
}
break;
case OrderType.Market:
if (order.IsBuy) orderConfig.Add("market_market_ioc", new Dictionary<string, object>() { { "quote_size", order.Amount.ToStringInvariant() }});
else orderConfig.Add("market_market_ioc", new Dictionary<string, object>() { { "base_size", order.Amount.ToStringInvariant() }});
if (order.IsBuy) orderConfig.Add("market_market_ioc", new Dictionary<string, object>() { { "quote_size", amount }});
else orderConfig.Add("market_market_ioc", new Dictionary<string, object>() { { "base_size", amount }});
break;
}

Expand Down

0 comments on commit 1608eb9

Please sign in to comment.