public static int GetBuyIntValue(this BuySellStrategyType strategy) { if (strategy == BuySellStrategyType.N20 || strategy == BuySellStrategyType.MA20) { return(20); } if (strategy == BuySellStrategyType.N40 || strategy == BuySellStrategyType.MA40) { return(40); } if (strategy == BuySellStrategyType.N60 || strategy == BuySellStrategyType.MA60) { return(60); } if (strategy == BuySellStrategyType.MA120) { return(120); } if (strategy == BuySellStrategyType.MA240) { return(240); } return(0); }
public StopLossEmailTemplate(string receipent, string stockID, string stockName, BuySellStrategyType strategy, decimal stopPriceInStrategy, decimal currentLowPrice) { ReceipentEmail = receipent; _stockID = stockID; _stockName = stockName; _stopPriceInStrategy = stopPriceInStrategy; _currentLowPrice = currentLowPrice; _strategy = strategy; }
public BreakDownEmailTemplate(string receipent, string stockID, string stockName, BuySellStrategyType strategy, decimal stopPriceInStrategy, decimal currentLowPrice) { ReceipentEmail = receipent; _stockID = stockID; _stockName = stockName; _stopPriceInStrategy = stopPriceInStrategy; _todayLowestPrice = currentLowPrice; _strategy = strategy; }
public BreakThroughEmailTemplate(string receipent, string stockID, string stockName, BuySellStrategyType strategy, decimal todayHighPrice, decimal highPriceInStrategy) { ReceipentEmail = receipent; _stockID = stockID; _stockName = stockName; _todayHighPrice = todayHighPrice; _highPriceInStrategy = highPriceInStrategy; _strategy = strategy; }
public MemberBuyStock(string memberEmail, CountryKind country, string stockID, decimal buyPrice, decimal N, decimal stopPrice, StockBuyState state, BuySellStrategyType strategy, DateTime buyDate) { MemberEmail = memberEmail; Country = country; StockId = stockID; BuyPrice = buyPrice; StopPrice = stopPrice; State = state; BuyDate = buyDate; NValue = N; Strategy = strategy; }
public static BuySellStrategyKind GetKind(this BuySellStrategyType strategy) { if (strategy == BuySellStrategyType.N20 || strategy == BuySellStrategyType.N40 || strategy == BuySellStrategyType.N60) { return(BuySellStrategyKind.Turtle); } else if (strategy == BuySellStrategyType.MA20 || strategy == BuySellStrategyType.MA40 || strategy == BuySellStrategyType.MA60 || strategy == BuySellStrategyType.MA120 || strategy == BuySellStrategyType.MA240) { return(BuySellStrategyKind.MovingAverage); } return(BuySellStrategyKind.Unknown); }
public static int GetSellIntValue(this BuySellStrategyType strategy) { if (strategy == BuySellStrategyType.N20) { return(10); } if (strategy == BuySellStrategyType.N40) { return(15); } if (strategy == BuySellStrategyType.N60) { return(20); } return(0); }
public IEmailTemplate GetBreakThroughEmailTemplate(string receipent, string stockId, string stockName, BuySellStrategyType strategy, decimal todayHighPrice, decimal high20Price) { return(new BreakThroughEmailTemplate(receipent, stockId, stockName, strategy, todayHighPrice, high20Price)); }
public IEmailTemplate GetBreakDownEmailTemplate(string receipent, string stockId, string stockName, BuySellStrategyType strategy, decimal lowPriceInStrategy, decimal currentLowPrice) { return(new BreakDownEmailTemplate(receipent, stockId, stockName, strategy, lowPriceInStrategy, currentLowPrice)); }
private string ComposeKey(string memberEmail, string stockFullID, DateTime date, StockNotificationType type, BuySellStrategyType strategy, StockBuyState targetState) { return($"{strategy.GetString()}.{memberEmail}.{stockFullID}.{date.ToString(_dateFormat)}.{type.ToString()}.{targetState.GetStockBuyStateValue()}"); }
public void InsertRecord(string memberEmail, string stockFullID, StockNotificationType type, DateTime date, BuySellStrategyType strategy, StockBuyState targetState) { _checkers.Add(ComposeKey(memberEmail, stockFullID, date, type, strategy, targetState)); }
public bool CanNotify(string memberEmail, string stockFullID, StockNotificationType type, DateTime today, BuySellStrategyType strategy, StockBuyState targetState) { return(!_checkers.Contains(ComposeKey(memberEmail, stockFullID, today, type, strategy, targetState))); }
public IEmailTemplate GetBreakThroughEmailTemplate(string receipent, string stockId, string stockName, BuySellStrategyType strategy, decimal highPriceInStrategy, decimal currentHighPrice) { return(new BackTestNotificationContent(stockId, "Buy", "FirstBuy", currentHighPrice, _currentDate, "")); }
public static string GetString(this BuySellStrategyType strategy) { return(Enum.GetName(typeof(BuySellStrategyType), strategy)); }
public Task SetMemberStockAsync(string memberEmail, CountryKind country, string stockId, BuySellStrategyType strategy, bool isNotify) { IMemberStock stock = MemberStockTable.Find(a => string.Equals(a.MemberEmail, memberEmail, StringComparison.OrdinalIgnoreCase) && a.Country == country && string.Equals(a.StockId, stockId, StringComparison.OrdinalIgnoreCase)); if (!(stock is MemberStock target)) { return(Task.CompletedTask); } target.Strategy = strategy; target.IsNotify = isNotify; return(Task.CompletedTask); }
public Task AddMemberStockAsync(string memberEmail, CountryKind country, string stockID, BuySellStrategyType strategy, bool isNotify) { MemberStock stock = new MemberStock(memberEmail, country, stockID, isNotify, strategy); MemberStockTable.Add(stock); return(Task.CompletedTask); }
public Task AddMemberBuyStockAsync(string memberEmail, CountryKind country, string stockID, decimal buyPrice, decimal N, BuySellStrategyType strategy, DateTime buyDate) { IMemberBuyStock memberBuyStock = new MemberBuyStock(memberEmail, country, stockID, buyPrice, N, buyPrice - (2 * N), StockBuyState.Buy, strategy, buyDate); MemberBuyStockTable.Add(memberBuyStock); return(Task.CompletedTask); }
public IEmailTemplate GetStopLossEmailTemplate(string receipent, string stockId, string stockName, BuySellStrategyType strategy, decimal stopPriceInStrategy, decimal currentLowPrice) { return(new StopLossEmailTemplate(receipent, stockId, stockName, strategy, stopPriceInStrategy, currentLowPrice)); }
private (decimal?NInSystem, decimal?highestPriceInSystem, decimal?lowestPriceInSystem) DailyPriceCalculationSystem(BuySellStrategyType type, IReadOnlyList <IStockPriceHistory> recentStockPriceHistory, decimal todayATR, IStockQuoteFromDataSource todayPriceDataFromDataSource) { decimal[] lowPrices = null; decimal[] highPrices = null; decimal?[] ATRs = null; decimal? lowestPrice = null; decimal? highestPrice = null; decimal? todayN = null; if (recentStockPriceHistory.Count >= type.GetSellIntValue()) { lowPrices = recentStockPriceHistory.Take(type.GetSellIntValue()).Select(a => a.LowPrice).ToArray(); ATRs = recentStockPriceHistory.Take(type.GetSellIntValue() - 1).Select(a => a.ATR).ToArray(); } if (recentStockPriceHistory.Count() >= type.GetBuyIntValue()) { highPrices = recentStockPriceHistory.Take(type.GetBuyIntValue()).Select(a => a.HighPrice).ToArray(); ATRs = recentStockPriceHistory.Take(type.GetBuyIntValue() - 1).Select(a => a.ATR).ToArray(); } if (lowPrices != null) { lowestPrice = _baseData.CalculateLowestPrice(lowPrices, todayPriceDataFromDataSource.LowPrice); } if (highPrices != null) { highestPrice = _baseData.CalculateHighestPrice(highPrices, todayPriceDataFromDataSource.HighPrice); } if (ATRs != null) { List <decimal> validATRList = new List <decimal>(); foreach (decimal?item in ATRs) { if (item.HasValue) { validATRList.Add(item.Value); } } if (validATRList.Count() == type.GetBuyIntValue() - 1) { todayN = _baseData.CalculateTodayN(validATRList.ToArray(), todayATR); } } return(todayN, highestPrice, lowestPrice); }
public IEmailTemplate GetStopLossEmailTemplate(string receipent, string stockId, string stockName, BuySellStrategyType strategy, decimal stopPriceInStrategy, decimal currentLowPrice) { return(new BackTestNotificationContent(stockId, "Sell", "StopLoss", currentLowPrice, _currentDate, $"Stop Price in SystemN :{stopPriceInStrategy}")); }