public CoinPerformance DefinePerformance(OutStats table) { var tableRows = table.Table; var result = new CoinPerformance(); if (!decimal.TryParse(_settings.LowerBorder, out var lowerBorder)) { throw new Exception("Wrong Value of Border in App Settings!"); } if (!decimal.TryParse(_settings.UpperBorder, out var upperBorder)) { throw new Exception("Wrong Value of BorderUp in App Settings!"); } if (!decimal.TryParse(_settings.UpperWidth, out var widthRateUpper)) { throw new Exception("Wrong Value of BorderUp in App Settings!"); } if (!decimal.TryParse(_settings.LowerWidth, out var widthRateLower)) { throw new Exception("Wrong Value of BorderUp in App Settings!"); } result.Width = Width(table.YhatLowerList, table.YhatUpperList, widthRateUpper, widthRateLower); var enumerable = tableRows.ToList(); var upper = enumerable.First().Yhat; var lower = enumerable.Last().Yhat; var max = table.MaxValue; var min = table.MinValue; if (max < upper) { max = upper; } if (min > lower) { min = lower; } decimal length; if (upper - lower > 0) { length = 1 / (max - min) * (upper - lower) * 100; } else if (upper - lower < 0) { length = -1 * (1 / (max - min) * (lower - upper) * 100); } else { result.Indicator = Indicator.Neutral; result.Rate = 0; return(result); } if (length > upperBorder) { result.Indicator = Indicator.StrongPositive; result.Rate = length / 100; return(result); } if (length > 0 && length <= upperBorder) { result.Indicator = Indicator.Positive; result.Rate = length / 100; return(result); } if (length < 0 && lowerBorder < length) { result.Indicator = Indicator.Neutral; result.Rate = -1 * length / 100; return(result); } result.Indicator = Indicator.Negative; result.Rate = -1 * length / 100; return(result); }
public BotArrange SpecifyDirByIndicators(string path, int rsi, List <int> trend, List <int> border, CoinPerformance performance, decimal coinRsi) { try { if (string.IsNullOrEmpty(path)) { return(BotArrange.DontBuy); } var folderTo = DefineArrange(rsi, trend, border, performance, coinRsi); var getUpperFolder = path.Remove(0, path.LastIndexOf(Path.DirectorySeparatorChar) + 1); var getRootPath = path.Remove(path.LastIndexOf(Path.DirectorySeparatorChar), path.Length - path.LastIndexOf(Path.DirectorySeparatorChar)); string moveTo; switch (folderTo) { case BotArrange.Buy: moveTo = CreateSubDir(getRootPath, _dirBotArrangeBuy); break; case BotArrange.Consider: moveTo = CreateSubDir(getRootPath, _dirBotArrangeConsider); break; case BotArrange.DontBuy: moveTo = CreateSubDir(getRootPath, _dirBotArrangeDontBuy); break; default: throw new ArgumentOutOfRangeException(nameof(folderTo), folderTo, null); } if (!string.IsNullOrEmpty(moveTo)) { MoveFolderToDir(path, moveTo, getUpperFolder); return(folderTo); } } catch (Exception e) { throw new Exception(e.Message); } return(BotArrange.DontBuy); }
private static BotArrange DefineArrange(int rsi, IEnumerable <int> trend, IEnumerable <int> border, CoinPerformance performance, decimal coinRsi) { var subDir = BotArrange.Buy; if (coinRsi < rsi) { if (performance.Indicator == Indicator.StrongPositive || performance.Indicator == Indicator.Positive) { return(BotArrange.Consider); } return(BotArrange.DontBuy); } var isInTrend = IsInTrendRange(trend, performance.Indicator); if (!isInTrend) { if (performance.Indicator == Indicator.StrongPositive || performance.Indicator == Indicator.Positive) { return(BotArrange.Consider); } return(BotArrange.DontBuy); } var isInWidth = IsInWidthRange(border, performance.Width); if (!isInWidth) { if (performance.Width == Width.Medium || performance.Width == Width.Narrow) { return(BotArrange.Consider); } return(BotArrange.DontBuy); } return(subDir); }
public CoinPerformance Indicatior(IEnumerable <TableRow> table) { var tableRows = table.ToList(); var result = new CoinPerformance(); if (!decimal.TryParse(appSettings.Value.Border, out var border)) { throw new Exception("Wrong Value of Border in App Settings!"); } if (!decimal.TryParse(appSettings.Value.BorderUp, out var borderUp)) { throw new Exception("Wrong Value of BorderUp in App Settings!"); } var upper = tableRows.First().Yhat; var lower = tableRows.Last().Yhat; var max = tableRows.First().MaxVal; var min = tableRows.First().MinVal; if (max < upper) { max = upper; } if (min > lower) { min = lower; } decimal length; if (upper - lower > 0) { length = 1 / (max - min) * (upper - lower) * 100; } else if (upper - lower < 0) { length = -1 * (1 / (max - min) * (lower - upper) * 100); } else { result.Indicator = Indicator.Neutral; result.Rate = 0; return(result); } if (length > borderUp) { result.Indicator = Indicator.StrongPositive; result.Rate = length / 100; return(result); } if (length > 0 && length <= borderUp) { result.Indicator = Indicator.Positive; result.Rate = length / 100; return(result); } if (length < 0 && border < length) { result.Indicator = Indicator.Neutral; result.Rate = -1 * length / 100; return(result); } result.Indicator = Indicator.Negative; result.Rate = -1 * length / 100; return(result); }