コード例 #1
0
ファイル: AccountDAL.cs プロジェクト: LucianaCC/CodeExample
        public static EntityModel.Account getUserbyid(int id)
        {
            try
            {
                EntityModel.Account user = new EntityModel.Account();

                using (var Contexto = new WBTaskEntities1())
                {
                    var query = (from c in Contexto.Account
                                 where c.IdAccount == id
                                 select c);

                    var userlogined = query.First <Account>();
                    user.IdAccount = userlogined.IdAccount;
                    user.Email     = userlogined.Email;
                    user.Name      = userlogined.Nombre;
                    user.Password  = userlogined.PassWord;
                }
                return(user);
            }

            catch (Exception ex)
            {
                throw ex;
            }
        }
コード例 #2
0
 protected void addNewMessage_Click(object sender, EventArgs e)
 {
     if (Texto.Value != string.Empty)
     {
         EntityModel.Account userloged  = (EntityModel.Account)Session["user"];
         Message             newMessage = new Message();
         newMessage.Text    = Texto.Value;
         newMessage.Account = userloged;
         webService.Message_newMessage(newMessage);
         Texto.Value = string.Empty;
         refreshMessage();
     }
     else
     {
         lblError.Text = "Please, enter your message.";
     }
 }
コード例 #3
0
        private void NextBtn_Click(object sender, RoutedEventArgs e)
        {
            string accountId = AccountIdTextBox.Text;
            if(String.IsNullOrEmpty(accountId))
            {
                MessageBox.Show("Cannot use an empty account.");
                return;
            }

            using(var context = new DBContext())
            {
                //check if this account exists, otherwise add it
                Account account;
                if(context.Accounts.Any(x => x.AccountId == accountId))
                {
                    account = context.Accounts.First(x => x.AccountId == accountId);
                }
                else
                {
                    account = new Account { AccountId = accountId };
                    context.Accounts.Add(account);
                    context.SaveChanges();
                }

                //Now that we have the account, set it everywhere

                foreach(EquitySummary es in context.EquitySummaries)
                {
                    es.Account = account;
                }

                foreach (DividendAccrual da in context.DividendAccruals)
                {
                    da.Account = account;
                }

                foreach(Order o in context.Orders)
                {
                    o.Account = account;
                }

                foreach(Execution ex in context.Executions)
                {
                    ex.Account = account;
                }

                foreach(FXTransaction fxt in context.FXTransactions)
                {
                    fxt.Account = account;
                }

                foreach(FXPosition fxp in context.FXPositions)
                {
                    fxp.Account = account;
                }

                foreach(CashTransaction ct in context.CashTransactions)
                {
                    ct.Account = account;
                }

                foreach (OpenPosition op in context.OpenPositions)
                {
                    op.Account = account;
                }

                foreach(PriorPosition pp in context.PriorPositions)
                {
                    pp.Account = account;
                }

                context.SaveChanges();
            }
            _appliedChanges = true;
            MessageBox.Show("Success!");
            Close();
        }
コード例 #4
0
 public static EntityModel.Account getUser(string password, string user)
 {
     EntityModel.Account validate = DataAccesLayer.AccountDAL.getUser(password, user);
     return(validate);
 }
コード例 #5
0
ファイル: FlexParser.cs プロジェクト: QANTau/QPAS
        private static void ParseCashTransactions(XContainer xml, IDBContext context, bool skipLastDateCheck, DateTime lastDate, Account account)
        {
            var cashTransactionsMapper = new Mapper<CashTransaction>(xml.Descendants("CashTransaction"));
            List<CashTransaction> cashTransactions = cashTransactionsMapper.ParseAll();

            var instruments = context.Instruments.ToList();
            var currencies = context.Currencies.ToList();

            foreach (CashTransaction i in cashTransactions)
            {
                if (skipLastDateCheck || i.TransactionDate > lastDate)
                {
                    i.Account = account;
                    i.Currency = currencies.FirstOrDefault(x => x.Name == i.CurrencyString);
                    i.Instrument = instruments.FirstOrDefault(x => x.ConID == i.ConID);
                    context.CashTransactions.Add(i);
                }
            }
            context.SaveChanges();

            //<CashTransaction accountId="U1066712" currency="CAD" assetCategory="STK" fxRateToBase="0.99717"
            //symbol="XRE" description="XRE() DIVIDEND .0615 CAD PER SHARE - CA TAX" conid="74580643" securityID=""
            //securityIDType="" cusip="" isin="" underlyingConid="" underlyingSymbol="" issuer="" dateTime="2012-07-31"
            //amount="-6.92" type="Withholding Tax" tradeID="" code="" />
        }
