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

Fix CryptoUtility.PrecisionToStepSize and add rate limit for Poloniex #800

Merged
merged 3 commits into from
Mar 26, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ private ExchangePoloniexAPI()
RequestContentType = "application/json";
MarketSymbolSeparator = "_";
WebSocketOrderBookType = WebSocketOrderBookType.DeltasOnly;
RateLimit = new RateGate(10, TimeSpan.FromSeconds(1));
}

/// <summary>
Expand Down Expand Up @@ -78,9 +79,8 @@ protected override Task OnInitializeAsync()
fieldCount[split[0]] = split[1].ConvertInvariant<int>();
}
}

WithdrawalFieldCount = fieldCount;
ExchangeGlobalCurrencyReplacements["STR"] = "XLM"; // wtf

return Task.CompletedTask;
}

Expand Down
8 changes: 3 additions & 5 deletions src/ExchangeSharp/Utility/CryptoUtility.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1412,14 +1412,12 @@ public static decimal CalculatePrecision(string numberWithDecimals)
/// </summary>
public static decimal PrecisionToStepSize(decimal precision)
{
if (precision == 0) return 1;

var sb = new StringBuilder();
sb.Append("0");
if (precision > 0) sb.Append(".");
if (precision == 1)
{
sb.Append("1");
return decimal.Parse(sb.ToStringInvariant());
}

for (var i = 0; i < precision; i++)
{
sb.Append(i + 1 == precision ? "1" : "0");
Expand Down