private List <InstrumentRecommendation> GetRecommendationFromInstrument(Instrument InstrumentToProcess) { List <InstrumentRecommendation> InstrumentRecommendations = new List <InstrumentRecommendation>(); OnSystemNotification(new IMPSystemNotificationEventArg { Message = string.Format("{0} - combining trading info about {1}", PROCESSNAME, InstrumentToProcess.Name) }); m_oSA = ImperaturGlobal.Kernel.Get <ISecurityAnalysis>(new Ninject.Parameters.ConstructorArgument("Instrument", InstrumentToProcess)); if (m_oSA.HasValue) //&& m_oSA.Instrument != null && m_oSA.QuoteFromInstrument != null) { InstrumentRecommendations.Add( new InstrumentRecommendation { InstrumentInfo = InstrumentToProcess, ExternalSearchHits = m_oRSS.GetOccurancesOfString(SearchPlaces, new string[] { InstrumentToProcess.Name, InstrumentToProcess.Symbol }), VolumeIndication = m_oSA.GetRangeOfVolumeIndicator(DateTime.Now.AddDays(-50), DateTime.Now).Last().Item2, TradingRecommendations = m_oSA.GetTradingRecommendations() }); } return(InstrumentRecommendations); }
public ISecurityAnalysis GetSecurityAnalysis(Instrument Instrument) { if (m_oSecurityAnalysis != null && m_oSecurityAnalysis.Instrument.Equals(Instrument)) { return(m_oSecurityAnalysis); } else { m_oSecurityAnalysis = ImperaturGlobal.Kernel.Get <ISecurityAnalysis>( new Ninject.Parameters.ConstructorArgument("Instrument", Instrument) ); } return(m_oSecurityAnalysis); }
private List <IOrder> GetSellOrdersByProfit(List <InstrumentRecommendation> TradingRecommendations) { List <IOrder> NewOrders = new List <IOrder>(); //now, do an evalution of every holding and sell if profit above 1.5% and no recommendation exists foreach (IAccountInterface oA in m_oAccountHandler.Accounts().Where(a => a.GetAccountType().Equals(AccountType.Customer))) { CreateSystemNoficationEvent(string.Format("Calculation sell orders by profit from {0}", oA.AccountName)); if (oA.GetHoldings().Count() == 0) { continue; } var holdings = from h in oA.GetHoldings() from tr in TradingRecommendations.Where(x => x.TradingRecommendations.Where(tr => tr.TradingForecastMethod != TradingForecastMethod.Undefined && tr.BuyPrice.Amount > 0).Count() > 0).ToList().Where(t => t.InstrumentInfo.Symbol.Equals(h.Symbol)).DefaultIfEmpty() where h.ChangePercent > 1.5m select h; foreach (var holding in holdings.Where(h => h.Symbol != null)) { CreateSystemNoficationEvent(string.Format("creating sell orders by profit from {0} for {1}", oA.AccountName, holding.Symbol)); m_oSA = ImperaturGlobal.Kernel.Get <ISecurityAnalysis>(new Ninject.Parameters.ConstructorArgument("Instrument", ImperaturGlobal.Instruments.Where(i => i.Symbol.Equals(holding.Symbol)).First())); ITrigger NewTrigger = ImperaturGlobal.Kernel.Get <ITrigger>( new Ninject.Parameters.ConstructorArgument("m_oOperator", TriggerOperator.EqualOrGreater), new Ninject.Parameters.ConstructorArgument("m_oValueType", TriggerValueType.TradePrice), new Ninject.Parameters.ConstructorArgument("m_oTradePriceValue", m_oSA.QuoteFromInstrument.LastTradePrice.Amount), new Ninject.Parameters.ConstructorArgument("m_oPercentageValue", 0m) ); NewOrders.Add(ImperaturGlobal.Kernel.Get <IOrder>( new Ninject.Parameters.ConstructorArgument("Symbol", m_oSA.Instrument.Symbol), new Ninject.Parameters.ConstructorArgument("Trigger", new List <ITrigger> { NewTrigger }), new Ninject.Parameters.ConstructorArgument("AccountIdentifier", oA.Identifier), new Ninject.Parameters.ConstructorArgument("Quantity", Convert.ToInt32(holding.Quantity)), new Ninject.Parameters.ConstructorArgument("OrderType", OrderType.Sell), new Ninject.Parameters.ConstructorArgument("ValidToDate", DateTime.Now.AddDays(2)), new Ninject.Parameters.ConstructorArgument("ProcessCode", "SellProfit"), new Ninject.Parameters.ConstructorArgument("StopLossValidDays", 0), new Ninject.Parameters.ConstructorArgument("StopLossAmount", 0m), new Ninject.Parameters.ConstructorArgument("StopLossPercentage", 0m) )); } } return(NewOrders); }
private void ComboBox_Symbols_SelectedIndexChanged(object sender, EventArgs e) { if (this.comboBox_Symbols.SelectedItem != null) { if (ImperaturGlobal.Quotes.Where(q => q.Symbol.Equals(comboBox_Symbols.SelectedItem.ToString())).Count() > 0) { Quote oQ = ImperaturGlobal.Quotes.Where(q => q.Symbol.Equals(comboBox_Symbols.SelectedItem.ToString())).First(); m_oI = ImperaturGlobal.Instruments.Where(i => i.Symbol.Equals(comboBox_Symbols.SelectedItem.ToString())).First(); label_instrument_info.Text = string.Format("{0}({1}) Last: {2}", m_oI.Name, m_oI.Symbol, oQ.LastTradePrice); m_oSecAnalysis = m_oTradeHandler.GetSecurityAnalysis(m_oI); label3.Text = string.Format("Today: {0} / {1}", oQ.ChangePercent, oQ.Change); ChangeGraph(); } else { label_instrument_info.Text = "N/A"; } } }