public IgPublicApiData.TradeSubscriptionModel UpdateTs(int itemPos, string itemName, IUpdateInfo update, string inputData, TradeSubscriptionType updateType)
            {
                var tsm = new IgPublicApiData.TradeSubscriptionModel();

                try
                {
                    var tradeSubUpdate = JsonConvert.DeserializeObject <LsTradeSubscriptionData>(inputData);

                    tsm.DealId         = tradeSubUpdate.dealId;
                    tsm.AffectedDealId = tradeSubUpdate.affectedDealId;
                    tsm.DealReference  = tradeSubUpdate.dealReference;
                    tsm.DealStatus     = tradeSubUpdate.dealStatus.ToString();
                    tsm.Direction      = tradeSubUpdate.direction.ToString();
                    tsm.ItemName       = itemName;
                    tsm.Epic           = tradeSubUpdate.epic;
                    tsm.Expiry         = tradeSubUpdate.expiry;
                    tsm.GuaranteedStop = tradeSubUpdate.guaranteedStop;
                    tsm.Level          = tradeSubUpdate.level;
                    tsm.Limitlevel     = tradeSubUpdate.limitLevel;
                    tsm.Size           = tradeSubUpdate.size;
                    tsm.Status         = tradeSubUpdate.status.ToString();
                    tsm.StopLevel      = tradeSubUpdate.stopLevel;

                    switch (updateType)
                    {
                    case TradeSubscriptionType.Opu:
                        tsm.TradeType = "OPU";
                        break;

                    case TradeSubscriptionType.Wou:
                        tsm.TradeType = "WOU";
                        break;

                    case TradeSubscriptionType.Confirm:
                        tsm.TradeType = "CONFIRM";
                        break;
                    }

                    SmartDispatcher.getInstance().BeginInvoke(() =>
                    {
                        if (_applicationViewModel != null)
                        {
                            _applicationViewModel.UpdateDebugMessage("TradeSubscription received : " + tsm.TradeType);
                            _applicationViewModel.TradeSubscriptions.Add(tsm);

                            if ((tradeSubUpdate.affectedDeals != null) && (tradeSubUpdate.affectedDeals.Count > 0))
                            {
                                foreach (var ad in tradeSubUpdate.affectedDeals)
                                {
                                    var adm = new IgPublicApiData.AffectedDealModel
                                    {
                                        AffectedDealId     = ad.dealId,
                                        AffectedDealStatus = ad.status
                                    };
                                    _applicationViewModel.AffectedDeals.Add(adm);
                                }
                            }
                        }
                    });
                }
                catch (Exception ex)
                {
                    _applicationViewModel.ApplicationDebugData += ex.Message;
                }
                return(tsm);
            }
Пример #2
0
            public IgPublicApiData.TradeSubscriptionModel UpdateTs(int itemPos, string itemName, IUpdateInfo update, string inputData, TradeSubscriptionType updateType)
            {
                var tsm = new IgPublicApiData.TradeSubscriptionModel();	           

                try
                {                                    
                    var tradeSubUpdate = JsonConvert.DeserializeObject<LsTradeSubscriptionData>(inputData);
                                         
                    tsm.DealId = tradeSubUpdate.dealId;              
                    tsm.AffectedDealId = tradeSubUpdate.affectedDealId;                        
                    tsm.DealReference = tradeSubUpdate.dealReference;
                    tsm.DealStatus = tradeSubUpdate.dealStatus.ToString();
                    tsm.Direction = tradeSubUpdate.direction.ToString();                    
                    tsm.ItemName = itemName;
                    tsm.Epic = tradeSubUpdate.epic;
                    tsm.Expiry = tradeSubUpdate.expiry;
                    tsm.GuaranteedStop = tradeSubUpdate.guaranteedStop;
                    tsm.Level = tradeSubUpdate.level;
                    tsm.Limitlevel = tradeSubUpdate.limitLevel;
                    tsm.Size = tradeSubUpdate.size;
                    tsm.Status = tradeSubUpdate.status.ToString();                                       
                    tsm.StopLevel = tradeSubUpdate.stopLevel;	            
	               				               
	                switch (updateType)
                    {
                        case TradeSubscriptionType.Opu:
                            tsm.TradeType = "OPU";
                            break;
                        case TradeSubscriptionType.Wou:
                            tsm.TradeType = "WOU";
                            break;
                        case TradeSubscriptionType.Confirm:
                            tsm.TradeType = "CONFIRM";
                            break;
                    }

                    SmartDispatcher.BeginInvoke(() =>
                    {
                        if (_applicationViewModel != null)
                        {
                            _applicationViewModel.UpdateDebugMessage("TradeSubscription received : " + tsm.TradeType);
                            _applicationViewModel.TradeSubscriptions.Add(tsm);

	                        if ((tradeSubUpdate.affectedDeals != null) && (tradeSubUpdate.affectedDeals.Count > 0))
	                        {
		                        foreach (var ad in tradeSubUpdate.affectedDeals)
		                        {
			                        var adm = new IgPublicApiData.AffectedDealModel
			                        {
				                        AffectedDeal_Id = ad.dealId,
				                        AffectedDeal_Status = ad.status
			                        };
			                        _applicationViewModel.AffectedDeals.Add(adm);
		                        }
	                        }

                        }
                    });                   
                }
                catch (Exception ex)
                {
                    _applicationViewModel.ApplicationDebugData += ex.Message;
                }
                return tsm;
            }