예제 #1
0
        public TotalTransactions GetTotalTransactions(List <CompanyTransactions> companiesTransactionsList) //para um utilizador, obter o portfolio, com o resultado total das transações
        {
            var totalTransactions = new TotalTransactions();

            decimal?totalInvested  = 0;
            decimal?totalWithdrawn = 0;
            decimal?totalValue     = 0;
            decimal?totalGainLoss  = 0;


            foreach (var companyTransactions in companiesTransactionsList)
            {
                totalInvested  += companyTransactions.TotalInvested;
                totalWithdrawn += companyTransactions.TotalWithdrawn;
                totalValue     += companyTransactions.TotalCurrentSharesValue;
                totalGainLoss  += companyTransactions.TotalGainLoss;
            }

            totalTransactions.TotalInvested  = totalInvested;
            totalTransactions.TotalWithdrawn = totalWithdrawn;
            totalTransactions.TotalValue     = totalValue;
            totalTransactions.TotalGainLoss  = totalGainLoss;
            if ((totalValue + totalWithdrawn) == 0)
            {
                totalTransactions.TotalGainLossPercentage = 0;
            }
            else
            {
                totalTransactions.TotalGainLossPercentage = (Math.Abs(((double)totalInvested - ((double)totalWithdrawn + (double)totalValue))) / (double)totalInvested) * 100;
            }

            totalTransactions.Balance = totalWithdrawn + totalValue;

            return(totalTransactions);
        }
예제 #2
0
        public string GetTransactionReport()
        {
            string report = "";

            for (int i = 0; i < _traderAgent.Agents.Count; i++)
            {
                AbstractStrategy abstracttrader = (AbstractStrategy)_traderAgent.Agents[i];
                //report += "Instrument:\t\t\t\t\t" + abstracttrader._instrument.Name + "\r\n";
                report += "Date range:\t\t\t" + GetStartDate().ToShortDateString() + " - " + GetEndDate().ToShortDateString() + "\r\n";
                report += "Initial Balance:\t\t\t" + abstracttrader.Account.InitialBalance.ToString() + "\r\n";
                report += "Total bars:\t\t\t" + ((Statistics)_traderstats[abstracttrader]).getDays().ToString() + "\r\n";
                report += "Total transactions:\t\t" + TotalTransactions.ToString() + "\r\n";
                report += "Total bars held:\t\t\t" + ((Statistics)_traderstats[abstracttrader]).TotalHeldBars.ToString() + "\r\n";
                report += "Total bars won:\t\t\t" + ((Statistics)_traderstats[abstracttrader]).getUpPosDays().ToString() + "\r\n";
                report += "Total bars even:\t\t\t" + ((Statistics)_traderstats[abstracttrader]).getEvenPosDays().ToString() + "\r\n";
                report += "Total bars lost:\t\t\t" + ((Statistics)_traderstats[abstracttrader]).getDownPosDays().ToString() + "\r\n";
                report += "Maximum consecutive wins:\t\t" + ((Statistics)_traderstats[abstracttrader]).MaximumConsectutiveWinBars.ToString() + "\r\n";
                report += "Average consecutive wins:\t\t" + ((Statistics)_traderstats[abstracttrader]).AverageConsectutiveWinBars.ToString() + "\r\n";
                report += "Maximum consecutive even:\t\t" + ((Statistics)_traderstats[abstracttrader]).MaximumConsectutiveEvenBars.ToString() + "\r\n";
                report += "Average consecutive even:\t\t" + ((Statistics)_traderstats[abstracttrader]).AverageConsectutiveEvenBars.ToString() + "\r\n";
                report += "Maximum consecutive losses:\t\t" + ((Statistics)_traderstats[abstracttrader]).MaximumConsectutiveLoseBars.ToString() + "\r\n";
                report += "Average consecutive losses:\t\t" + ((Statistics)_traderstats[abstracttrader]).AverageConsectutiveLoseBars.ToString() + "\r\n";
                report += "Maximum bar profit:\t\t\t" + ((Statistics)_traderstats[abstracttrader]).getMaximumPosWin().ToString() + "\r\n";
                report += "Maximum bar loss:\t\t\t" + ((Statistics)_traderstats[abstracttrader]).getMaximumPosLoss().ToString() + "\r\n";
                report += "Total Profit/Loss:\t\t\t" + TotalPnL.ToString() + "\r\n";
                report += "Risk:\t\t\t\t" + ((Statistics)_traderstats[abstracttrader]).getMeanRisk().ToString() + "\r\n";
                //report += "Score:\t\t\t\t" + TotalScore.ToString() + "\r\n";
                report += "Transactions:\t\t\t" + ((Transaction)abstracttrader.Account.Transactions[0]).Date.ToShortDateString() + ", " + ((Transaction)abstracttrader.Account.Transactions[0]).Quantity.ToString() + ", " + ((Transaction)abstracttrader.Account.Transactions[0]).Amount.ToString() + ", " + (double)(Math.Abs(((Transaction)abstracttrader.Account.Transactions[0]).Amount) / Math.Abs(((Transaction)abstracttrader.Account.Transactions[0]).Quantity)) + "\r\n";
                for (int x = 1; x < abstracttrader.Account.Transactions.Count; x++)
                {
                    report += "\t\t\t\t" + ((Transaction)abstracttrader.Account.Transactions[x]).Date.ToShortDateString() + ", " + ((Transaction)abstracttrader.Account.Transactions[x]).Quantity.ToString() + ", " + ((Transaction)abstracttrader.Account.Transactions[x]).Amount.ToString() + ", " + (double)(Math.Abs(((Transaction)abstracttrader.Account.Transactions[x]).Amount) / Math.Abs(((Transaction)abstracttrader.Account.Transactions[x]).Quantity)) + "\r\n";
                }
            }
            return(report);
        }
