volume draw + picasso fixed

This commit is contained in:
Sewmina 2025-01-07 13:34:59 +05:30
parent 4a8f2d608b
commit 253d45ce13
22 changed files with 60 additions and 32 deletions

BIN
SignalsTestCmd/ACTUSDT.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 88 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 68 KiB

After

Width:  |  Height:  |  Size: 87 KiB

View File

@ -77,7 +77,8 @@ namespace SignalsTest
int[] mas = new int[] { 7, 12, 25 }; int[] mas = new int[] { 7, 12, 25 };
reports = new List<TAReport>(); reports = new List<TAReport>();
decimal max = 0; decimal max = 0;
decimal min = 10000000; decimal min = 100000000;
decimal maxVol = 0;
for(int i=0; i < candles.Count; i++){ for(int i=0; i < candles.Count; i++){
TAReport report = TAReport.Generate(pair, Utils.GetMinutesForInterval(interval) ,candles, i,reports); TAReport report = TAReport.Generate(pair, Utils.GetMinutesForInterval(interval) ,candles, i,reports);
@ -87,6 +88,10 @@ namespace SignalsTest
if(candles[i].Close < min){ if(candles[i].Close < min){
min = candles[i].Close; min = candles[i].Close;
} }
if(candles[i].Volume > maxVol){
maxVol = candles[i].Volume;
}
reports.Add(report); reports.Add(report);
} }
Console.WriteLine($"Drawing chart for {reports.Count} candles, Coin: {symbol}, ceil:{max}, floor:{min}"); Console.WriteLine($"Drawing chart for {reports.Count} candles, Coin: {symbol}, ceil:{max}, floor:{min}");
@ -105,7 +110,7 @@ namespace SignalsTest
} }
if(isStSwitch){ if(isStSwitch){
Picasso.DrawChart(reports, max ,min, symbol); Picasso.DrawChart(reports, max ,min, maxVol, symbol);
await Messenger.instance.SendLastChart(filename:symbol); await Messenger.instance.SendLastChart(filename:symbol);
await Messenger.instance.SendMessage($"`{symbol}` switched the SuperTrend lines. Current price: {reports[reports.Count-1].Close}"); await Messenger.instance.SendMessage($"`{symbol}` switched the SuperTrend lines. Current price: {reports[reports.Count-1].Close}");
} }

View File

@ -21,6 +21,14 @@ public static class CoinsList{
"CHILLGUYUSDT", "CHILLGUYUSDT",
"STGUSDT", "STGUSDT",
"ONEUSDT", "ONEUSDT",
"LINKUSDT" "LINKUSDT",
"ARUSDT",
"RUNEUSDT",
"USUALUSDT",
"ZKUSDT",
"JUPUSDT",
"LUNAUSDT",
"DUSKUSDT",
"SUIUSDT"
]; ];
} }

BIN
SignalsTestCmd/MOVEUSDT.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 105 KiB

View File

