Пример #1
0
 void EWrapper.updatePortfolio(Contract contract, double position, double marketPrice, double marketValue, double averageCost, double unrealisedPNL, double realisedPNL, string accountName)
 {
     UpdatePortfolio?.Invoke(contract, position, marketPrice, marketValue, averageCost, unrealisedPNL, realisedPNL, accountName);
 }
Пример #2
0
        /// <summary>
        /// takes messages from the shared queue, converts them to C# classes, and sends them to up
        /// берет сообщения из общей очереди, конвертирует их в классы C# и отправляет на верх
        /// </summary>
        public void Converter()
        {
            while (true)
            {
                try
                {
                    if (_isDisposed)
                    {
                        return;
                    }

                    if (!_newMessage.IsEmpty)
                    {
                        string data;

                        if (_newMessage.TryDequeue(out data))
                        {
                            if (data.StartsWith("<pits>") || data.StartsWith("<sec_info"))
                            {
                                continue;
                            }

                            if (data.StartsWith("<server_status"))
                            {
                                ServerStatus status = Deserialize <ServerStatus>(data);

                                if (status.Connected == "true")
                                {
                                    IsConnected = true;
                                    Connected?.Invoke();
                                }
                                else if (status.Connected == "false")
                                {
                                    IsConnected = false;
                                    Disconnected?.Invoke();
                                }
                                else if (status.Connected == "error")
                                {
                                    SendLogMessage(status.Text, LogMessageType.Error);
                                }
                            }
                            else if (data.StartsWith("<securities>"))
                            {
                                var securities = _deserializer.Deserialize <List <Security> >(new RestResponse()
                                {
                                    Content = data
                                });

                                UpdatePairs?.Invoke(securities);
                            }
                            else if (data.StartsWith("<united_portfolio"))
                            {
                                UnitedPortfolio unitedPortfolio = Deserialize <UnitedPortfolio>(data);

                                UpdatePortfolio?.Invoke(unitedPortfolio);
                            }
                            else if (data.StartsWith("<positions"))
                            {
                                var positions = Deserialize <TransaqPositions>(data);

                                UpdatePositions?.Invoke(positions);
                            }
                            else if (data.StartsWith("<clientlimits"))
                            {
                                var limits = Deserialize <Clientlimits>(data);

                                UpdateMonoPortfolio?.Invoke(limits);
                            }
                            else if (data.StartsWith("<client"))
                            {
                                var clientInfo = _deserializer.Deserialize <Client>(new RestResponse()
                                {
                                    Content = data
                                });

                                ClientsInfo?.Invoke(clientInfo);
                            }
                            else if (data.StartsWith("<alltrades>"))
                            {
                                var allTrades = _deserializer.Deserialize <List <Trade> >(new RestResponse()
                                {
                                    Content = data
                                });

                                NewTradesEvent?.Invoke(allTrades);
                            }
                            else if (data.StartsWith("<quotes>"))
                            {
                                var quotes = _deserializer.Deserialize <List <Quote> >(new RestResponse()
                                {
                                    Content = data
                                });

                                UpdateMarketDepth?.Invoke(quotes);
                            }
                            else if (data.StartsWith("<orders>"))
                            {
                                var orders = _deserializer.Deserialize <List <Order> >(new RestResponse()
                                {
                                    Content = data
                                });

                                MyOrderEvent?.Invoke(orders);
                            }
                            else if (data.StartsWith("<trades>"))
                            {
                                var myTrades = _deserializer.Deserialize <List <Trade> >(new RestResponse()
                                {
                                    Content = data
                                });

                                MyTradeEvent?.Invoke(myTrades);
                            }
                            else if (data.StartsWith("<candles"))
                            {
                                Candles newCandles = Deserialize <Candles>(data);

                                NewCandles?.Invoke(newCandles);
                            }
                            else if (data.StartsWith("<messages>"))
                            {
                                if (data.Contains("Время действия Вашего пароля истекло"))
                                {
                                    NeedChangePassword?.Invoke();
                                }
                            }
                        }
                    }
                }

                catch (Exception exception)
                {
                    SendLogMessage(exception.ToString(), LogMessageType.Error);
                }
                Thread.Sleep(1);
            }
        }
 public virtual void updatePortfolio(Contract contract, double position, double marketPrice, double marketValue, double averageCost, double unrealisedPNL, double realisedPNL, string accountName)
 {
     UpdatePortfolio?.Invoke(this, new UpdatePortfolioArgs(contract, position, marketPrice, marketValue, averageCost, unrealisedPNL, realisedPNL, accountName));
 }
Пример #4
0
 /// <summary>
 /// UpdatePortfolio event invocator
 /// </summary>
 protected virtual void OnUpdatePortfolio(UpdatePortfolioEventArgs e)
 {
     UpdatePortfolio?.Invoke(this, e);
 }
Пример #5
0
 public void updatePortfolio(Contract contract, double position, double marketPrice, double marketValue, double averageCost, double unrealizedPNL, double realizedPNL, string accountName)
 {
     UpdatePortfolio?.Invoke(new UpdatePortfolioMessage(contract, position, marketPrice, marketValue, averageCost, unrealizedPNL, realizedPNL, accountName));
 }