예제 #3
0
        public string GetReport()
        {
            string report = "";

            for (int i = 0; i < _traderAgent.Agents.Count; i++)
            {
                AbstractStrategy abstracttrader = (AbstractStrategy)_traderAgent.Agents[i];
                //report += "Instrument:\t\t\t\t\t" + abstracttrader._instrument.Name + "\r\n";
                report += "Date range:\t\t\t" + GetStartDate().ToShortDateString() + " - " + GetEndDate().ToShortDateString() + "\r\n";
                report += "Total bars:\t\t\t" + ((Statistics)_traderstats[abstracttrader]).getDays().ToString() + "\r\n";
                report += "Total transactions:\t\t\t" + TotalTransactions.ToString() + "\r\n";
                report += "Total bars held:\t\t\t" + ((Statistics)_traderstats[abstracttrader]).TotalHeldBars.ToString() + "\r\n";
                report += "Total bars won:\t\t\t" + ((Statistics)_traderstats[abstracttrader]).getUpPosDays().ToString() + "\r\n";
                report += "Total bars even:\t\t\t" + ((Statistics)_traderstats[abstracttrader]).getEvenPosDays().ToString() + "\r\n";
                report += "Total bars lost:\t\t\t" + ((Statistics)_traderstats[abstracttrader]).getDownPosDays().ToString() + "\r\n";
                report += "Maximum consecutive wins:\t\t" + ((Statistics)_traderstats[abstracttrader]).MaximumConsectutiveWinBars.ToString() + "\r\n";
                report += "Average consecutive wins:\t\t" + ((Statistics)_traderstats[abstracttrader]).AverageConsectutiveWinBars.ToString() + "\r\n";
                report += "Maximum consecutive even:\t\t" + ((Statistics)_traderstats[abstracttrader]).MaximumConsectutiveEvenBars.ToString() + "\r\n";
                report += "Average consecutive even:\t\t" + ((Statistics)_traderstats[abstracttrader]).AverageConsectutiveEvenBars.ToString() + "\r\n";
                report += "Maximum consecutive losses:\t\t" + ((Statistics)_traderstats[abstracttrader]).MaximumConsectutiveLoseBars.ToString() + "\r\n";
                report += "Average consecutive losses:\t\t" + ((Statistics)_traderstats[abstracttrader]).AverageConsectutiveLoseBars.ToString() + "\r\n";
                report += "Maximum bar profit:\t\t\t" + ((Statistics)_traderstats[abstracttrader]).getMaximumPosWin().ToString() + "\r\n";
                report += "Maximum bar loss:\t\t\t" + ((Statistics)_traderstats[abstracttrader]).getMaximumPosLoss().ToString() + "\r\n";
                report += "Total Profit/Loss:\t\t\t" + TotalPnL.ToString() + "\r\n";
                report += "Risk:\t\t\t\t" + ((Statistics)_traderstats[abstracttrader]).getMeanRisk().ToString() + "\r\n";
                //report += "Score:\t\t\t\t" + TotalScore.ToString();
            }

            return(report);
        }
        public virtual int _GetUniqueIdentifier()
        {
            var hashCode = 399326290;

            hashCode = hashCode * -1521134295 + (Id?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (TotalAmount?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Year?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (Month?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (TotalAmountFunded?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (TotalTransactions?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (TotalCreditNotes?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (CNAmount?.GetHashCode() ?? 0);
            return(hashCode);
        }
        public virtual int _GetUniqueIdentifier()
        {
            var hashCode = 399326290;

            hashCode = hashCode * -1521134295 + (Id?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (TotalCommercialAgreements?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (DataQuality?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (DataAvailability?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (OnTimeDeliveries?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (AsOrderedDeliveries?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (InFullDeliveries?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (TotalImpeachments?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (CurrentTurnover?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (NextTurnover?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (PreviousTurnover?.GetHashCode() ?? 0);
            hashCode = hashCode * -1521134295 + (TotalTransactions?.GetHashCode() ?? 0);
            return(hashCode);
        }
예제 #6
0
        MessageCollection <GridTotalTransactionIndex> ITOTAL_TRANSACTIONS.GetAllTotalTransactionsByBank(TotalTransactions filtroPesquisa)
        {
            var msg = new MessageCollection <Dominio.Mensagens.GridTotalTransactionIndex>();

            try
            {
                using (var context = new HostelEntities())
                {
                    var query = (from tt in context.Total_Transactions
                                 join c in context.Calcs on tt.ID_Calc equals c.ID into cLeft
                                 join rt in context.Report_Type on tt.ID_Report_Type equals rt.ID
                                 from subC in cLeft.DefaultIfEmpty()
                                 orderby tt.DT_Reg descending
                                 where filtroPesquisa.ID_REPORT_TYPE == tt.ID_Report_Type
                                 select new Dominio.Mensagens.GridTotalTransactionIndex()
                    {
                        ID = tt.ID,
                        DT_Reg = tt.DT_Reg.Value,
                        LogLogin = tt.LogLogin,
                        TotalTransactions = tt.TotalTransactions.Value,
                        IDLastTotalCalc = (subC != null && subC.ID > 0 ? subC.ID : 0),
                        TotalCalc = (subC != null && subC.Total > 0 ? subC.Total : 0),
                        LastTotalCashier = (tt.Last_Cashier_Total.HasValue ? tt.Last_Cashier_Total.Value : 0),
                        TotalFinal = tt.TotalFinal.Value,
                        DifferenceFinalCalc = tt.DifferenceFinalCalc.HasValue ? tt.DifferenceFinalCalc.Value : 0,
                        ID_Report_Type = tt.ID_Report_Type.HasValue ? tt.ID_Report_Type.Value : 0,
                        Desc_Report_Type = rt.Description
                    });


                    ////Filtros de Pesquisa
                    if (filtroPesquisa.Report_Type > 0)
                    {
                        query = query.Where(q => (q.ID_Report_Type == filtroPesquisa.Report_Type));
                    }

                    if (!string.IsNullOrEmpty(filtroPesquisa.txtNome))
                    {
                        query = query.Where(q => q.LogLogin.Contains(filtroPesquisa.txtNome));
                    }

                    if (!string.IsNullOrEmpty(filtroPesquisa.dtInicio))
                    {
                        DateTime dtFim = DateTime.UtcNow;
                        if (!string.IsNullOrEmpty(filtroPesquisa.dtFim))
                        {
                            dtFim = Convert.ToDateTime(filtroPesquisa.dtFim);
                        }

                        DateTime dtInicio = Convert.ToDateTime(filtroPesquisa.dtInicio);

                        query = query.Where(q => q.DT_Reg >= dtInicio && q.DT_Reg <= dtFim);
                    }

                    //ordenação
                    if (filtroPesquisa.sSortDir_0 == "asc")
                    {
                        if (filtroPesquisa.iSortCol_0 == 1)
                        {
                            query = query.OrderBy(q => q.DT_Reg);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 2)
                        {
                            query = query.OrderBy(q => q.LogLogin);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 3)
                        {
                            query = query.OrderBy(q => q.TotalTransactions);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 4)
                        {
                            query = query.OrderBy(q => q.LastTotalCashier);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 5)
                        {
                            query = query.OrderBy(q => q.TotalFinal);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 6)
                        {
                            query = query.OrderBy(q => q.DifferenceFinalCalc);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 7)
                        {
                            query = query.OrderBy(q => q.Desc_Report_Type);
                        }
                        else
                        {
                            query = query.OrderBy(q => q.DT_Reg);
                        }
                    }
                    else if (filtroPesquisa.sSortDir_0 == "desc")
                    {
                        if (filtroPesquisa.iSortCol_0 == 1)
                        {
                            query = query.OrderByDescending(q => q.DT_Reg);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 2)
                        {
                            query = query.OrderByDescending(q => q.LogLogin);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 3)
                        {
                            query = query.OrderByDescending(q => q.TotalTransactions);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 4)
                        {
                            query = query.OrderByDescending(q => q.LastTotalCashier);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 5)
                        {
                            query = query.OrderByDescending(q => q.TotalFinal);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 6)
                        {
                            query = query.OrderByDescending(q => q.DifferenceFinalCalc);
                        }
                        else if (filtroPesquisa.iSortCol_0 == 7)
                        {
                            query = query.OrderByDescending(q => q.Desc_Report_Type);
                        }
                        else
                        {
                            query = query.OrderByDescending(q => q.DT_Reg);
                        }
                    }
                    else
                    {
                        query = query.OrderByDescending(q => q.DT_Reg);
                    }

                    query         = query.Take(100);
                    msg.Instances = query.Skip(filtroPesquisa.iDisplayStart).Take(filtroPesquisa.iDisplayLength).ToList();
                    msg.Code      = query.Count();//Total de registro com filtros aplicados
                }
            }
            catch (Exception ex)
            {
                msg.Exception = ex;
            }
            return(msg);
        }