@ -17,13 +17,17 @@ namespace SignalsTest
private static Messenger m_instance; private static Messenger m_instance;
public static Messenger instance { get { if (m_instance == null) { m_instance = new Messenger(); } return m_instance; } } public static Messenger instance { get { if (m_instance == null) { m_instance = new Messenger(); } return m_instance; } }
public const string chatId = "@doralockscryptosignals";
//prod:doralockscryptosignals
//test:SignalTestPrivate
public async Task SendMessage(string text, string chat = "@doralockscryptosignals")
public async Task SendMessage(string text, string chat =chatId)
{ {
await botClient.SendTextMessageAsync(chat, text); await botClient.SendTextMessageAsync(chat, text);
} }
public async Task SendLastChart(string chat = "@doralockscryptosignals", string filename="test"){ public async Task SendLastChart(string chat = chatId, string filename="test"){
FileStream fsSource = new FileStream($"{filename}.png", FileMode.Open, FileAccess.Read); FileStream fsSource = new FileStream($"{filename}.png", FileMode.Open, FileAccess.Read);
InputFile photo = InputFile.FromStream(fsSource); InputFile photo = InputFile.FromStream(fsSource);
await botClient.SendPhotoAsync(chat, photo); await botClient.SendPhotoAsync(chat, photo);

View File

@ -9,33 +9,48 @@ using SixLabors.ImageSharp.Processing;
using Newtonsoft.Json; using Newtonsoft.Json;
public class Picasso{ public class Picasso{
public static void DrawChart(List<TAReport> reports, decimal max, decimal min, string filename="test"){ public static void DrawChart(List<TAReport> reports, decimal max, decimal min, decimal volMax, string filename="test"){
// float height = (float)Math.Ceiling(max - min) * 2f; // float height = (float)Math.Ceiling(max - min) * 2f;
// float width = ((float)height / 9f) * 16f; // float width = ((float)height / 9f) * 16f;
float multiplier = 1; decimal heightRange = max-min;
if(min < 1000){
multiplier = 10000;
}
float heightRange = (float)Math.Ceiling((float)(max - min) * multiplier);
float height=1080; float height=1080;
float width = 1920; float width = 1920;
float widthMultiplier = width / (float)reports.Count; float widthMultiplier = width / (float)reports.Count;
float heightMultiplier = (height/ (float)heightRange) * 0.6f;
float candlesOffset = 0.3f * height;
float volumeSize = 0.2f * height;
using (Image img = new Image<Rgba32>((int)width + 100, (int)height)){ using (Image img = new Image<Rgba32>((int)width + 100, (int)height)){
//Draw Candles //Draw Candles
for(int i=0; i < reports.Count; i++){ for(int i=0; i < reports.Count; i++){
// img.Mutate(ctx=> ctx.DrawLine())) // img.Mutate(ctx=> ctx.DrawLine()))
PointF[] points = new PointF[2]; PointF[] points = new PointF[2];
points[0] =new PointF(i * widthMultiplier, (float)(reports[i].candle.Open - min) * multiplier);
points[1] =new PointF(i * widthMultiplier, (float)(reports[i].candle.Close - min)* multiplier); float openVal1 = (float)(reports[i].candle.Open - min) * heightMultiplier;
float closeVal1 = (float)(reports[i].candle.Close - min)* heightMultiplier;
points[0] =new PointF(i * widthMultiplier, openVal1 + candlesOffset);
points[1] =new PointF(i * widthMultiplier, closeVal1+ candlesOffset);
PointF[] rangePoints = new PointF[2]; PointF[] rangePoints = new PointF[2];
rangePoints[0] = new PointF(i * widthMultiplier, (float)(reports[i].candle.High-min)* multiplier);
rangePoints[1] = new PointF(i * widthMultiplier, (float)(reports[i].candle.Low-min)* multiplier);
img.Mutate(ctx=> ctx.DrawLine(reports[i].candle.Close > reports[i].candle.Open ? Color.Green : Color.Red, 10, points).DrawLine( float openVal2 = (float)(reports[i].candle.High-min)* heightMultiplier;
reports[i].candle.Close > reports[i].candle.Open ? Color.Green : Color.Red, 3, rangePoints float closeVal2 = (float)(reports[i].candle.Low-min)* heightMultiplier;
));
rangePoints[0] = new PointF(i * widthMultiplier, openVal2+ candlesOffset);
rangePoints[1] = new PointF(i * widthMultiplier, closeVal2+ candlesOffset);
PointF[] volumePoints = new PointF[2];
volumePoints[0] = new PointF(i * widthMultiplier, 0);
volumePoints[1] = new PointF(i * widthMultiplier, ((float)reports[i].candle.Volume / (float)volMax) * volumeSize);
Color candleColor = reports[i].candle.Close > reports[i].candle.Open ? Color.Green : Color.Red;
img.Mutate(ctx=> ctx.
DrawLine(candleColor, 10, points).
DrawLine(candleColor, 3, rangePoints).
DrawLine(candleColor, 10, volumePoints)
);
} }
// Console.WriteLine("Getting paths"); // Console.WriteLine("Getting paths");
@ -44,9 +59,9 @@ public class Picasso{
// Console.WriteLine(float.Parse(t.ToString())); // Console.WriteLine(float.Parse(t.ToString()));
//Overlay //Overlay
IPath sma7Path = GetPath(reports, "SMA7", widthMultiplier,heightRange, (float)min); IPath sma7Path = GetPath(reports, "SMA7", widthMultiplier,(float)heightMultiplier, (float)min, candlesOffset);
IPath sma25Path = GetPath(reports, "SMA25", widthMultiplier,heightRange, (float)min); IPath sma25Path = GetPath(reports, "SMA25", widthMultiplier,(float)heightMultiplier, (float)min, candlesOffset);
IPath stPath = GetPath(reports, "ST", widthMultiplier,heightRange, (float)min); IPath stPath = GetPath(reports, "ST", widthMultiplier,(float)heightMultiplier, (float)min, candlesOffset);
//NewChart //NewChart
FontFamily fontFamily; FontFamily fontFamily;
@ -67,23 +82,19 @@ public class Picasso{
} }
} }
static IPath GetPath(List<TAReport> reports, string propName, float widthMultiplier,float heightRange, float min, float offset =0){ static IPath GetPath(List<TAReport> reports, string propName, float widthMultiplier,float heightMultiplier, float min, float offset =0){
PathBuilder builder = new PathBuilder(); PathBuilder builder = new PathBuilder();
builder.SetOrigin(new PointF(0,0)); builder.SetOrigin(new PointF(0,0));
float multiplier = 1;
if(min < 1000){
multiplier = 10000;
}
for(int i=0; i < reports.Count; i++){ for(int i=0; i < reports.Count; i++){
float newVal = float.Parse(GetPropByName(reports[i],propName).ToString() ?? "0"); float newVal = float.Parse(GetPropByName(reports[i],propName).ToString() ?? "0");
// Console.WriteLine( newVal); // Console.WriteLine( newVal);
float prevVal = i > 0 ? float.Parse(GetPropByName(reports[i-1],propName).ToString() ?? "0") : 0; float prevVal = i > 0 ? float.Parse(GetPropByName(reports[i-1],propName).ToString() ?? "0") : 0;
// Console.WriteLine( prevVal); // Console.WriteLine( prevVal);
float preValY = (prevVal * multiplier) - (min * multiplier); float preValY =( prevVal - min) * heightMultiplier ;
float newValY=(newVal* multiplier) - (min* multiplier); float newValY=(newVal - min) * heightMultiplier;
PointF prevPoint = new PointF((i-1)* widthMultiplier, preValY); PointF prevPoint = new PointF((i-1)* widthMultiplier, (preValY) +offset);
PointF newPoint = new PointF(i * widthMultiplier, newValY); PointF newPoint = new PointF(i * widthMultiplier, (newValY) + offset);
// Console.WriteLine(newValY); // Console.WriteLine(newValY);
builder.AddLine(prevPoint, newPoint); builder.AddLine(prevPoint, newPoint);
} }

BIN
SignalsTestCmd/SOLUSDT.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 84 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 71 KiB

After

Width:  |  Height:  |  Size: 90 KiB

BIN
SignalsTestCmd/STGUSDT.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 111 KiB

BIN
SignalsTestCmd/XLMUSDT.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 97 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 19 KiB

After

Width:  |  Height:  |  Size: 89 KiB

View File

@ -13,7 +13,7 @@ using System.Reflection;
[assembly: System.Reflection.AssemblyCompanyAttribute("SignalsTestCmd")] [assembly: System.Reflection.AssemblyCompanyAttribute("SignalsTestCmd")]
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")] [assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+c7feba5a4ade9eca44a22aa5fdbcdfbb6ffbb0b0")] [assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0+4a8f2d608b1f1ca133831ccdead689f8d57ae5f4")]
[assembly: System.Reflection.AssemblyProductAttribute("SignalsTestCmd")] [assembly: System.Reflection.AssemblyProductAttribute("SignalsTestCmd")]
[assembly: System.Reflection.AssemblyTitleAttribute("SignalsTestCmd")] [assembly: System.Reflection.AssemblyTitleAttribute("SignalsTestCmd")]
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")] [assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]

View File

@ -1 +1 @@
5d95c334624791bdad7518056635a728e45ea1d8d347d96b17e862042cf7e5fc ca0f5c6656c28599aa5c69610c0b127117543bcbf3a50182e0f73d06e5e5f4ec