-
-
Notifications
You must be signed in to change notification settings - Fork 373
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
Changes from all commits
c019446
7ba7b52
81acebf
66fe413
6b235bb
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -252,7 +252,25 @@ protected override async Task<IEnumerable<KeyValuePair<string, ExchangeTicker>>> | |
#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. | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
if (maxCount > 100) | ||
{ | ||
maxCount = 500; | ||
} | ||
else if (maxCount > 25 && maxCount <= 100) // ExchangeSharp default. | ||
{ | ||
maxCount = 25; | ||
} | ||
else if (maxCount > 1 && maxCount <= 25) | ||
{ | ||
maxCount = 25; | ||
} | ||
else | ||
{ | ||
maxCount = 1; | ||
} | ||
|
||
JToken token = await MakeJsonRequestAsync<JToken>("/markets/" + marketSymbol + "/orderbook" + "?depth=" + maxCount); | ||
return ExchangeAPIExtensions.ParseOrderBookFromJTokenDictionaries(token, "ask", "bid", "rate", "quantity", maxCount: maxCount); | ||
} | ||
|
||
|
@@ -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"); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. |
||
} | ||
|
||
foreach (KeyValuePair<string, object> kv in order.ExtraParameters) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -749,13 +749,17 @@ protected override async Task<Dictionary<string, decimal>> OnGetAmountsAvailable | |
|
||
protected override async Task<ExchangeOrderResult> OnPlaceOrderAsync(ExchangeOrderRequest order) | ||
{ | ||
IEnumerable<ExchangeMarket> markets = await OnGetMarketSymbolsMetadataAsync(); | ||
ExchangeMarket market = markets.Where(m => m.MarketSymbol == order.MarketSymbol).First<ExchangeMarket>(); | ||
|
||
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()); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. This rounding avoids an error returned by Kraken's API that |
||
} | ||
order.ExtraParameters.CopyTo(payload); | ||
|
||
|
There was a problem hiding this comment.
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.