コード例 #6
0
ファイル: FlexParser.cs プロジェクト: QANTau/QPAS
        private static void ParseCFDCharges(XContainer xml, IDBContext context, bool skipLastDateCheck, DateTime lastDate, Account account)
        {
            var cfdTransactionsMapper = new Mapper<CashTransaction>(xml.Descendants("CFDCharge"));
            cfdTransactionsMapper.SetAttributeMap("total", "Amount");
            cfdTransactionsMapper.SetAttributeMap("date", "TransactionDate", "yyyy-MM-dd");
            List<CashTransaction> cfdCharges = cfdTransactionsMapper.ParseAll();

            var instruments = context.Instruments.ToList();
            var currencies = context.Currencies.ToList();

            foreach (CashTransaction i in cfdCharges)
            {
                i.Type = "CFD Charge";

                if (skipLastDateCheck || i.TransactionDate > lastDate)
                {
                    i.Account = account;
                    i.Currency = currencies.FirstOrDefault(x => x.Name == i.CurrencyString);
                    i.Instrument = instruments.FirstOrDefault(x => x.ConID == i.ConID);
                    context.CashTransactions.Add(i);
                }
            }
            context.SaveChanges();

            //<CFDCharge accountId="U1066712F" currency="USD" assetCategory="CFD" fxRateToBase="1"
            //symbol="--" description="--" conid="--" securityID="--" securityIDType="--" cusip="--"
            //isin="--" underlyingConid="--" underlyingSymbol="--" issuer="--" date="2013-01-03" received="0"
            //paid="-1.27" total="-1.27" transactionID="3283049378" />
        }
コード例 #7
0
ファイル: FlexParser.cs プロジェクト: QANTau/QPAS
        private static void ParseOrders(XContainer xml, IDBContext context, bool skipLastDateCheck, Account account)
        {
            if (!xml.Descendants("Trades").Any()) return;

            var ordersMapper = new Mapper<Order>(xml.Descendants("Trades").First().Descendants("Order"));
            List<Order> orders = ordersMapper.ParseAll();

            DateTime lastDate = context.Orders.Any(x => x.AccountID == account.ID)
                ? context.Orders.Where(x => x.AccountID == account.ID).Max(x => x.TradeDate)
                : new DateTime(1, 1, 1);

            var instruments = context.Instruments.ToList();
            var currencies = context.Currencies.ToList();

            //then add the new ones
            foreach (Order order in orders)
            {
                if (order.TradeDate > lastDate || skipLastDateCheck)
                {
                    order.IsReal = true;
                    if(order.AssetCategory == AssetClass.Cash)
                    {
                        //These are currency trades. But currencies aren't provided in the SecuritiesInfos
                        //So we have to hack around it and add the currency as an instrument "manually" if it's not in yet
                        order.Instrument = TryAddAndGetCurrencyInstrument(order, context);
                    }
                    else
                    {
                        order.Instrument = instruments.FirstOrDefault(x => x.ConID == order.ConID);
                    }

                    order.Account = account;
                    order.Currency = currencies.FirstOrDefault(x => x.Name == order.CurrencyString);
                    order.CommissionCurrency = currencies.FirstOrDefault(x => x.Name == order.CommissionCurrencyString);
                    context.Orders.Add(order);
                }
            }
            context.SaveChanges();

            //<Order accountId="U1066712" currency="USD" assetCategory="STK" fxRateToBase="1" symbol="AAPL"
            //description="APPLE INC" conid="265598" securityID="" securityIDType="" cusip="" isin=""
            //underlyingConid="" underlyingSymbol="" issuer="" tradeID="--" reportDate="20140325" tradeDate="20140325"
            //tradeTime="093002" settleDateTarget="20140328" transactionType="--" exchange="--" quantity="-48"
            //tradePrice="541.37" multiplier="1" tradeMoney="-25985.76" proceeds="25985.76" taxes="0" ibCommission="-1.574285"
            //ibCommissionCurrency="USD" closePrice="544.99" openCloseIndicator="C" notes="C" cost="-25877.8" fifoPnlRealized="106.385715"
            //mtmPnl="-173.76" origTradePrice="--" origTradeDate="--" origTradeID="--" origOrderID="--" strike="" expiry="" putCall=""
            //buySell="SELL" ibOrderID="537171278" ibExecID="--" brokerageOrderID="--" orderReference="--" volatilityOrderLink="--"
            //orderPlacementTime="--" clearingFirmID="--" exchOrderId="--" extExecID="--" orderTime="20140325;093002" openDateTime="--"
            //holdingPeriodDateTime="--" whenRealized="--" whenReopened="--" levelOfDetail="ORDER" changeInPrice="--" changeInQuantity="--"
            //netCash="25984.185715" orderType="LMT" />
        }
