Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixes for Bittrex and Kraken after testing live orders. #597

Merged
merged 5 commits into from
Jun 11, 2021
Merged

Fixes for Bittrex and Kraken after testing live orders. #597

merged 5 commits into from
Jun 11, 2021

Conversation

EcBen
Copy link
Contributor

@EcBen EcBen commented Jun 11, 2021

No description provided.

@@ -252,7 +252,25 @@ protected override async Task<ExchangeTicker> OnGetTickerAsync(string marketSymb
#region OrderBooks
protected override async Task<ExchangeOrderBook> OnGetOrderBookAsync(string marketSymbol, int maxCount = 25)
{
JToken token = await MakeJsonRequestAsync<JToken>("/markets/" + marketSymbol + "/orderbook" + marketSymbol + "&depth=" + maxCount);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This URL is invalid. Fixed below.

@@ -252,7 +252,25 @@ protected override async Task<ExchangeTicker> OnGetTickerAsync(string marketSymb
#region OrderBooks
protected override async Task<ExchangeOrderBook> OnGetOrderBookAsync(string marketSymbol, int maxCount = 25)
{
JToken token = await MakeJsonRequestAsync<JToken>("/markets/" + marketSymbol + "/orderbook" + marketSymbol + "&depth=" + maxCount);
// Bittrex API allowed values are [1, 25, 500], default is 25.
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@@ -370,7 +388,7 @@ protected override async Task<ExchangeOrderResult> OnPlaceOrderAsync(ExchangeOrd
if (order.OrderType == ExchangeSharp.OrderType.Limit)
{
orderParams.Add("limit", orderPrice);
//orderParams.Add("timeInForce", "GOOD_TIL_CANCELLED");
orderParams.Add("timeInForce", "GOOD_TIL_CANCELLED");
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bittrex V3 API is saying this is a required parameter now for limit orders.

object nonce = await GenerateNonceAsync();
Dictionary<string, object> payload = new Dictionary<string, object>(StringComparer.OrdinalIgnoreCase)
{ { "pair", order.MarketSymbol }, { "type", (order.IsBuy ? "buy" : "sell") }, { "ordertype", order.OrderType.ToString().ToLowerInvariant() }, { "volume", order.RoundAmount().ToStringInvariant() }, { "trading_agreement", "agree" }, { "nonce", nonce }
};
if (order.OrderType != OrderType.Market)
{
payload.Add("price", order.Price.ToStringInvariant());
int precision = BitConverter.GetBytes(Decimal.GetBits((decimal)market.PriceStepSize)[3])[2];
payload.Add("price", Math.Round(order.Price, precision).ToStringInvariant());
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This rounding avoids an error returned by Kraken's API that price can only have so many decimals.

@vslee vslee merged commit 3aff3e6 into DigitalRuby:master Jun 11, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants