public void ExecuteOptionRules() { List <TMRule> rules = new List <TMRule>(); rules = DalManager.GetRules("Option"); if (rules != null && rules.Count > 0) { IOptionsEnt DDSoption = null; IStocksEnt DDStock = null; List <TMStockInfo> optionSymbols = DalManager.GetStockSymbols();//get all symbols DalManager.InsertLog("EXEC", "ExecuteOptionRules started at:" + DateTime.Now.ToString()); foreach (TMStockInfo symbol in optionSymbols) { try { // DDSoption = dds.GetOptionsByStock(symbol.Symbol); // DDStock = dds.GetStockBySymbol(symbol.Symbol); TMStockEnt TMstock = new TMStockEnt(symbol.Symbol, symbol.StockID, DDStock); TMstock.PriceBar = YahooAPI.GetHistoricalData(symbol.Symbol, DateTime.Now.AddDays(-360)); //need to change with an interface or factory pattern TMstock.GenerateIndicators(); //creates all sma , bollinger, candles etc while (DDSoption.Next()) { TMOptionEnt TMoption = new TMOptionEnt(symbol.Symbol, symbol.StockID, DDSoption); TMoption.StockEnt = TMstock; foreach (TMRule rule in rules) { TMoption.RuleName = rule.RuleName; TMoption.RuleID = rule.RuleID; //Evaluator<TMOptionEnt> e = new Evaluator<TMOptionEnt>(rule.RuleXml); //bool success = e.Evaluate(TMoption); DalManager.InsertLog("EXEC:OPTION", "Option rule:" + rule.RuleName + " executed for stock:" + symbol.Symbol + "; strike price: " + DDSoption.StrikePrice.ToString() + " & expiration date:" + DDSoption.ExpirationDate.ToString() + "; on " + DateTime.Now.ToString()); } } } catch (Exception ex) { //handle exception here. log to db int x; } } DalManager.InsertLog("EXEC", "ExecuteOptionRules ended at:" + DateTime.Now.ToString()); } }
public void ExecuteStockRules() { List <TMRule> rules = new List <TMRule>(); rules = DalManager.GetRules("Stock"); if (rules != null && rules.Count > 0) { IStocksEnt ddsStock = null; List <TMStockInfo> stockSymbols = DalManager.GetStockSymbols(); DalManager.InsertLog("EXEC", "ExecuteStockRules started at:" + DateTime.Now.ToString()); foreach (TMStockInfo symbol in stockSymbols) { try { ddsStock = dds.GetStockBySymbol(symbol.Symbol); TMStockEnt tmStock = new TMStockEnt(symbol.Symbol, symbol.StockID, ddsStock); tmStock.PriceBar = YahooAPI.GetHistoricalData(symbol.Symbol, DateTime.Now.AddDays(-360)); //need to change with an interface or factory pattern tmStock.GenerateIndicators(); //creates all sma , bollinger, candles etc foreach (TMRule rule in rules) { tmStock.RuleName = rule.RuleName; tmStock.RuleID = rule.RuleID; //Evaluator<TMStockEnt> e = new Evaluator<TMStockEnt>(rule.RuleXml); //bool success = e.Evaluate(tmStock); DalManager.InsertLog("EXEC:STOCK", "Stock rule:" + rule.RuleName + " executed for stock:" + symbol.Symbol + " on " + DateTime.Now.ToString()); } } catch (Exception ex) { //handle exception here int x; } } DalManager.InsertLog("EXEC", "ExecuteStockRules ended at:" + DateTime.Now.ToString()); } }
static void Main(string[] args) { DalManager dalmanager = new DalManager(); List <TMStockInfo> optionSymbols = DalManager.GetStockSymbols();//get all symbols foreach (TMStockInfo symbol in optionSymbols) { TMStockEnt TMstock = new TMStockEnt(symbol.Symbol, symbol.StockID); TMstock.PriceBar = YahooAPI.GetHistoricalData(symbol.Symbol, DateTime.Now.AddDays(-250));//need to change with an interface or factory pattern Console.WriteLine(TMstock.Symbol); foreach (double close in TMstock.PriceBar.Close) { Console.WriteLine(close.ToString()); } Console.ReadKey(); TMstock.GenerateIndicators();//creates all sma , bollinger, candles etc } }