コード例 #8
0
ファイル: FlexParser.cs プロジェクト: QANTau/QPAS
        private static void ParseExecutions(XContainer xml, IDBContext context, bool skipLastDateCheck, Account account)
        {
            if (!xml.Descendants("Trades").Any()) return;

            var tradesMapper = new Mapper<Execution>(xml.Descendants("Trades").First().Descendants("Trade"));
            List<Execution> executions = tradesMapper.ParseAll();

            DateTime lastDate = context.Executions.Any(x => x.AccountID == account.ID)
                ? context.Executions.Where(x => x.AccountID == account.ID).Max(x => x.TradeDate)
                : new DateTime(1, 1, 1);

            var currencies = context.Currencies.ToList();
            var instruments = context.Instruments.ToList();
            var orderReferenceSet = new List<long>(); //used to keep track of which orders we have set the order reference for, so we don't do it multiple times

            //then add the new ones
            foreach (Execution i in executions)
            {
                if (i.TradeDate > lastDate || skipLastDateCheck)
                {
                    i.Account = account;
                    i.Instrument = instruments.FirstOrDefault(x => x.ConID == i.ConID);
                    i.Currency = currencies.FirstOrDefault(x => x.Name == i.CurrencyString);
                    i.CommissionCurrency = currencies.FirstOrDefault(x => x.Name == i.CommissionCurrencyString);
                    var order = context.Orders.FirstOrDefault(x => x.IBOrderID == i.IBOrderID);
                    i.Order = order;
                    if (!string.IsNullOrEmpty(i.OrderReference) && !orderReferenceSet.Contains(i.IBOrderID))
                    {
                        orderReferenceSet.Add(i.IBOrderID);
                        order.OrderReference = i.OrderReference;

                        ((IObjectContextAdapter)context).ObjectContext.ObjectStateManager.ChangeObjectState(order, EntityState.Modified);
                    }
                    context.Executions.Add(i);
                }
            }
            context.SaveChanges();

            //<Trade accountId="U1066712" currency="USD" assetCategory="STK" fxRateToBase="1" symbol="VGK"
            //description="VANGUARD MSCI EUROPEAN ETF" conid="27684070" securityID="" securityIDType="" cusip="" isin=""
            //underlyingConid="" underlyingSymbol="" issuer="" tradeID="812956946" reportDate="20121231" tradeDate="20121231"
            //tradeTime="160000" settleDateTarget="20130104" transactionType="ExchTrade" exchange="ARCA" quantity="-60" tradePrice="48.84"
            //multiplier="1" tradeMoney="-2930.4" proceeds="2930.4" taxes="0" ibCommission="-1" ibCommissionCurrency="USD" closePrice="48.84"
            //openCloseIndicator="C" notes="P;" cost="-2869.2" fifoPnlRealized="60.2" mtmPnl="0" origTradePrice="0" origTradeDate=""
            //origTradeID="" origOrderID="0" strike="" expiry="" putCall="" buySell="SELL" ibOrderID="415554439"
            //ibExecID="0000d3de.50e1a59d.01.01" brokerageOrderID="" orderReference="" volatilityOrderLink=""
            //orderPlacementTime="" clearingFirmID="" exchOrderId="N/A" extExecID="AD_5629512420665350" orderTime="20121231;142412"
            //openDateTime="--" holdingPeriodDateTime="--" whenRealized="--" whenReopened="--" levelOfDetail="EXECUTION"
            //changeInPrice="0" changeInQuantity="0" netCash="2929.4" orderType="MOC" />
        }
