coin_alerts/Extensions.cs
2025-01-19 11:45:51 +05:30

22 lines
778 B
C#

using BinanceExchange.API.Models.Response;
public static class Extensions{
public static bool isGreen(this KlineCandleStickResponse candle){
return candle.Close > candle.Open;
}
public static float getShadowRatio(this KlineCandleStickResponse candle){
decimal shadowLen = candle.High-candle.Low;
decimal candleLen = Math.Abs(candle.Open-candle.Close);
return (float)(candleLen/(shadowLen==0 ? 1 :shadowLen)); //Prevent commiting suicide
}
public static float getCandleLength(this KlineCandleStickResponse candle){
return (float)Math.Abs(candle.Open-candle.Close);
}
public static float getTotalLength(this KlineCandleStickResponse candle){
return (float)Math.Abs(candle.High - candle.Low);
}
}