DigitalRuby / ExchangeSharp

ExchangeSharp is a powerful, fast and easy to use .NET/C# API for interfacing with many crypto currency exchanges. REST and web sockets are supported.
https://www.digitalruby.com
MIT License
744 stars 373 forks source link

Time interval GetCandlesAsynch not working correct #502

Open Speed1972 opened 5 years ago

Speed1972 commented 5 years ago

Api interval now a days has interval letter added to the time interval string. Example Binance: intervalNum describes the amount of the interval. For example, intervalNum 5 with intervalLetter M means "Every 5 minutes".

The Defined GetCandleAsync (in ExchnageAPI) has only the period Seconds without the intervalletter.

GetCandlesAsync(string marketSymbol, int periodSeconds, DateTime? startDate = null, DateTime? endDate = null, int? limit = null);

vslee commented 5 years ago

Not the prettiest fix, but you could send us a PR which uses a switch on periodSeconds. If it is a valid value, then it would send the appropriate corresponding string (w/ intervalLetter M) to Binance.

Speed1972 commented 5 years ago

Can you explane yourself a bit more?

vslee commented 5 years ago

If Binance is the exchange you use, then send us an updated version of OnGetCandlesAsync() and possibly CryptoUtility.SecondsToPeriodString(). If you do change CryptoUtility.SecondsToPeriodString(), please make sure you don't break any other exchanges in the process of fixing Binance.

Speed1972 commented 5 years ago

I was supposed to help you with potential problems in the open source code that you wrote. But you want me to solve those problems too? Do you also want me to look at another code from you to solve the problems there too? Or rewrite part of the code?

PS. Not only Binance uses Interval Letters

vslee commented 5 years ago

We welcome code contributions / pull requests. Like you, we do this in our free time. We then share our results with the community for free. If you're not interested, then we can close this issue. There's no need for you to have attitude or get upset.

vslee commented 4 years ago

@Speed1972, #504 is an example of how to send us the fix if you don't know how to send a pull request.

PeetCrypto commented 4 years ago

@vslee how would you like this isseu to be soulved if i do not know how to code but inderstand what must be changed? Binance uses Intervaltellers: image

Just like the change #504 the secondes must be changed to interval letters. Just like in the code of HitBTC the code must look like: public override string PeriodSecondsToString(int seconds) { switch (seconds) { case 60: return "M1"; case 180: return "M3"; case 300: return "M5"; case 900: return "M15"; case 1800: return "M30"; case 3600: return "H1"; case 14400: return "H4"; case 86400: return "D1"; case 604800: return "D7"; case 4233600: return "1M"; default: throw new ArgumentException($"{nameof(seconds)} must be 60, 180, 300, 900, 1800, 3600, 14400, 86400, 604800, 4233600"); } }

Exact the same way like in the HitBTC code (ExchangeHitbtcAPI.cs) the code must be inster into the binance code. How to do that? Maybe it is a cut/past for you?

vslee commented 4 years ago

@CryptoP2345 The pasted code only works for HitBTC. In Binance, the allowed parameters are (scroll down to the ENUM definitions):

Kline/Candlestick chart intervals:

m -> minutes; h -> hours; d -> days; w -> weeks; M -> months

If you can update the code you pasted above with these new values, then I will handle the rest.