コード例 #9
0
ファイル: FlexParser.cs プロジェクト: QANTau/QPAS
        private static void ParseEquitySummaries(XContainer xml, IDBContext context, Account account)
        {
            var equitySummaryMapper = new Mapper<EquitySummary>(xml.Descendants("EquitySummaryByReportDateInBase"));
            List<EquitySummary> equitySummaries = equitySummaryMapper.ParseAll();

            foreach (EquitySummary i in equitySummaries)
            {
                if (context.EquitySummaries.Count(x => x.Date == i.Date && x.AccountID == account.ID) == 0)
                {
                    i.Account = account;
                    context.EquitySummaries.Add(i);
                    context.SaveChanges();
                }
            }

            //<EquitySummaryByReportDateInBase accountId="U1066712" reportDate="2012-07-18" cash="-8839.601715" cashLong="0"
            //cashShort="-8839.601715" slbCashCollateral="0" slbCashCollateralLong="0" slbCashCollateralShort="0"
            //stock="38134.228955" stockLong="38134.228955" stockShort="0" slbDirectSecuritiesBorrowed="0"
            //slbDirectSecuritiesBorrowedLong="0" slbDirectSecuritiesBorrowedShort="0" slbDirectSecuritiesLent="0"
            //slbDirectSecuritiesLentLong="0" slbDirectSecuritiesLentShort="0" options="235.75" optionsLong="235.75"
            //optionsShort="0" commodities="0" commoditiesLong="0" commoditiesShort="0" bonds="0" bondsLong="0" bondsShort="0"
            //notes="0" notesLong="0" notesShort="0" interestAccruals="-7.2318305" interestAccrualsLong="0"
            //interestAccrualsShort="-7.2318305" softDollars="0" softDollarsLong="0" softDollarsShort="0" dividendAccruals="0"
            //dividendAccrualsLong="0" dividendAccrualsShort="0" total="29523.1454095" totalLong="38369.978955" totalShort="-8846.8335455" />
        }
コード例 #10
0
ファイル: FlexParser.cs プロジェクト: QANTau/QPAS
        private static void ParseOpenPositions(XContainer xml, IDBContext context, Account account)
        {
            if (!xml.Descendants("OpenPositions").Any()) return;
            var openPositionsMapper = new Mapper<OpenPosition>(xml.Descendants("OpenPosition").Where(x => x.Attribute("levelOfDetail").Value == "SUMMARY"));
            List<OpenPosition> openPositions = openPositionsMapper.ParseAll();

            //start by deleting the old ones
            context.OpenPositions.RemoveRange(context.OpenPositions.Where(x => x.AccountID == account.ID).ToList());
            context.SaveChanges();

            //then add the new ones
            foreach (OpenPosition i in openPositions)
            {
                i.Account = account;
                i.Instrument = context.Instruments.FirstOrDefault(x => x.ConID == i.ConID);
                i.Currency = context.Currencies.FirstOrDefault(x => x.Name == i.CurrencyString);

                context.OpenPositions.Add(i);
            }
            context.SaveChanges();

            //<OpenPosition accountId="U1066712" currency="USD" assetCategory="STK" fxRateToBase="1" symbol="ACWV"
            //description="ISHARES MSCI ALL COUNTRY WOR" conid="96090060" securityID="" securityIDType="" cusip=""
            //isin="" underlyingConid="" underlyingSymbol="" issuer="" reportDate="20130131" position="18" multiplier="1"
            //markPrice="58.01" positionValue="1044.18" openPrice="55.877777778" costBasisPrice="55.877777778"
            //costBasisMoney="1005.8" percentOfNAV="1.61" fifoPnlUnrealized="38.38" side="Long" @levelOfDetaillevelOfDetail="SUMMARY"
            //openDateTime="" holdingPeriodDateTime="" code="" originatingOrderID="" />
        }
コード例 #11
0
ファイル: FlexParser.cs プロジェクト: QANTau/QPAS
        private static void ParsePriorPeriodPositions(XContainer xml, IDBContext context, bool skipLastDateCheck, Account account)
        {
            var priorPeriodPositionsMapper = new Mapper<PriorPosition>(xml.Descendants("PriorPeriodPosition"));
            List<PriorPosition> priorPeriodPositions = priorPeriodPositionsMapper.ParseAll();

            DateTime lastDate = context.PriorPositions.Any(x => x.AccountID == account.ID)
                ? context.PriorPositions.Where(x => x.AccountID == account.ID).Max(x => x.Date)
                : new DateTime(1, 1, 1);

            var currencies = context.Currencies.ToList();
            var instruments = context.Instruments.ToList();

            foreach (PriorPosition i in priorPeriodPositions)
            {
                if (skipLastDateCheck || i.Date > lastDate)
                {
                    i.Account = account;
                    i.Currency = currencies.FirstOrDefault(x => x.Name == i.CurrencyString);
                    i.Instrument = instruments.FirstOrDefault(x => x.ConID == i.ConID);
                    context.PriorPositions.Add(i);
                }
            }
            context.SaveChanges();

            //<PriorPeriodPosition accountId="U1066712" currency="USD" assetCategory="STK" fxRateToBase="1" symbol="ACWV"
            //description="ISHARES MSCI ALL COUNTRY WOR" conid="96090060" securityID="" securityIDType="" cusip="" isin=""
            //underlyingConid="" underlyingSymbol="" issuer="" date="2012-12-28" price="55.23" priorMtmPnl="-9" />
        }
