public bool QueueMaintence(IAccountHandlerInterface AccountHandler) { //remove sell orders where the holding dont exists on the account try { List <OrderType> SellStoploss = new List <OrderType>(); SellStoploss.Add(OrderType.Sell); SellStoploss.Add(OrderType.StopLoss); var OrderQuery = from t in m_oOrders join ssl in SellStoploss on t.OrderType equals ssl select t; var ObseleteOrders = from o in OrderQuery from a in AccountHandler.Accounts() .Where(a => a.Identifier.Equals(o.AccountIdentifier) && a.GetSymbolInHoldings().Contains(o.Symbol) ).DefaultIfEmpty() where a == null select o; /* * var ObseleteOrders = from a in AccountHandler.Accounts() * from o in OrderQuery * .Where(x => a.Identifier.Equals(x.AccountIdentifier) * && * a.GetSymbolInHoldings().Contains(x.Symbol) * ).DefaultIfEmpty() * select o; */ /* * var ObseleteOrders = from o in OrderQuery * from a in AccountHandler.Accounts() * .Where(a => a.Identifier.Equals(o.AccountIdentifier) * && * a.GetSymbolInHoldings().Contains(o.Symbol) * ).DefaultIfEmpty() * select o;*/ int gfgf = ObseleteOrders.Count(); List <IOrder> sds = ObseleteOrders.ToList(); //string[] sdfsd = ObseleteOrders.Select(x => x.Identifier.ToString()).ToArray(); if (ObseleteOrders == null || ObseleteOrders.Count() == 0) { return(true); } RemoveFilesFromStorage(ObseleteOrders.Where(o => o != null).ToList()); m_oOrders.RemoveRange(ObseleteOrders.Where(o => o != null).ToList()); } catch (Exception ex) { ImperaturGlobal.GetLog().Error("Error in OrderQueue.QueueMaintence", ex); } return(true); }
public IAccountHandlerInterface GetAccountHandler() { if (m_oAccountHandler == null) { m_oAccountHandler = ImperaturGlobal.Kernel.Get <IAccountHandlerInterface>(); } return(m_oAccountHandler); }
public AccountTab(IAccountHandlerInterface AccountHandler, ITradeHandlerInterface TradeHandler, IOrderQueue OrderQueueHandler) { InitializeComponent(); m_AccountHandler = AccountHandler; m_oTradeHandler = TradeHandler; m_oOrderQueueHandler = OrderQueueHandler; //this.KeyDown += AccountTab_KeyDown; typeof(TableLayoutPanel).GetProperty("DoubleBuffered", System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance).SetValue(tlp_Account, true, null); }
public OrderQueue(IAccountHandlerInterface AccountHandler, ITradeHandlerInterface TradeHandler) { TryLoadFromStorage = false; m_oLastErrorMessage = ""; m_oOrders = new ObservableRangeCollection <IOrder>(); m_oNewOrders = new List <Guid>(); m_oAccountHandler = AccountHandler; m_oTradeHandler = TradeHandler; InitOrders(); }
public TradeAutomation(IAccountHandlerInterface AccountHandler) { m_oTradingOverview = new List <InstrumentRecommendation>(); //TODO, add this to an external resource SearchPlaces = new string[] { "http://investors.avanza.se/sv/feed/reports" }; m_oRSS = new RSSReader(); m_oAccountHandler = AccountHandler; }
public SellDialog(IAccountHandlerInterface AccountHandler, IAccountInterface Account, string Ticker, int Quantity)//, ITradeHandlerInterface Tradehandler) { InitializeComponent(); oAH = AccountHandler; oA = Account; textBox_quantity.TextChanged += TextBox_quantity_TextChanged; oQ = Quantity; oT = Ticker; groupBox1.Text += ": " + Ticker; //m_oTradeHandler = Tradehandler; }
public Account_Search(IAccountHandlerInterface AccountHandler) { InitializeComponent(); this.Dock = DockStyle.Fill; this.listView_searchresult.SelectedIndexChanged += ListView_searchresult_SelectedIndexChanged; m_oAh = AccountHandler; listView_searchresult.View = View.Details; listView_searchresult.Columns.Add("Name"); listView_searchresult.Columns.Add("Available"); listView_searchresult.Columns.Add("Current"); listView_searchresult.Columns.Add("Change"); listView_searchresult.Columns.Add("Change%"); this.textBox_Search.KeyDown += TextBox_Search_KeyDown; }
public bool ExecuteOrder(IAccountHandlerInterface AccountHandler, ITradeHandlerInterface TradeHandler, out IOrder StopLossOrder) { StopLossOrder = this; if (EvaluateTriggerOnOrder()) { try { IAccountInterface oA = AccountHandler.GetAccount(m_oAccountIdentifier); switch (m_oOrderType) { case OrderType.Buy: oA.AddHoldingToAccount(m_oQuantity, m_oSymbol, TradeHandler); StopLossOrder = this; return(true); case OrderType.Sell: oA.SellHoldingFromAccount(m_oQuantity, m_oSymbol, TradeHandler); return(true); case OrderType.StopLoss: oA.AddHoldingToAccount(m_oQuantity, m_oSymbol, TradeHandler); StopLossOrder = CreateStopLossOrder(ImperaturGlobal.Quotes.Where(q => q.Symbol.Equals(m_oSymbol)).First().LastTradePrice.Amount); return(true); default: break; } } catch (Exception ex) { m_oLastErrorMessage = "OrderExecute error: " + ex.Message; return(false); } } return(false); }
public Account_Trade(IAccountHandlerInterface AccountHandler, ITradeHandlerInterface TradeHandler, IOrderQueue OrderHandler) { InitializeComponent(); this.Dock = DockStyle.Fill; m_oAh = AccountHandler; m_oTradeHandler = TradeHandler; m_oOrderQueueHandler = OrderHandler; //comboBox_Symbols AutoCompleteStringCollection list = new AutoCompleteStringCollection(); list.AddRange(ImperaturGlobal.Instruments.Select(i => i.Symbol).ToArray()); comboBox_Symbols.AutoCompleteMode = AutoCompleteMode.Suggest; comboBox_Symbols.AutoCompleteSource = AutoCompleteSource.CustomSource; comboBox_Symbols.AutoCompleteCustomSource = list; comboBox_Symbols.DataSource = ImperaturGlobal.Instruments.Select(i => i.Symbol).ToList(); comboBox_Symbols.Text = ""; comboBox_Symbols.SelectedIndexChanged += ComboBox_Symbols_SelectedIndexChanged; this.textBox_Quantity.KeyDown += TextBox_Quantity_KeyDown; tableLayoutPanel_Graph.Visible = false; m_oGraphSettingDays = 7; m_oDateRanges = new List <Tuple <int, string, bool> >(); m_oIndicator = new List <Tuple <TA_Indicator, string, bool> >(); m_oGraphSettings = new List <Tuple <TA_Settings, string, bool> >(); //DateRanges m_oDateRanges.Add(new Tuple <int, string, bool>(1, "1 day", false)); m_oDateRanges.Add(new Tuple <int, string, bool>(3, "3 days", false)); m_oDateRanges.Add(new Tuple <int, string, bool>(7, "7 days", false)); m_oDateRanges.Add(new Tuple <int, string, bool>(90, "3 months", false)); m_oDateRanges.Add(new Tuple <int, string, bool>(365, "1 year", false)); //Indicators foreach (TA_Indicator indicator in Enum.GetValues(typeof(TA_Indicator))) { m_oIndicator.Add(new Tuple <TA_Indicator, string, bool>(indicator, indicator.ToString(), false)); } foreach (TA_Settings setting in Enum.GetValues(typeof(TA_Settings))) { m_oGraphSettings.Add(new Tuple <TA_Settings, string, bool>(setting, setting.ToString(), false)); } foreach (var dr in m_oDateRanges) { comboBox_daterange.Items.Add(dr.Item2); } comboBox_daterange.SelectedIndexChanged += ComboBox_daterange_SelectedIndexChanged; foreach (var dr in m_oIndicator) { checkBoxComboBox_TA.Items.Add(dr.Item2); } checkBoxComboBox_TA.CheckBoxCheckedChanged += CheckBoxComboBox_TA_CheckBoxCheckedChanged; //checkBoxComboBox_TA.DropDownClosed += CheckBoxComboBox_TA_DropDownClosed; foreach (var dr in m_oGraphSettings) { checkBoxComboBox_Settings.Items.Add(dr.Item2); } checkBoxComboBox_Settings.CheckBoxCheckedChanged += CheckBoxComboBox_Settings_CheckBoxCheckedChanged; SetDateRangeToNumber(7); }
public Account_Holdings(IAccountHandlerInterface AccountHandler, ITradeHandlerInterface TradeHandler) { InitializeComponent(); this.Dock = DockStyle.Fill; m_oAh = AccountHandler; m_oTradeHandler = TradeHandler; listView_holdings.View = View.Details; listView_holdings.Columns.Add("Name"); listView_holdings.Columns.Add("Quantity"); listView_holdings.Columns.Add("PurchaseAmount"); listView_holdings.Columns.Add("Change"); listView_holdings.Columns.Add("CurrentValue"); listView_holdings.Columns.Add("AAC"); //average acquisition cost listView_holdings.Columns.Add("Action"); listView_holdings.Columns.Add("Info"); ListViewExtender extender = new ListViewExtender(listView_holdings); ListViewButtonColumn buttonAction = new ListViewButtonColumn(listView_holdings.Columns.Count - 2); buttonAction.Click += ButtonAction_Click; buttonAction.FixedWidth = true; extender.AddColumn(buttonAction); ListViewButtonColumn buttonActionInfo = new ListViewButtonColumn(listView_holdings.Columns.Count - 1); buttonActionInfo.Click += ButtonActionInfo_Click; buttonActionInfo.FixedWidth = true; extender.AddColumn(buttonActionInfo); listView_holdings.Click += ListView_holdings_Click; TotalAvilableFundsGrid = new DataGridView(); TotalAvilableFundsGrid.AutoGenerateColumns = false; TotalAvilableFundsGrid.AllowUserToAddRows = false; TotalAvilableFundsGrid.RowHeadersVisible = false; TotalAvilableFundsGrid.Columns.Add( new DataGridViewTextBoxColumn() { CellTemplate = new DataGridViewTextBoxCell(), Name = "Deposit", HeaderText = "Deposit", DataPropertyName = "Deposit", ReadOnly = true } ); TotalAvilableFundsGrid.Columns.Add( new DataGridViewTextBoxColumn() { CellTemplate = new DataGridViewTextBoxCell(), Name = "Amount", HeaderText = "Amount", DataPropertyName = "Amount", ReadOnly = true } ); TotalAvilableFundsGrid.Columns.Add( new DataGridViewTextBoxColumn() { CellTemplate = new DataGridViewTextBoxCell(), Name = "Change", HeaderText = "Change", DataPropertyName = "Change", ReadOnly = true } ); }