private void InitInstrument() { //初始化控件信息 foreach (InstrumentInfo instrumnet in InstrumentInfoList.getInstence()) { System.Windows.Data.Binding bd = new System.Windows.Data.Binding("DevInfoState"); bd.Mode = BindingMode.TwoWay; System.Windows.Data.Binding bdEnable = new System.Windows.Data.Binding("Enabled"); bdEnable.Mode = BindingMode.TwoWay; // if (instrumnet.InstrumentTypeID == InstrumentType.SignalSource) { this.SG.instrument = instrumnet; this.SG.SetBinding(imageControl.DevEnableProperty, bdEnable); this.SG.SetBinding(imageControl.DevStateProperty, bd); this.SG.DataContext = instrumnet; } //频谱仪 if (instrumnet.InstrumentTypeID == InstrumentType.SA) { this.PXA.instrument = instrumnet; this.PXA.SetBinding(imageControl.DevEnableProperty, bdEnable); this.PXA.SetBinding(imageControl.DevStateProperty, bd); this.PXA.DataContext = instrumnet; } } DutInfo = InstrumentInfoList.getInstence().GetInstrument("RackSys.TestLab.Instrument.DUT", "1"); //this.cmbPort.ItemsSource = new List<string>() //{ // "COM1" //}; }
override public void tickSize(int tickerId, int field, int size) { lock (_asyncObject) { if (!_asyncObject.ContainsKey(tickerId)) { return; } InstrumentInfo quote = (InstrumentInfo)_asyncObject[tickerId]; switch (field) { case TickType.DELAYED_BID_SIZE: quote.BidSize = size; break; case TickType.DELAYED_ASK_SIZE: quote.AskSize = size; break; case TickType.DELAYED_LAST_SIZE: quote.LastSize = size; break; case TickType.DELAYED_VOLUME: quote.Volume = size; break; } if (_asyncEvent.ContainsKey(tickerId)) { _asyncEvent[tickerId].Set(); } } }
/// <summary> /// Processes the response to the InstrumentInfo command. /// </summary> /// <param name="instrumentInfoResponse">Command response data.</param> private void ProcessInstrumentInfoResponse(XElement instrumentInfoResponse) { //Expected response //<InstrumentInfo> // <field Label="...">...</field> // ... //</InstrumentInfo> using (InstrumentInfo.AcquireLock()) { InstrumentInfo.Clear(); foreach (var fieldElement in instrumentInfoResponse.Elements("field", StringComparison.InvariantCultureIgnoreCase)) { var label = FindAttribute(fieldElement, "Label").Value; InstrumentInfo.Add(new InstrumentInfoElement(label, fieldElement.Value)); if (string.Compare(label, "Options", true) == 0) { Options = fieldElement.Value; } else if (string.Compare(label, "Family", true) == 0) { Family = fieldElement.Value; } } } }
public List <InstrumentInfo> getInsrumetns(UserData _user) { List <InstrumentInfo> instrumentInfoList = new List <InstrumentInfo>(); LicenseServiceClient licenseServiceClient = new LicenseServiceClient(); foreach (InstrumentsContract instrumentsContract in ((IEnumerable <InstrumentsContract>)licenseServiceClient.getInstuments(new Trader() { Account = _user.User, Signature = _user.Signature })).Where <InstrumentsContract>((Func <InstrumentsContract, bool>)(inst => inst.Enabled))) { InstrumentInfo instrumentInfo = new InstrumentInfo() { ID = instrumentsContract.DisplayId, Name = instrumentsContract.Description, Parameters = new string[2] { instrumentsContract.Parametr1, instrumentsContract.Parametr2 }, Providerid = instrumentsContract.ProviderId }; instrumentInfoList.Add(instrumentInfo); } return(instrumentInfoList); }
/// <summary> /// 重载构造函数 /// </summary> /// <param name="instrument">设备信息</param> /// <param name="imagesource">图片源</param> public DlgDevicePropertyManage(ref InstrumentInfo instrument, ImageSource imagesource) { InitializeComponent(); // initCom(); // this.ImageDevice.AddImage(imagesource); if (instrument != null) { if (instrument.InstrumentTypeID == InstrumentType.DCPowerAnalyzer || instrument.InstrumentTypeID == InstrumentType.DCPower) { this.rowDCPower.Height = new GridLength(40, GridUnitType.Pixel); this.labDevName.Content = "电源名称:"; } if (instrument.InstrumentTypeID == InstrumentType.TemperatureMonitor) { this.rowDCPower.Height = new GridLength(40, GridUnitType.Pixel); // this.labDevName.Content = "电源名称:"; } instrumentInfo = instrument; tempInstrumentInfo = instrumentInfo; this.ImageDevice.Source = imagesource; //this.InitUI(imagesource); this.LabelDeviceType.Content = instrument.InstrumentName; this.LabelDeviceModelNo.Content = instrument.ModelNo; this.txtInnerNum.Text = instrument.IDInInstitute; this.txtDevName.Text = instrument.InstrumentName; this.txtChanneNum.Text = instrument.DCModleNum.ToString(); // this.txtInputAddress.Text = instrument.IpAddress; instrumentAddress.IsApply = true; //if (instrument.InstrumentTypeID == InstrumentType.MultiChannelController) //{ // instrumentAddress.InstrumentAddType = addrType.Other; // instrumentAddress.InstrumentAddr = instrument.IpAddress; // //this.rbInputAddress.IsEnabled = false; // // this.rbIOLibAddr.IsEnabled = false; // // this.comLanOrGpib.IsEnabled = false; // // this.txtInputAddress.IsEnabled = false; //} //else //{ // initAddr(instrument.IpAddress); // } this.visaAddrSel.Init(instrument.IpAddress); if (this.instrumentInfo.DevInfoState == devState.connect) { this.txtConRes.Text = "已连接 "; this.txtConRes.Foreground = new SolidColorBrush(Colors.Green); } else { this.txtConRes.Text = "未连接 "; this.txtConRes.Foreground = new SolidColorBrush(Colors.Red); } this.txtIdetn.Text = this.instrumentInfo.Identity; this.mainGrid.DataContext = this.instrumentAddress; } }
void ManageHedgedOrders(Order order) { if (!tsitemEnableHedging.Checked) { return; } // See if this order's instrument is in our managed hedges list foreach (InstrumentKey key in managedHedges.Keys) { InstrumentInfo info = managedHedges[key]; if (order.InstrumentKey == info.InstrumentKey) { //listOrders.Items.Insert(0, OrderToString(order)); if (order.IsChild && !order.IsSynthetic) { Instrument instrument = info.Instrument; OrderProfile profile = CreateOrderCopy(order, instrument); // try to delete the order and re-insert it if (order.Delete()) { DisplayOrderSuccess(instrument.Session.SendOrder(profile)); } } break; } } }
private void comboBox1_SelectedIndexChanged(object sender, EventArgs e) { selectedInstrument = (InstrumentInfo)comboBox1.SelectedItem; latestS5Candles = null; LoadOrderBookList(selectedInstrument.Name); orderBookList.SelectedIndex = 0; UpdatePrice(); }
public void IsSameAs_Compares_As_ValueObjects(InstrumentInfo sut, object other, bool same) { //act. var isSame = sut.IsSameAs(other); //assert. isSame.Should().Be(same); }
public Lot ToLot() { return(new Lot( Id, InstrumentInfo.ToInstrumentInfo(), PurchaseDate, PurchasePrice, Notes)); }
public static InstrumentInfoJsonDto FromInstrumentInfo(InstrumentInfo instrumentInfo) { return(new InstrumentInfoJsonDto { Symbol = instrumentInfo.Symbol, Name = instrumentInfo.Name, CurrentPrice = instrumentInfo.CurrentPrice }); }
public static Instrument NewInstrumentByInfo(InstrumentInfo instrumentInfo) { var newInstrument = new Instrument( instrumentInfo.Symbol, instrumentInfo.Name, instrumentInfo.CurrentPrice); return(newInstrument); }
public static void Add(InstrumentInfo instrumentInfo) { if (Get(instrumentInfo.Symbol) == null) { lock (_writeLock) { _instrumentsInfo.TryAdd(instrumentInfo.Symbol, instrumentInfo); } } }
public void Update() { DataReaderFactory tmpFac = new DataReaderFactory(dataProvider.GetDataPath()); List <InstrumentInfo> codes = tmpFac.CodeReader.GetAllCodes(); for (int i = 0; i < codes.Count; i++) { InstrumentInfo code = codes[i]; UpdateCode(code.Code, tmpFac); } }
override public void tickString(int tickerId, int tickType, string value) { lock (_asyncObject) { if (!_asyncObject.ContainsKey(tickerId)) { return; } InstrumentInfo quote = (InstrumentInfo)_asyncObject[tickerId]; } }
public void Ctor_Initializes_All_Properties() { //arrange. var symbol = "sym"; var name = "name123"; var currentPrice = 123.45m; //act. var sut = new InstrumentInfo(symbol, name, currentPrice); //assert. sut.Symbol.Should().Be(symbol); sut.Name.Should().Be(name); sut.CurrentPrice.Should().Be(currentPrice); }
public List <InstrumentInfo> GetUpdateCodes() { List <InstrumentInfo> codes = provider.GetCodes(); List <InstrumentInfo> updateCodes = new List <InstrumentInfo>(); for (int i = 0; i < codes.Count; i++) { InstrumentInfo c = codes[i]; if (!codeReader.Contain(c.Code)) { updateCodes.Add(c); } } return(updateCodes); }
public void CancelMarketData(InstrumentInfo info) { int infoHash = info.GetHashCode(); ClientSocket.cancelMktData(infoHash); lock (_asyncObject) { _asyncObject.Remove(infoHash); if (_asyncEvent.ContainsKey(infoHash)) { _asyncEvent.Remove(infoHash); } } }
override public void tickPrice(int tickerId, int field, double price, int canAutoExecute) { lock (_asyncObject) { if (!_asyncObject.ContainsKey(tickerId)) { return; } InstrumentInfo quote = (InstrumentInfo)_asyncObject[tickerId]; switch (field) { case TickType.DELAYED_ASK: quote.Ask = price; break; case TickType.DELAYED_BID: quote.Bid = price; break; case TickType.DELAYED_LAST: quote.Last = price; break; case TickType.DELAYED_OPEN: quote.Open = price; break; case TickType.DELAYED_HIGH: quote.High = price; break; case TickType.DELAYED_LOW: quote.Low = price; break; case TickType.DELAYED_CLOSE: quote.Close = price; break; } if (_asyncEvent.ContainsKey(tickerId)) { _asyncEvent[tickerId].Set(); } } }
public void RequestMarketData(InstrumentInfo info, AutoResetEvent sync = null) { int infoHash = info.GetHashCode(); lock (_asyncObject) { _asyncObject[infoHash] = info; if (sync != null) { _asyncEvent[infoHash] = sync; } } ClientSocket.reqMarketDataType(3); ClientSocket.reqMktData(infoHash, info.Details.Summary, string.Empty, false, null); }
public void invalid_lot_size_on_create_order_test() { //given var command = new CreateOrderCommand { Price = 10, Quantity = 40, Side = Domain.Commands.OrderSide.Sell, Symbol = "PETR4", Type = Domain.Commands.OrderType.Market, UserId = 123 }; var instrumentInfo = new InstrumentInfo { Type = InstrumentType.Stock, Symbol = "PETR4", Description = "PETROBRAS", Exchange = "BOVESPA", ISIN = "123456", LotStep = 100, MaxLot = 100000, MinLot = 100 }; var instrumentInfoRepositoryMock = new Mock <IRepository>(); instrumentInfoRepositoryMock.Setup(i => i.Get(It.IsAny <string>())).ReturnsAsync(instrumentInfo); var orderRepositoryMock = new Mock <IRepository>(); var message = string.Empty; try { var orderService = new OrderService(orderRepositoryMock.Object, instrumentInfoRepositoryMock.Object); orderService.Create(command); } catch (Exception ex) { message = ex.Message; } Assert.AreEqual("Quantidade inv�lida.", message); }
public static List <InstrumentInfo> LoadByLines(string[] lines) { List <InstrumentInfo> data = new List <InstrumentInfo>(lines.Length); for (int i = 0; i < lines.Length; i++) { String line = lines[i].Trim(); if (line.Equals("")) { continue; } InstrumentInfo code = new InstrumentInfo(); code.LoadFromString(line); data.Add(code); } return(data); }
// InstrumentDescriptor is my name for a string with all the instrument info jammed together // (using '|' as a separator). // SubscribeToInstrument("CME|FUTURE|HG|Dec13"); private InstrumentInfo SubscribeToInstrument(string instrumentDescriptor) { string[] parts = instrumentDescriptor.Split(new char[] { '|' }); string marketKeyStr = parts[0]; string productTypeStr = parts[1]; string productStr = parts[2]; string contract = parts[3]; ProductKey productKey = new ProductKey(marketKeyStr, productTypeStr, productStr); SubscribeToInstrument(productKey, contract); InstrumentInfo info = new InstrumentInfo(instrumentDescriptor); info.ProductKey = productKey; info.Contract = contract; return(info); }
public void UpdateInstrumentPrice_Replaces_Instrument_ValueObject() { //arrange. var instrumentInfo = new InstrumentInfo("GG1", "Golden Gates 1", 1.23m); var sut = new Lot(Guid.NewGuid(), instrumentInfo, new DateTime(2017, 12, 24), 1.23m); var newPrice = 2.34m; //act. sut.UpdateInstrumentPrice(newPrice); //assert. sut.InstrumentInfo.Should().NotBeNull(); sut.InstrumentInfo.Should().NotBe(instrumentInfo); sut.InstrumentInfo.IsSameAs(instrumentInfo).Should().BeFalse(); sut.InstrumentInfo.Symbol.Should().Be(instrumentInfo.Symbol); sut.InstrumentInfo.Name.Should().Be(instrumentInfo.Name); sut.InstrumentInfo.CurrentPrice.Should().Be(newPrice); }
public void Constructor_Initializes_All_Values() { //arrange. var id = Guid.NewGuid(); var purchaseDate = DateTime.Now; var instrumentInfo = new InstrumentInfo("SYM", "name", 123.45m); var purchasePrice = 1m; var notes = "some notes"; //act. var sut = new Lot(id, instrumentInfo, purchaseDate, purchasePrice, notes); //assert. sut.Id.Should().Be(id); sut.PurchaseDate.Should().Be(purchaseDate); sut.InstrumentInfo.Should().Be(instrumentInfo); sut.PurchasePrice.Should().Be(purchasePrice); sut.Notes.Should().Be(notes); }
/// <summary> /// Processes the response to the InstrumentInfo command. /// </summary> /// <param name="instrumentInfoResponse">Command response data.</param> private void ProcessInstrumentInfoResponse(XElement instrumentInfoResponse) { //Expected response //<InstrumentInfo> // <field Label="...">...</field> // ... //</InstrumentInfo> using (InstrumentInfo.AcquireLock()) { InstrumentInfo.Clear(); foreach (var fieldElement in instrumentInfoResponse.Elements("field")) { InstrumentInfo.Add(new InstrumentInfoElement(fieldElement.Attribute("label").Value, fieldElement.Value)); if (fieldElement.Attribute("label").Value == "Options") { Options = fieldElement.Value; } } } }
//"UART", "TELNET", "SCPI", "DRIVER" public static int _openDevice(AbstractInstrument instrument, InstrumentInfo info) { switch (info.CnnType) { case "UART": { return(instrument.Open(info.ComPort, info.ComBaudRate, info.ComDataBit, Base.StringToParity(info.ComParity), Base.StringToStopBits(info.ComStopBit))); } case "TELNET": { return(instrument.Open(info.TelnetIP, info.TelnetPort, info.TelnetUser, info.TelnetPassword)); } case "SCPI": { return(instrument.Open(info.VisaAddress)); } case "DRIVER": { return(instrument.Open()); } default: return(-1); } }
/// <summary> /// Called when a property change notification is raised on this view model. This view model /// uses this method to monitor when the Connected property is changed. This logic could have /// been placed in the Connected property setter, but putting it here keeps the property setter simple. /// </summary> /// <param name="sender">Event sender.</param> /// <param name="e">Event arguments.</param> void ConnectionViewModel_PropertyChanged(object sender, System.ComponentModel.PropertyChangedEventArgs e) { if (e.PropertyName == "Connected") { LoggedOn = false; LogOnResult = String.Empty; if (Connected) { //We have become connected, so send a to get general information about //the instrument we have connected to. These commands can be executed without //first executing a Logon command. SendData(new SendDataEventArgs(_versionCommandDocument.ToString(), this)); SendData(new SendDataEventArgs(_supportedCulturesCommandDocument.ToString(), this)); SendData(new SendDataEventArgs(_instrumentInfoCommandDocument.ToString(), this)); } else { //We have become disconnected, so clear out our data. InstrumentVersion = String.Empty; ProtocolVersion = String.Empty; SelectedLanguage = null; Options = String.Empty; Family = string.Empty; using (SupportedCultures.AcquireLock()) { SupportedCultures.Clear(); } using (InstrumentInfo.AcquireLock()) { InstrumentInfo.Clear(); } } } }
/* public static CookieContainer CookieContainer { get{return DataManager.cookieContainer;} set{DataManager.cookieContainer=value;} } */ public DataManager(InstrumentInfo instrumentInfo,DataCycle dataCycle) { this.instrumentInfo=instrumentInfo; this.dataCycle=dataCycle; }
private async Task UpdateInstrumentsInfo(HashSet <IStockModel> stocks = null) { if (stocks == null) { stocks = new HashSet <IStockModel>(_mainModel.Stocks.Values); } try { var info = await GetInstrumentsInfo(); if (info.Status.Equals("Ok", StringComparison.InvariantCultureIgnoreCase)) { LastInstrumentsUpdate = DateTime.Now; var instruments = info.Payload.Values.ToDictionary(v => v.Symbol.Ticker); ExchangeStatus = info.Payload.Values .Select(v => new { v.Symbol.Exchange, v.ExchangeStatus }).Distinct() .Select(s => new ExchangeStatus(s.Exchange, s.ExchangeStatus)).ToArray(); foreach (var stock in stocks) { if (instruments.ContainsKey(stock.Ticker)) { var instrumentInfo = new InstrumentInfo(instruments[stock.Ticker]); if (Instruments.ContainsKey(stock.Ticker)) { Instruments[stock.Ticker].ReadFrom(instrumentInfo); } else { Instruments[stock.Ticker] = instrumentInfo; } if (stock.Exchange != instrumentInfo.Exchange) { stock.Exchange = instrumentInfo.Exchange; } if (stock.CanBeShorted != instrumentInfo.ShortIsEnabled) { stock.CanBeShorted = instrumentInfo.ShortIsEnabled; } } else { stock.Status = "Инструмент не торгуется"; stock.IsDead = true; } } } else { throw new Exception(info.Status); } } catch (Exception ex) { LogError($"Ошибка получения сведений об инструментах: {ex.Message}"); LastInstrumentsUpdate = DateTime.MinValue; } }
public DataManager(InstrumentInfo instrumentInfo,DataCycle dataCycle) { }
void processFill(FillOriginator originator, FillAction action, Fill fill) { /* * fill.BuySell; * fill.FFT2; * fill.FFT3; * fill.FillKey; * fill.FillType; * fill.InstrumentKey; * fill.IsHedge; // autospreader hedge order * fill.IsQuoting; // autospreader quoting order * fill.MatchPrice; * fill.Quantity; * fill.SpreadId; * fill.TransactionDateTime; */ // If this is the first fill for this instrument, then add it to our list and // subscribe to the instrument updates. if (!instruments.ContainsKey(fill.InstrumentKey)) { InstrumentLookupSubscription ils = new InstrumentLookupSubscription(apiInstance.Session, Dispatcher.Current, fill.InstrumentKey); ils.Update += new EventHandler <InstrumentLookupSubscriptionEventArgs>(ils_Update); ils.Start(); InstrumentInfo info = new InstrumentInfo(fill.InstrumentKey); instruments.Add(fill.InstrumentKey, info); } // Display the fill in the grid and play and sounds and/or send any messages related to // this fill. FillBasic fb = new FillBasic(fill); displayFill(fillGrid, fb); UpdateFillCount(fillGrid.Rows.Count); UpdateProfit(0); // See if this fill contains our '#' hashtag in either FFT field. string hashField = null; if (fill.FFT2.StartsWith("#")) { hashField = fill.FFT2; } if (fill.FFT3.StartsWith("#")) { hashField = fill.FFT3; } // If we found a valid '#' hashtag value, then put it in our dropdown combo box. if (hashField != null) { // Add this fill to our list of fills with this same hashsymbol if (!hashSymbols.ContainsKey(hashField)) { hashSymbols.Add(hashField, new List <Fill>()); } List <Fill> fills = hashSymbols[hashField]; fills.Add(fill); // Add this hashsymbol to our dropdown list if it is not already there if (!tscomboFFT.Items.Contains(hashField)) { tscomboFFT.Items.Add(hashField); } // If the user is filtering by this hash symbol then put this fill in the filter grid also string selectedHash = tscomboFFT.SelectedItem as string; if (selectedHash != null && selectedHash.Equals(hashField)) { displayFill(filteredGrid, fb); } } }
private ClientPortfolio GetListOperations(string AccountNumber, string StartDate, string EndDate) { byte[] bs; string schema; string TimeZone = Properties.Settings.Default.TimeInfo.ToString(); string strtDate = StartDate + TimeZone; string edDate = EndDate + TimeZone; string fileName = Properties.Settings.Default.REP_REGADVICE_QUERY.ToString(); string OperationName = Properties.Settings.Default.REP_REGADVICE_OPNAME.ToString(); int RowCount = 10; RowCount = Properties.Settings.Default.DEFAULT_ROW_COUNT; string TemplateFileName = HttpContext.Current.Server.MapPath("~/" + fileName); string filter = FileToString(TemplateFileName); filter = filter.Replace("@AccountReference", AccountNumber); filter = filter.Replace("@StartDate", strtDate); filter = filter.Replace("@EndDate", edDate); ClientPortfolio clientPortfolio = new ClientPortfolio(); List <InstrumentInfo> instrumentInfoList = new List <InstrumentInfo>(); BrokerInfo brokerInfo = new BrokerInfo(); AccountDetails accountDetails = new AccountDetails(); try { rt = mid.DataSetListZIP(SessionID, OperationName, RowCount, filter, out schema, out bs); if (rt.HasError) // lets see what server thinks about that { Logger logger = LogManager.GetCurrentClassLogger(); logger.Error(DateTime.Now.ToString() + "\t" + rt.ErrorInfo.ErrorReference + "\t" + rt.ErrorInfo.ErrorText); } else { /* unzip output from server */ DataSet opListDS = Utils.unZipDS(bs, schema); DataTable Balances = opListDS.Tables["BALANCE"]; DataTable Balchange = opListDS.Tables["BALCHANGE"]; DataTable ISIN = opListDS.Tables["ISIN"]; DataTable TranTypes = opListDS.Tables["CONFIG_TRANSACTION_TYPE"]; decimal NetActivity = 0.0M; var balanceList = from Balance in Balances.AsEnumerable() select new { BalanceAccount = Balance.Field <int>("BALANCE_ACCOUNT"), AccountReference = Balance.Field <string>("ACCOUNT_REFERENCE"), StartPledge = Balance.Field <decimal?>("BALTIME_PLEDGED_OPEN") == null ? 0 : Balance.Field <decimal?>("BALTIME_PLEDGED_OPEN"), EndingPledge = Balance.Field <decimal?>("BALTIME_PLEDGED_CLOSE") == null ? 0 : Balance.Field <decimal?>("BALTIME_PLEDGED_CLOSE"), Price = Balance.Field <decimal?>("PHIST_CLOSE") == null ? 0 : Balance.Field <decimal?>("PHIST_CLOSE"), // Value = Balance.Field<decimal?>("PHIST_CLOSE") == null ? 0 : Balance.Field<decimal?>("PHIST_CLOSE") * Balance.Field<decimal?>("BALTIME_BALANCE_CLOSE") ,//== null ? 0 : Balance.Field<decimal?>("BALTIME_BALANCE_CLOSE"), Value = Balance.Field <decimal?>("PHIST_CLOSE") * Balance.Field <decimal?>("BALTIME_BALANCE_CLOSE"), //== null ? 0 : Balance.Field<decimal?>("BALTIME_BALANCE_CLOSE"), ISINCCY = Balance.Field <string>("PHIST_CCY"), Name = Balance.Field <string>("NAME_BLOCK_1"), BrokerName = Balance.Field <string>("DEPOPART_NAME"), BrokerCode = Balance.Field <string>("DEPOPART_CODE"), BalCarriedForward = Balance.Field <decimal?>("BALTIME_BALANCE_CLOSE"), BalBroughtForward = Balance.Field <decimal?>("BALTIME_BALANCE_OPEN"), ISIN = Balance.Field <int?>("BALANCE_ISIN"), ISIN_CCY = Balance.Field <string>("PHIST_CCY") }; List <InstrumentInfo> InstrumentInfoList = new List <InstrumentInfo>(); NetActivity = 0; foreach (var b in balanceList.ToList()) { brokerInfo.BrokerCode = b.BrokerCode; brokerInfo.BrokerName = b.BrokerName; accountDetails.Name = b.Name; accountDetails.Account = b.AccountReference.ToString(); InstrumentInfo InstrInfo = new InstrumentInfo(); InstrInfo.InstrumentISINCode = b.ISIN.ToString(); //Get Balance Data var BalChange = from Balch in Balchange.AsEnumerable() where Balch.Field <int>("BALCHANGE_ACCOUNT") == b.BalanceAccount && Balch.Field <int>("BALCHANGE_ISIN") == b.ISIN && Balch.Field <string>("TRANS_CCY") == b.ISINCCY /* No records will be returned if there is a transaction without currency */ select new { TransactionID = Balch.Field <int>("Trans_ID"), TransactionType = Balch.Field <string>("Trans_Type"), TransactionDate = Balch.Field <DateTime>("BALCHANGE_DATE"), TransactonQty = Balch.Field <decimal?>("BALCHANGE_QTY"), TransactonCurr = Balch.Field <string>("TRANS_CCY") }; //GetInstruments Header var Instrument = from isin in ISIN.AsEnumerable() where isin.Field <int>("ISIN_ID") == b.ISIN select new { ISINID = isin.Field <int>("ISIN_ID"), ISIN_Code = isin.Field <string>("ISIN_CODE"), ISIN_CCY = isin.Field <string>("ISIN_CCY"), ISIN_FULL_NAME = isin.Field <string>("ISIN_FULL_NAME"), ISIN_SHORT_NAME = isin.Field <string>("ISIN_SHORT_NAME") }; InstrInfo.InstrumentISINCode = b.ISIN.ToString(); foreach (var inst in Instrument.ToList()) { InstrInfo.InstrumentISINCode = inst.ISIN_Code; InstrInfo.InstrumentCode = inst.ISIN_SHORT_NAME.ToString(); InstrInfo.InstrumentName = inst.ISIN_FULL_NAME.ToString(); InstrInfo.ISINCurrency = inst.ISIN_CCY.ToString(); } //Get Transaction Details ----------------------------------------------------Balchange -------------------------------------------------------------- NetActivity = 0; List <TransactionActivity> TransActivityList = new List <TransactionActivity>(); foreach (var bal in BalChange.ToList()) { TransactionActivity TransActivity = new TransactionActivity(); TransActivity.TransactionDate = bal.TransactionDate.ToString("yyyy-MM-dd"); TransActivity.TransactionID = bal.TransactionID.ToString(); TransActivity.TransCurrency = bal.TransactonCurr; TransActivity.Quantity = bal.TransactonQty.ToString(); NetActivity = NetActivity + Convert.ToDecimal(TransActivity.Quantity); var TransType = from TranType in TranTypes.AsEnumerable() where TranType.Field <string>("TRANTYPE") == bal.TransactionType select new { TranType = TranType.Field <string>("TRANTYPE"), TranDesc = TranType.Field <string>("TRANTYPE_DESCRIPTION") }; foreach (var Tran in TransType.ToList()) { TransActivity.TransType = Tran.TranDesc; } TransActivityList.Add(TransActivity); } // InstrInfo.TransactionActivity = TransActivityList; // TransActivityList.GroupBy(x => x.TransactionID).Select(g => g.First()); //InstrInfo.TransactionActivity = TransActivityList.Distinct().ToList(); //InstrInfo.TransactionActivity = InstrInfo.TransactionActivity = TransActivityList.GroupBy(p => p.TransactionID).Select(g => g.First()).ToList(); InstrInfo.BroughtForwardDate = StartDate.ToString(); InstrInfo.CarryForwardDate = EndDate.ToString(); //; InstrInfo.PledgeEndingBalance = b.EndingPledge.ToString(); InstrInfo.PlegeStartingBalance = b.StartPledge.ToString(); InstrInfo.Value = b.Value.ToString().Trim() == "" ? "0" : b.Value.ToString().Trim(); InstrInfo.Price = b.Price.ToString(); InstrInfo.NetActivityAmount = NetActivity.ToString(); InstrInfo.CarryForwardAmount = b.BalCarriedForward.ToString(); InstrInfo.BroughtForwardAmount = b.BalBroughtForward.ToString(); InstrInfo.ISINCurrency = b.ISINCCY; InstrumentInfoList.Add(InstrInfo); } //GrandTotal List <GrandTotal> GrandTotalList = new List <Models.GrandTotal>(); try { var GrandTotal = from t in InstrumentInfoList group t by t.ISINCurrency into g select new { ISINCurrency = g.Key, totalAmount = g.Sum(a => (decimal.Parse(a.Value))) // blanks will be treated as 0 }; foreach (var g in GrandTotal.ToList()) { GrandTotal grandTotal = new GrandTotal(); grandTotal.GrandTotalCurrency = g.ISINCurrency; grandTotal.GrandTotalAmount = g.totalAmount.ToString(); GrandTotalList.Add(grandTotal); } } catch (Exception ex) { Logger logger = LogManager.GetCurrentClassLogger(); logger.Error(DateTime.Now.ToString() + "\t" + ex.Message); } clientPortfolio.GrandTotal = GrandTotalList; clientPortfolio.AccountDetails = accountDetails; clientPortfolio.Broker = brokerInfo; clientPortfolio.InstrumentInfo = InstrumentInfoList; } } catch (Exception ex) { Logger logger = LogManager.GetCurrentClassLogger(); logger.Error(DateTime.Now.ToString() + "\t" + ex.Message); //Console.WriteLine(String.Format("Operations list exception:\r\n{0}", ex.Message)); } finally { //always close once done. //if (mid != null) // mid.Close(); } return(clientPortfolio); }