public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); info.AddValue("assembliesPaths", GeneralHelper.EnumerableToArray <string>(_expertContainingAssembliesAndPaths.Values)); info.AddValue("expertContainers", _expertInfos); }
public bool RemoveAssembly(Assembly assembly) { lock (this) { if (_expertContainingAssembliesAndPaths.ContainsKey(assembly) == false) { SystemMonitor.Error("Failed to remove assembly [" + assembly.FullName + "]"); return(false); } SystemMonitor.CheckError(_expertContainingAssembliesAndPaths.Remove(assembly)); foreach (ExpertInformation container in GeneralHelper.EnumerableToArray <ExpertInformation>(_expertInfos)) { if (container.ContainingAssembly == assembly) { RemoveExpert(container); } } } if (ExpertAssemblyRemovedEvent != null) { ExpertAssemblyRemovedEvent(assembly); } return(true); }
/// <summary> /// /// </summary> public override void OnUpdate() { if (_upading) { return; } int channelId = 0; string[] names; lock (this) { names = GeneralHelper.EnumerableToArray <string>(_channelsAddresses.Keys); } foreach (string channelName in names) { string uri; lock (this) { uri = _channelsAddresses[channelName]; } if (IsChannelEnabled(channelName)) { List <RssNewsItem> items = ProcessPage(uri, channelId); base.AddItems(items.ToArray()); } channelId++; } }
private void listViewIndicatorTypes_SelectedIndexChanged(object sender, EventArgs e) { if (listViewIndicatorTypes.SelectedItems.Count > 0) { string name = listViewIndicatorTypes.SelectedItems[0].Tag as string; // Just create the indicator, no need to set it up, this will be handled by the session itself. _pendingIndicator = (PlatformIndicator)IndicatorFactory.Instance.GetIndicatorCloneByName(name); foreach (string setName in GeneralHelper.EnumerableToArray <string>(_pendingIndicator.ChartSeries.OutputResultSetsPens.Keys)) { _pendingIndicator.ChartSeries.OutputResultSetsPens[setName] = Pens.WhiteSmoke; } indicatorControl1.IsReadOnly = true; indicatorControl1.SelectedObject = _pendingIndicator.ChartSeries; } else { indicatorControl1.SelectedObject = null; _pendingIndicator = null; } UpdateUI(); }
private void buttonPresentDistribution_Click(object sender, EventArgs e) { chartControl.Clear(); foreach (ListViewItem item in this.listViewItemSelection.SelectedItems) { PropertyStatisticsData data = item.Tag as PropertyStatisticsData; Dictionary <double, double> distribution = MathHelper.CalculateValueDistribution(data.Values, 128); PresentDataSeries(data.Name, GeneralHelper.EnumerableToArray(distribution.Values)); } }
public string[] GetIndicatorsNames(IndicatorGroup indicatorsGroup) { lock (this) { if (_indicatorsGroups.ContainsKey(indicatorsGroup)) { return(GeneralHelper.EnumerableToArray <string>(_indicatorsGroups[indicatorsGroup].Keys)); } } return(new string [] { }); }
private void buttonShowDistribution_Click(object sender, EventArgs e) { ChartForm form = new ChartForm("Distribution of results"); form.Show(); Dictionary <double, double> distributedResults = MathHelper.CalculateValueDistribution(_results[listBoxResults.SelectedIndex], 256); double[] distributedValues = GeneralHelper.EnumerableToArray(distributedResults.Values); double[] distributedValuesMA = MathHelper.CalculateQuickMA(distributedValues, 12); form.Chart.MasterPane.Add(new LinesChartSeries("Value distribution", LinesChartSeries.ChartTypeEnum.Histogram, GeneralHelper.DoublesToFloats(distributedValues)), true, false); form.Chart.MasterPane.Add(new LinesChartSeries("Value distribution MA 12", LinesChartSeries.ChartTypeEnum.Line, GeneralHelper.DoublesToFloats(distributedValuesMA)), true, false); }
public AccountInfo[] GetAvailableAccounts() { // Perform update. lock (this) { TableAut accountsTable = (FXCore.TableAut)_manager.Desk.FindMainTable("accounts"); foreach (RowAut item in (RowsEnumAut)accountsTable.Rows) { string id = (string)item.CellValue("AccountID"); if (string.IsNullOrEmpty(id)) { SystemMonitor.OperationWarning("Account with null/empty id found."); continue; } AccountInfo info = new AccountInfo(); if (_accounts.ContainsKey(id)) {// Existing account info. info = _accounts[id]; } else {// New account info. info.Guid = Guid.NewGuid(); info.Id = id; } info.Name = (string)item.CellValue("AccountName"); info.Balance = Math.Round(new decimal((double)item.CellValue("Balance")), IntegrationAdapter.AdvisedAccountDecimalsPrecision); info.Equity = Math.Round(new decimal((double)item.CellValue("Equity")), IntegrationAdapter.AdvisedAccountDecimalsPrecision); info.Margin = Math.Round(new decimal((double)item.CellValue("UsableMargin")), IntegrationAdapter.AdvisedAccountDecimalsPrecision); info.Profit = Math.Round(new decimal((double)item.CellValue("GrossPL")), IntegrationAdapter.AdvisedAccountDecimalsPrecision); info.FreeMargin = Math.Round(new decimal((double)item.CellValue("UsableMargin")), IntegrationAdapter.AdvisedAccountDecimalsPrecision); // Finally, assign the update structure. _accounts[id] = info; } return(GeneralHelper.EnumerableToArray <AccountInfo>(_accounts.Values)); } }
GetAvailableAccountsResponseMessage Receive(GetAvailableAccountsMessage message) { IImplementation implementation = _implementation; if (implementation == null || OperationalState != OperationalStateEnum.Operational) { return(new GetAvailableAccountsResponseMessage(new AccountInfo[] { }, false)); } AccountInfo[] accounts = implementation.GetAvailableAccounts(); if (accounts == null) {// Stub provides no info on this, so we should. lock (this) { accounts = GeneralHelper.EnumerableToArray <AccountInfo>(_accounts.Values); } } return(new GetAvailableAccountsResponseMessage(accounts, true)); }
protected override void client_UpdateEvent(MessageBusClient client) { base.client_UpdateEvent(client); // Also send this notification to clients. int[] keys; lock (_syncRoot) { keys = GeneralHelper.EnumerableToArray <int>(_remoteClientsNetIds.Keys); } ClientUpdateMessage message = new ClientUpdateMessage() { ClientId = client.Id, MessageId = PendingMessageId, RequestResponse = false }; foreach (int key in keys) { ToClient(key, message, null); } }
/// <summary> /// Make sure to call on Invoke'd thread. /// </summary> /// <param name="account"></param> void PerformUpdate(MbtAccount account, bool updateAccount, bool updateOrders, bool updatePositions) { //SystemMonitor.CheckError(_messageLoopOperator.InvokeRequred == false, "Invoke must not be required in baseMethod call."); MbtOrderClient orderClient = _orderClient; MBTradingConnectionManager manager = _manager; MBTradingQuote quotes = null; if (orderClient == null || manager == null) { return; } quotes = manager.Quotes; if (quotes == null) { return; } AccountInfo info; Dictionary <string, OrderInfo> pendingOrderInfos = new Dictionary <string, OrderInfo>(); List <PositionInfo> positionsInfos = new List <PositionInfo>(); lock (this) { if (updateOrders) { // We need to send up only the latest of each orders histories, since prev ones are for previous states. foreach (MbtOrderHistory history in _orderClient.OrderHistories) { Order.UpdateTypeEnum updateType; OrderInfo? orderInfo = ConvertToOrderInfo(history, out updateType); if (orderInfo.HasValue) { pendingOrderInfos[orderInfo.Value.Id] = orderInfo.Value; } } // Make sure open orders orderInfo is always on top. foreach (MbtOpenOrder pOrd in _orderClient.OpenOrders) { OrderInfo?orderInfo = ConvertToOrderInfo(pOrd); if (orderInfo.HasValue) { pendingOrderInfos[orderInfo.Value.Id] = orderInfo.Value; } } } if (updatePositions) { foreach (MbtPosition position in _orderClient.Positions) { PositionInfo?positionInfo = ConvertToPositionInfo(position); if (positionInfo.HasValue) { positionsInfos.Add(positionInfo.Value); } } } if (_accountInfo.HasValue) { info = _accountInfo.Value; } else { info = new AccountInfo(); info.Guid = Guid.NewGuid(); } ConvertAccount(account, ref info); _accountInfo = info; } MBTradingAdapter adapter = _adapter; if (adapter != null) { OrderExecutionSourceStub stub = adapter.OrderExecutionSourceStub; if (stub != null) { if (updateAccount) { stub.UpdateAccountInfo(_accountInfo.Value); } if (updateOrders) { stub.UpdateOrdersInfo(_accountInfo.Value, GeneralHelper.GenerateSingleValueArray <Order.UpdateTypeEnum>(pendingOrderInfos.Count, Order.UpdateTypeEnum.Update), GeneralHelper.EnumerableToArray <OrderInfo>(pendingOrderInfos.Values)); } if (updatePositions) { stub.UpdatePositionsInfo(_accountInfo.Value, positionsInfos.ToArray()); } } } }
/// <summary> /// Serialization routine. /// </summary> public void GetObjectData(SerializationInfo info, StreamingContext context) { info.AddValue("resultSetsNames", GeneralHelper.EnumerableToArray <string>(_resultSets.Keys)); info.AddValue("resultSetsChartTypes", _resultSetsChartTypes); }
/// <summary> /// Update user interface based on the underlying information. /// </summary> void UpdateUI() { if (_expert == null || _expert.Manager == null) { return; } ExpertSession[] sessions; lock (_expert.Manager) { sessions = GeneralHelper.EnumerableToArray <ExpertSession>(_expert.Manager.SessionsArray); } List <ToolStripButton> panelsButtons = GetPanelsButtons(); foreach (PlatformExpertSession session in sessions) { // Search in already existing. bool sessionFound = false; foreach (ToolStripButton button in panelsButtons) { Panel containingPanel = (Panel)button.Tag; if (containingPanel.Tag is PlatformExpertSessionControl) { PlatformExpertSessionControl sessionControl = (PlatformExpertSessionControl)containingPanel.Tag; if (sessionControl.Session == session) {// Session found and presented, continue. panelsButtons.Remove(button); sessionFound = true; break; } } } if (sessionFound) { continue; } // Create new sessionInformation. Panel panel = CreateSessionPanel(session); panel.Parent = this; panel.BringToFront(); panel.CreateControl(); ToolStripButton newButton = new ToolStripButton(session.Info.Name, ForexPlatformFrontEnd.Properties.Resources.PIN_GREY); newButton.Tag = panel; newButton.Click += new EventHandler(toolStripButton_Click); this.toolStripMain.Items.Add(newButton); // Show newly created sessionInformation. toolStripButton_Click(newButton, EventArgs.Empty); } // Those buttons no longer have corresponding sessions and must be removed. foreach (ToolStripButton button in panelsButtons) { Panel panel = button.Tag as Panel; if (panel.Tag is PlatformExpertSessionControl) { DestroySessionPanel(panel); this.Controls.Remove(panel); button.Click -= new EventHandler(toolStripButton_Click); toolStripMain.Items.Remove(button); } } // Make sure there is at least one visibile sessionInformation if there are any. panelsButtons = GetPanelsButtons(); bool visibleSessionFound = false; foreach (ToolStripButton button in panelsButtons) { if (((Panel)(button.Tag)).Visible) { visibleSessionFound = true; break; } } if (visibleSessionFound == false && panelsButtons.Count > 0) {// Show the first available sessionInformation. toolStripButton_Click(panelsButtons[0], EventArgs.Empty); } //toolStripAdvanced.Visible = toolStripButtonAdvanced.Checked; }
public override void GetObjectData(SerializationInfo info, StreamingContext context) { base.GetObjectData(info, context); info.AddValue("dataSourceId", _dataSourceId.HasValue ? _dataSourceId.Value : ComponentId.Empty); info.AddValue("symbols", GeneralHelper.EnumerableToArray <Symbol>(_symbolQuotes.Keys)); }