Skip to content

Commit

Permalink
Helper already checks flag
Browse files Browse the repository at this point in the history
  • Loading branch information
O-Mutt committed Jan 23, 2024
1 parent 1608eb9 commit 32b3529
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions src/ExchangeSharp/API/Exchanges/Coinbase/ExchangeCoinbaseAPI.cs
Original file line number Diff line number Diff line change
Expand Up @@ -396,15 +396,14 @@ 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", amount },
{"base_size", order.RoundAmount().ToStringInvariant() },
{"limit_price", order.Price.ToStringInvariant() },
{"end_time", order.ExtraParameters["gtd_timestamp"] },
{"post_only", order.ExtraParameters.TryGetValueOrDefault( "post_only", false) }
Expand All @@ -414,7 +413,7 @@ protected override async Task<ExchangeOrderResult> OnPlaceOrderAsync(ExchangeOrd
{
orderConfig.Add("limit_limit_gtc", new Dictionary<string, object>()
{
{"base_size", amount },
{"base_size", order.RoundAmount().ToStringInvariant() },
{"limit_price", order.Price.ToStringInvariant() },
{"post_only", order.ExtraParameters.TryGetValueOrDefault( "post_only", "false") }
});
Expand All @@ -425,7 +424,7 @@ protected override async Task<ExchangeOrderResult> OnPlaceOrderAsync(ExchangeOrd
{
orderConfig.Add("stop_limit_stop_limit_gtd", new Dictionary<string, object>()
{
{"base_size", amount },
{"base_size", order.RoundAmount().ToStringInvariant() },
{"limit_price", order.Price.ToStringInvariant() },
{"stop_price", order.StopPrice.ToStringInvariant() },
{"end_time", order.ExtraParameters["gtd_timestamp"] },
Expand All @@ -435,15 +434,15 @@ protected override async Task<ExchangeOrderResult> OnPlaceOrderAsync(ExchangeOrd
{
orderConfig.Add("stop_limit_stop_limit_gtc", new Dictionary<string, object>()
{
{"base_size", amount },
{"base_size", order.RoundAmount().ToStringInvariant() },
{"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", amount }});
else orderConfig.Add("market_market_ioc", new Dictionary<string, object>() { { "base_size", amount }});
if (order.IsBuy) orderConfig.Add("market_market_ioc", new Dictionary<string, object>() { { "quote_size", order.RoundAmount().ToStringInvariant() }});
else orderConfig.Add("market_market_ioc", new Dictionary<string, object>() { { "base_size", order.RoundAmount().ToStringInvariant() }});
break;
}

Expand All @@ -466,7 +465,7 @@ protected override async Task<ExchangeOrderResult> OnPlaceOrderAsync(ExchangeOrd
ClientOrderId = order.ClientOrderId,
ResultCode = $"{token["error_response"]["error"].ToStringInvariant()} - {token["error_response"]["preview_failure_reason"].ToStringInvariant()}",
AmountFilled = 0,
Amount = order.Amount,
Amount = order.RoundAmount(),
AveragePrice = 0,
Fees = 0,
FeesCurrency = "USDT"
Expand Down

0 comments on commit 32b3529

Please sign in to comment.