コード例 #12
0
ファイル: FlexParser.cs プロジェクト: QANTau/QPAS
        private static void ParseOpenDividendAccruals(XContainer xml, IDBContext context, Account account)
        {
            var openDividendAccrualsMapper = new Mapper<DividendAccrual>(xml.Descendants("OpenDividendAccrual"));
            List<DividendAccrual> dividendAccruals = openDividendAccrualsMapper.ParseAll();

            //delete all of them
            context.DividendAccruals.RemoveRange(context.DividendAccruals.Where(x => x.AccountID == account.ID).ToList());

            //then add the new ones
            foreach (DividendAccrual i in dividendAccruals)
            {
                i.Currency = context.Currencies.FirstOrDefault(x => x.Name == i.CurrencyString);
                i.Instrument = context.Instruments.FirstOrDefault(x => x.ConID == i.ConID);
                i.Account = account;
                if (i.Instrument == null)
                {
                    var logger = LogManager.GetCurrentClassLogger();
                    logger.Log(LogLevel.Error, "Could not find instrument for dividend accrual with conid: " + i.ConID);
                }
                else
                {
                    context.DividendAccruals.Add(i);
                }
            }
            context.SaveChanges();

            //<OpenDividendAccrual accountId="U1066712" currency="USD" assetCategory="STK" fxRateToBase="1" symbol="PICB"
            //description="POWERSHARES INT CORP BOND" conid="75980548" securityID="" securityIDType="" cusip="" isin=""
            //underlyingConid="" underlyingSymbol="" issuer="" exDate="2013-01-15" payDate="2013-01-31" quantity="19" tax="0.44"
            //fee="0" grossRate="0.07613" grossAmount="1.45" netAmount="1.01" code="" fromAcct="" toAcct="" />
        }
コード例 #13
0
ファイル: FlexParser.cs プロジェクト: QANTau/QPAS
        private static void ParseFXPositions(XContainer xml, IDBContext context, Account account)
        {
            var fxPositionsMapper = new Mapper<FXPosition>(xml.Descendants("FxPosition"));
            List<FXPosition> fxPositions = fxPositionsMapper.ParseAll();

            //delete all of them
            context.FXPositions.RemoveRange(context.FXPositions.Where(x => x.AccountID == account.ID).ToList());

            //then add the new ones
            foreach (FXPosition i in fxPositions)
            {
                i.FunctionalCurrency = context.Currencies.FirstOrDefault(x => x.Name == i.FunctionalCurrencyString);
                i.FXCurrency = context.Currencies.FirstOrDefault(x => x.Name == i.FXCurrencyString);
                i.Account = account;
                context.FXPositions.Add(i);
            }
            context.SaveChanges();

            //<FxPosition accountId="U1066712" acctAlias="" assetCategory="CASH" reportDate="20140325"
            //functionalCurrency="USD" fxCurrency="CAD" quantity="22.379966" costPrice="0.890970031" costBasis="-19.939879"
            //closePrice="0.89552" value="20.041707" unrealizedPL="0.101828" code="" lotDescription="" lotOpenDateTime="" levelOfDetail="SUMMARY" />
        }
コード例 #14
0
ファイル: FlexParser.cs プロジェクト: QANTau/QPAS
        private static void ParseFXTransactions(XContainer xml, IDBContext context, bool skipLastDateCheck, Account account)
        {
            var fxTransactionMapper = new Mapper<FXTransaction>(xml.Descendants("FxTransaction"));
            List<FXTransaction> fxTransactions = fxTransactionMapper.ParseAll();

            DateTime lastDate = context.FXTransactions.Any(x => x.AccountID == account.ID)
                ? context.FXTransactions.Where(x => x.AccountID == account.ID).Max(x => x.DateTime)
                : new DateTime(1, 1, 1);

            var currencies = context.Currencies.ToList();

            //then add the new ones
            foreach (FXTransaction i in fxTransactions)
            {
                if (i.DateTime > lastDate || skipLastDateCheck)
                {
                    i.FunctionalCurrency = currencies.FirstOrDefault(x => x.Name == i.FunctionalCurrencyString);
                    i.FXCurrency = currencies.FirstOrDefault(x => x.Name == i.FXCurrencyString);
                    context.FXTransactions.Add(i);
                }
            }
            context.SaveChanges();

            //<FxTransaction accountId="U1066712" acctAlias="" assetCategory="CASH" reportDate="20130401"
            //functionalCurrency="USD" fxCurrency="CAD" activityDescription="XRE() DIVIDEND .06726 CAD PER SHARE"
            //dateTime="20130328;202000" quantity="16.29" proceeds="16.034084" cost="-16.034084" realizedPL="0"
            //code="O" levelOfDetail="TRANSACTION" />
        }