예제 #1
0
        public ProfitLoss ConvertGeneralLedgerResponseToProfitLoss(GeneralLedgerResponse generalLedgerResponse, string office)
        {
            Type type = Type.Sales;

            if (generalLedgerResponse.VatType == Type.Purchase.ToString().ToLower())
            {
                type = Type.Purchase;
            }

            var g = new ProfitLoss
            {
                Office = office,
                Code   = generalLedgerResponse.Code,

                Name       = generalLedgerResponse.Name,
                Financials = new Financials
                {
                    Matchtype   = MatchType.Notmatchable,
                    Accounttype = "balance",
                    Level       = 1
                }
            };
            var fin = new VatCode();

            fin.Name = generalLedgerResponse.VatName;
            fin.Type = type;
            g.Type   = generalLedgerResponse.Type;
            return(g);
        }
예제 #2
0
 public void OnInitialize()
 {
     comboTradesBinary      = new TransactionPairsBinary(model.Context.TradeData);
     comboTradesBinary.Name = "ComboTrades";
     profitLoss             = model.Data.SymbolInfo.ProfitLoss;
     comboTrades            = new TransactionPairs(GetCurrentPrice, profitLoss, comboTradesBinary);
     profitLoss.Symbol      = model.Data.SymbolInfo;
 }
예제 #3
0
        private void showreportButton_Click(object sender, EventArgs e)
        {
            DateTime fromDate = fromdateTimePicker.Value;

            fromDate = fromDate.Date;
            DateTime toDate = todateTimePicker.Value;

            toDate = toDate.Date;
            toDate = toDate.AddDays(1);
            toDate = toDate.AddSeconds(-1);

            List <Transaction1> otherTransactions    = new List <Transaction1>();
            List <Transaction1> aTransactions        = new List <Transaction1>();
            List <Transaction1> employeeTransactions = new List <Transaction1>();
            StoreDAO            aStoreDao            = new StoreDAO();
            EmployeeDAO         aEmployeeDao         = new EmployeeDAO();

            otherTransactions    = aStoreDao.GetOtherTransactionBydateForProfit(fromDate, toDate);
            aTransactions        = aStoreDao.GetTransactionBydateForProfit(fromDate, toDate);
            employeeTransactions = aEmployeeDao.EmployeeTransactionReportBydate(fromDate, toDate);

            Int64               startDate        = new DateTime(fromdateTimePicker.Value.Year, fromdateTimePicker.Value.Month, fromdateTimePicker.Value.Day, 0, 0, 0).Ticks;
            DateTime            dtTemp           = todateTimePicker.Value.AddDays(1);
            Int64               endDate          = new DateTime(dtTemp.Year, dtTemp.Month, dtTemp.Day, 0, 0, 0).Ticks;
            List <Transaction1> saleTransactions = new List <Transaction1>();

            saleTransactions = aStoreDao.showAllData(startDate, endDate);
            toDate           = todateTimePicker.Value;
            toDate           = toDate.Date;
            List <ProfitLoss> aProfitLosses = new List <ProfitLoss>();

            while (fromDate <= toDate)
            {
                ProfitLoss aProfitLoss = new ProfitLoss();
                aProfitLoss.Date       = fromDate;
                aProfitLoss.AccsCost   = AmountCalculate(otherTransactions, fromDate);
                aProfitLoss.RMCost     = AmountCalculate(aTransactions, fromDate);
                aProfitLoss.SalaryCost = AmountCalculate(employeeTransactions, fromDate);
                aProfitLoss.SaleAmount = AmountCalculate(saleTransactions, fromDate);
                double amount1 = (aProfitLoss.AccsCost + aProfitLoss.RMCost + aProfitLoss.SalaryCost);
                if (aProfitLoss.SaleAmount - amount1 < 0)
                {
                    aProfitLoss.Loss = aProfitLoss.SaleAmount - amount1;
                }
                else
                {
                    aProfitLoss.Profit = aProfitLoss.SaleAmount - amount1;
                }
                aProfitLosses.Add(aProfitLoss);
                fromDate = fromDate.AddDays(1);
            }

            profitlossdataGridView.DataSource = aProfitLosses;
        }
 /// <summary>
 /// Returns profitloss index view
 /// </summary>
 /// <returns>profitloss index view</returns>
 /// GET: /AdministrationController/ProfitLossIndex
 public ActionResult ProfitLossIndex()
 {
     MODEL.ProfitLoss profitLossModel = new ProfitLoss();
     try
     {
         profitLossModel.OAcompanyList = Session.GetUserAssociatedCompanyList();
     }
     catch (Exception)
     {
     }
     return(IndexViewForAuthorizeUser(profitLossModel));
 }
        public void UpdateGainLoss(Double purchaseValue, Double openValue, Double currentValue)
        {
            //update Portfolio Daily and Inception Gain/Loss values and percentages

            ProfitLoss dpl = EquityCalculator.GetProfitLoss(openValue, currentValue);
            ProfitLoss ipl = EquityCalculator.GetProfitLoss(purchaseValue, currentValue);

            _portfolioDayGainLoss              = dpl.ValueChange;
            _portfolioDayGainLossPercent       = dpl.PercentChange;
            _portfolioInceptionGainLoss        = ipl.ValueChange;
            _portfolioInceptionGainLossPercent = ipl.PercentChange;
        }
예제 #6
0
        public GeneralLedgerResponse ConvertProfitLoss(ProfitLoss generalLedger)
        {
            var glr = new GeneralLedgerResponse
            {
                Code    = generalLedger.Code,
                Name    = generalLedger.Name,
                VatName = generalLedger.Financials.Vatcode.Name,
                VatType = generalLedger.Financials.Vatcode.Type.ToString()
            };

            glr.Type = generalLedger.Type;
            return(glr);
        }
예제 #7
0
        /// <summary>
        /// 新增益损信息
        /// </summary>
        /// <param name="recordId">记录Id</param>
        /// <param name="targetType">目标类型</param>
        /// <param name="category">分类</param>
        /// <param name="quantity">数量</param>
        /// <param name="remark">备注</param>
        /// <param name="creator">创建人</param>
        public void Add(string recordId, string targetType, string category, decimal quantity, string remark, string creator)
        {
            using (DbConnection conn = DbHelper.CreateConnection())
            {
                DbTransaction trans = null;
                try
                {
                    conn.Open();
                    trans = conn.BeginTransaction();
                    if (trans == null)
                    {
                        throw new ArgumentNullException("DbTransaction");
                    }
                    if (targetType == ProfitLossTargetType.Purchase)
                    {
                        Purchase purchase = this.purchaseService.Select(trans, recordId);
                        purchase.AddProfitLoss(category, quantity);
                        if (purchase.Inventory < 0)
                        {
                            throw new EasySoftException(BusinessResource.Purchase_LowStocks);
                        }
                        this.purchaseService.Update(trans, purchase);
                    }
                    else if (targetType == ProfitLossTargetType.Sale)
                    {
                        // 销售
                        throw new NotSupportedException();
                    }
                    else
                    {
                        throw new NotSupportedException();
                    }

                    ProfitLoss entity = new ProfitLoss();
                    entity.Create(recordId, targetType, category, quantity, remark, creator);
                    this.profitLossRepository.Insert(trans, entity);

                    trans.Commit();
                }
                catch
                {
                    if (trans != null)
                    {
                        trans.Rollback();
                    }
                    throw;
                }
            }
        }
예제 #8
0
        public TResult ReadDimension <TResult>(string code) where TResult : class
        {
            var resultType = typeof(TResult);

            var dimensionCommand = new ReadDimension
            {
                Office   = _session.Office,
                ReadType = "dimensions",
                Code     = code
            };

            if (resultType == typeof(Customer))
            {
                dimensionCommand.Type = "DEB";
                var dimensionResponse = _processXml.Process(dimensionCommand.ToXml());
                return(Customer.FromXml(dimensionResponse) as TResult);
            }

            if (resultType == typeof(Supplier))
            {
                dimensionCommand.Type = "CRD";
                var dimensionResponse = _processXml.Process(dimensionCommand.ToXml());
                return(Supplier.FromXml(dimensionResponse) as TResult);
            }

            if (resultType == typeof(BalanceSheet))
            {
                dimensionCommand.Type = "BAS";
                var dimensionResponse = _processXml.Process(dimensionCommand.ToXml());
                return(BalanceSheet.FromXml(dimensionResponse) as TResult);
            }

            if (resultType == typeof(ProfitLoss))
            {
                dimensionCommand.Type = "PNL";
                var dimensionResponse = _processXml.Process(dimensionCommand.ToXml());
                return(ProfitLoss.FromXml(dimensionResponse) as TResult);
            }

            if (resultType == typeof(CostCenter))
            {
                dimensionCommand.Type = "KPL";
                var dimensionResponse = _processXml.Process(dimensionCommand.ToXml());
                return(CostCenter.FromXml(dimensionResponse) as TResult);
            }

            return(default(TResult));
        }
        public void Calculate()
        {
            // do your calculations...
            var data = _context.ProfitLosses.FirstOrDefault(x => x.CreatedAt.ToShortDateString().Equals(DateTime.Now.ToShortDateString()));

            var materialsUsedTodayTotalPrice = _context.DailyMaterialsUsed
                                               .Where(x => x.CreatedAt.ToShortDateString().Equals(DateTime.Now.ToShortDateString()))
                                               .Sum(x => x.TotalPrice);

            var soldItemsTotalPriceToday = _context.Sales.Where(x => x.CreatedAt.ToShortDateString().Equals(DateTime.Now.ToShortDateString()))
                                           .Sum(x => x.TotalAmount);

            var ProfitLoss = soldItemsTotalPriceToday - materialsUsedTodayTotalPrice;



            var model = new ProfitLoss {
                ProfitOrLoss = ProfitLoss
            };

            model.TotalMaterialUsedToday = materialsUsedTodayTotalPrice;
            model.TotalSaledToday        = soldItemsTotalPriceToday;


            if (data != null && data.CreatedAt.ToShortDateString().Equals(DateTime.Now.ToShortDateString()))
            {
                data.TotalMaterialUsedToday = materialsUsedTodayTotalPrice;
                data.TotalSaledToday        = soldItemsTotalPriceToday;
                data.ProfitOrLoss           = ProfitLoss;

                _context.ProfitLosses.Update(data);
            }
            else
            {
                _context.ProfitLosses.Add(model);
            }

            _context.SaveChanges();



            //return RedirectToAction ("Index");
        }
예제 #10
0
 public void FromCustomObject(SqlConnection con, IntPtr pUdt)
 {
     SqlUdt.SetValue(con, pUdt, "ID", ID.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "CheckID", CheckID.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "WarehouseNo", WarehouseNo.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "HouseNo", HouseNo.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "AreaNo", AreaNo.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "MaterialNo", MaterialNo.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "MaterialDesc", MaterialDesc.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "AccountQty", AccountQty.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "ScanQty", ScanQty.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "Status", Status.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "StockTime", StockTime.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "Operator", Operator.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "OperationTime", OperationTime.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "ProfitLoss", ProfitLoss.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "DifferenceQty", DifferenceQty.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "IsDel", IsDel.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "Creater", Creater.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "CreateTime", CreateTime.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "Modifyer", Modifyer.ToSqlValue());
     SqlUdt.SetValue(con, pUdt, "ModifyTime", ModifyTime.ToSqlValue());
 }
        /// <summary>
        /// Edit profitloss details by id.
        /// </summary>
        /// <param name="id">Profitloss Id</param>
        /// <returns>The profit loss details view</returns>
        public ActionResult ProfitLossEdit(int id)
        {
            MODEL.ProfitLoss profitloss = new ProfitLoss();
            try
            {
                ProfitLossService profitlossService = new ProfitLossService();

                //Get P&L details
                ProfitLossVO profitlossVO = profitlossService.GetPandLbyId(id);
                if (profitlossVO == null)
                {
                    ModelState.AddModelError("", String.Format(Constants.ITEM_NOT_FOUND, Constants.PROFITANDLOSS));
                }
                else
                {
                    profitloss = new ProfitLoss(profitlossVO);
                }
            }
            catch (Exception e)
            {
                ModelState.AddModelError("", e.Message);
            }
            return(PartialView("ProfitLossDetails", profitloss));
        }
예제 #12
0
        public void UpdateValues(Double openPrice, Double currentPrice)
        {
            //cacluate individual position daily and inception Gain/Loss values and percentages
            //keep track of direction of last trade for formatting purposes on UI

            ProfitLoss dpl = EquityCalculator.GetProfitLoss(openPrice, currentPrice);
            ProfitLoss ipl = EquityCalculator.GetProfitLoss(_purchasePrice, currentPrice);

            if (_dataLoaded)
            {
                if (_currentPrice < currentPrice)
                {
                    _direction = 1;
                }
                else if (_currentPrice > currentPrice)
                {
                    _direction = -1;
                }
                else
                {
                    _direction = 0;
                }
            }

            _openPrice             = openPrice;
            _currentPrice          = currentPrice;
            _dayGainLoss           = dpl.ValueChange;
            _dayGainLossPercentage = dpl.PercentChange;
            _dayGainLossTotal      = _dayGainLoss * _quantity;

            _inceptionGainLoss           = ipl.ValueChange;
            _inceptionGainLossPercentage = ipl.PercentChange;
            _inceptionGainLossTotal      = _inceptionGainLoss * _quantity;

            _dataLoaded = true;
        }
예제 #13
0
        /// <summary>
        /// Posts the calculated average.
        /// </summary>
        /// <param name="selectedUser">The selected user.</param>
        /// <param name="newPrice">The new price.</param>
        /// <param name="quantity">The quantity.</param>
        /// <param name="multiplier">The multiplier.</param>
        /// <returns></returns>
        public async Task <Average> PostCalculatedAverage(object selectedUser, double newPrice, double quantity, double multiplier, Guid transactionId)
        {
            double totalPrice;
            double totalQuantity;
            double averagePrice;

            IsBalanceNegative = false;

            var avgResult = await tmsService.GetSpecificAverageData(selectedUser.ToString(), ShareName.ToUpper());

            if (avgResult != null)
            {
                var previousAvg        = avgResult.AveragePrice;
                var previousQty        = avgResult.Quantity;
                var totalPreviousPrice = previousAvg * previousQty;
                totalQuantity = previousQty + quantity;
                if (totalQuantity > 0)
                {
                    if (multiplier == 1)
                    {
                        averagePrice = (totalPreviousPrice + newPrice) / totalQuantity;
                    }
                    else
                    {
                        averagePrice = (totalPreviousPrice - newPrice) / totalQuantity;
                    }
                    totalPrice = totalQuantity * averagePrice;
                }
                else if (totalQuantity == 0)
                {
                    var    profitLossValue = newPrice - avgResult.TotalPrice;
                    string pLIdentifier;
                    if (profitLossValue > 0)
                    {
                        pLIdentifier = "Profit";
                    }
                    else if (profitLossValue < 0)
                    {
                        pLIdentifier = "Loss";
                    }
                    else
                    {
                        pLIdentifier = "Even";
                    }
                    profitLossValue = Math.Abs(profitLossValue);
                    var postPL = new ProfitLoss()
                    {
                        TransactionId        = transactionId,
                        Company              = avgResult.ShareName,
                        Date                 = DateTime.UtcNow.ToString(),
                        Name                 = selectedUser.ToString(),
                        Price                = profitLossValue,
                        ProfitLossIdentifier = pLIdentifier,
                    };
                    await tmsService.LogProfitLoss(postPL);

                    var currentBalance = await tmsService.GetPreviousBalanceDetails(selectedUser.ToString());

                    var balanceDetails = new Balance()
                    {
                        TotalBalance = currentBalance.TotalBalance + (newPrice - avgResult.TotalPrice)
                    };
                    await tmsService.PutUpdatedBalanceDetails(balanceDetails, selectedUser.ToString());

                    return(null);
                }
                else
                {
                    IsBalanceNegative = true;
                    return(null);
                }
            }
            else
            {
                totalQuantity = quantity;
                totalPrice    = newPrice;
                averagePrice  = newPrice / totalQuantity;
            }
            var postAvg = new Average()
            {
                TotalPrice   = totalPrice,
                Quantity     = totalQuantity,
                ShareName    = this.ShareName.ToUpper(),
                AveragePrice = averagePrice
            };

            return(postAvg);
        }
예제 #14
0
 public SymbolProperties()
 {
     profitLoss = new ProfitLossDefault(this);
 }
예제 #15
0
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                var hashCode = 41;
                // Suitable nullity checks etc, of course :)

                hashCode = hashCode * 59 + Direction.GetHashCode();
                if (ReduceOnly != null)
                {
                    hashCode = hashCode * 59 + ReduceOnly.GetHashCode();
                }
                if (Triggered != null)
                {
                    hashCode = hashCode * 59 + Triggered.GetHashCode();
                }
                if (OrderId != null)
                {
                    hashCode = hashCode * 59 + OrderId.GetHashCode();
                }
                if (Price != null)
                {
                    hashCode = hashCode * 59 + Price.GetHashCode();
                }

                hashCode = hashCode * 59 + TimeInForce.GetHashCode();
                if (Api != null)
                {
                    hashCode = hashCode * 59 + Api.GetHashCode();
                }

                hashCode = hashCode * 59 + OrderState.GetHashCode();
                if (Implv != null)
                {
                    hashCode = hashCode * 59 + Implv.GetHashCode();
                }

                hashCode = hashCode * 59 + Advanced.GetHashCode();
                if (PostOnly != null)
                {
                    hashCode = hashCode * 59 + PostOnly.GetHashCode();
                }
                if (Usd != null)
                {
                    hashCode = hashCode * 59 + Usd.GetHashCode();
                }
                if (StopPrice != null)
                {
                    hashCode = hashCode * 59 + StopPrice.GetHashCode();
                }

                hashCode = hashCode * 59 + OrderType.GetHashCode();
                if (LastUpdateTimestamp != null)
                {
                    hashCode = hashCode * 59 + LastUpdateTimestamp.GetHashCode();
                }

                hashCode = hashCode * 59 + OriginalOrderType.GetHashCode();
                if (MaxShow != null)
                {
                    hashCode = hashCode * 59 + MaxShow.GetHashCode();
                }
                if (ProfitLoss != null)
                {
                    hashCode = hashCode * 59 + ProfitLoss.GetHashCode();
                }
                if (IsLiquidation != null)
                {
                    hashCode = hashCode * 59 + IsLiquidation.GetHashCode();
                }
                if (FilledAmount != null)
                {
                    hashCode = hashCode * 59 + FilledAmount.GetHashCode();
                }
                if (Label != null)
                {
                    hashCode = hashCode * 59 + Label.GetHashCode();
                }
                if (Commission != null)
                {
                    hashCode = hashCode * 59 + Commission.GetHashCode();
                }
                if (Amount != null)
                {
                    hashCode = hashCode * 59 + Amount.GetHashCode();
                }

                hashCode = hashCode * 59 + Trigger.GetHashCode();
                if (InstrumentName != null)
                {
                    hashCode = hashCode * 59 + InstrumentName.GetHashCode();
                }
                if (CreationTimestamp != null)
                {
                    hashCode = hashCode * 59 + CreationTimestamp.GetHashCode();
                }
                if (AveragePrice != null)
                {
                    hashCode = hashCode * 59 + AveragePrice.GetHashCode();
                }
                return(hashCode);
            }
        }
예제 #16
0
        /// <summary>
        /// Returns true if Order instances are equal
        /// </summary>
        /// <param name="other">Instance of Order to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Order other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     Direction == other.Direction ||

                     Direction.Equals(other.Direction)
                     ) &&
                 (
                     ReduceOnly == other.ReduceOnly ||
                     ReduceOnly != null &&
                     ReduceOnly.Equals(other.ReduceOnly)
                 ) &&
                 (
                     Triggered == other.Triggered ||
                     Triggered != null &&
                     Triggered.Equals(other.Triggered)
                 ) &&
                 (
                     OrderId == other.OrderId ||
                     OrderId != null &&
                     OrderId.Equals(other.OrderId)
                 ) &&
                 (
                     Price == other.Price ||
                     Price != null &&
                     Price.Equals(other.Price)
                 ) &&
                 (
                     TimeInForce == other.TimeInForce ||

                     TimeInForce.Equals(other.TimeInForce)
                 ) &&
                 (
                     Api == other.Api ||
                     Api != null &&
                     Api.Equals(other.Api)
                 ) &&
                 (
                     OrderState == other.OrderState ||

                     OrderState.Equals(other.OrderState)
                 ) &&
                 (
                     Implv == other.Implv ||
                     Implv != null &&
                     Implv.Equals(other.Implv)
                 ) &&
                 (
                     Advanced == other.Advanced ||

                     Advanced.Equals(other.Advanced)
                 ) &&
                 (
                     PostOnly == other.PostOnly ||
                     PostOnly != null &&
                     PostOnly.Equals(other.PostOnly)
                 ) &&
                 (
                     Usd == other.Usd ||
                     Usd != null &&
                     Usd.Equals(other.Usd)
                 ) &&
                 (
                     StopPrice == other.StopPrice ||
                     StopPrice != null &&
                     StopPrice.Equals(other.StopPrice)
                 ) &&
                 (
                     OrderType == other.OrderType ||

                     OrderType.Equals(other.OrderType)
                 ) &&
                 (
                     LastUpdateTimestamp == other.LastUpdateTimestamp ||
                     LastUpdateTimestamp != null &&
                     LastUpdateTimestamp.Equals(other.LastUpdateTimestamp)
                 ) &&
                 (
                     OriginalOrderType == other.OriginalOrderType ||

                     OriginalOrderType.Equals(other.OriginalOrderType)
                 ) &&
                 (
                     MaxShow == other.MaxShow ||
                     MaxShow != null &&
                     MaxShow.Equals(other.MaxShow)
                 ) &&
                 (
                     ProfitLoss == other.ProfitLoss ||
                     ProfitLoss != null &&
                     ProfitLoss.Equals(other.ProfitLoss)
                 ) &&
                 (
                     IsLiquidation == other.IsLiquidation ||
                     IsLiquidation != null &&
                     IsLiquidation.Equals(other.IsLiquidation)
                 ) &&
                 (
                     FilledAmount == other.FilledAmount ||
                     FilledAmount != null &&
                     FilledAmount.Equals(other.FilledAmount)
                 ) &&
                 (
                     Label == other.Label ||
                     Label != null &&
                     Label.Equals(other.Label)
                 ) &&
                 (
                     Commission == other.Commission ||
                     Commission != null &&
                     Commission.Equals(other.Commission)
                 ) &&
                 (
                     Amount == other.Amount ||
                     Amount != null &&
                     Amount.Equals(other.Amount)
                 ) &&
                 (
                     Trigger == other.Trigger ||

                     Trigger.Equals(other.Trigger)
                 ) &&
                 (
                     InstrumentName == other.InstrumentName ||
                     InstrumentName != null &&
                     InstrumentName.Equals(other.InstrumentName)
                 ) &&
                 (
                     CreationTimestamp == other.CreationTimestamp ||
                     CreationTimestamp != null &&
                     CreationTimestamp.Equals(other.CreationTimestamp)
                 ) &&
                 (
                     AveragePrice == other.AveragePrice ||
                     AveragePrice != null &&
                     AveragePrice.Equals(other.AveragePrice)
                 ));
        }
예제 #17
0
        /// <summary>
        /// Returns true if Settlement instances are equal
        /// </summary>
        /// <param name="other">Instance of Settlement to be compared</param>
        /// <returns>Boolean</returns>
        public bool Equals(Settlement other)
        {
            if (other is null)
            {
                return(false);
            }
            if (ReferenceEquals(this, other))
            {
                return(true);
            }

            return
                ((
                     SessionProfitLoss == other.SessionProfitLoss ||
                     SessionProfitLoss != null &&
                     SessionProfitLoss.Equals(other.SessionProfitLoss)
                     ) &&
                 (
                     MarkPrice == other.MarkPrice ||
                     MarkPrice != null &&
                     MarkPrice.Equals(other.MarkPrice)
                 ) &&
                 (
                     Funding == other.Funding ||
                     Funding != null &&
                     Funding.Equals(other.Funding)
                 ) &&
                 (
                     Socialized == other.Socialized ||
                     Socialized != null &&
                     Socialized.Equals(other.Socialized)
                 ) &&
                 (
                     SessionBankrupcy == other.SessionBankrupcy ||
                     SessionBankrupcy != null &&
                     SessionBankrupcy.Equals(other.SessionBankrupcy)
                 ) &&
                 (
                     Timestamp == other.Timestamp ||
                     Timestamp != null &&
                     Timestamp.Equals(other.Timestamp)
                 ) &&
                 (
                     ProfitLoss == other.ProfitLoss ||
                     ProfitLoss != null &&
                     ProfitLoss.Equals(other.ProfitLoss)
                 ) &&
                 (
                     Funded == other.Funded ||
                     Funded != null &&
                     Funded.Equals(other.Funded)
                 ) &&
                 (
                     IndexPrice == other.IndexPrice ||
                     IndexPrice != null &&
                     IndexPrice.Equals(other.IndexPrice)
                 ) &&
                 (
                     SessionTax == other.SessionTax ||
                     SessionTax != null &&
                     SessionTax.Equals(other.SessionTax)
                 ) &&
                 (
                     SessionTaxRate == other.SessionTaxRate ||
                     SessionTaxRate != null &&
                     SessionTaxRate.Equals(other.SessionTaxRate)
                 ) &&
                 (
                     InstrumentName == other.InstrumentName ||
                     InstrumentName != null &&
                     InstrumentName.Equals(other.InstrumentName)
                 ) &&
                 (
                     Position == other.Position ||
                     Position != null &&
                     Position.Equals(other.Position)
                 ) &&
                 (
                     Type == other.Type ||

                     Type.Equals(other.Type)
                 ));
        }
예제 #18
0
 public TransactionPairs(Func <double, double> currentPrice, ProfitLoss pnl, TransactionPairsBinary transactionPairs)
 {
     this.currentPrice     = currentPrice;
     profitLossCalculation = pnl;
     this.transactionPairs = transactionPairs;
 }
예제 #19
0
 public TransactionPairs(Func <double, double> currentPrice, ProfitLoss pnl)
 {
     this.currentPrice     = currentPrice;
     profitLossCalculation = pnl;
     this.transactionPairs = new TransactionPairsBinary(TradeData);
 }
        void ReleaseDesignerOutlets()
        {
            if (EntryDate != null)
            {
                EntryDate.Dispose();
                EntryDate = null;
            }

            if (EntryPrice != null)
            {
                EntryPrice.Dispose();
                EntryPrice = null;
            }

            if (EntrySetup != null)
            {
                EntrySetup.Dispose();
                EntrySetup = null;
            }

            if (EntrySize != null)
            {
                EntrySize.Dispose();
                EntrySize = null;
            }

            if (EntryType != null)
            {
                EntryType.Dispose();
                EntryType = null;
            }

            if (ExitDate != null)
            {
                ExitDate.Dispose();
                ExitDate = null;
            }

            if (ExitPrice != null)
            {
                ExitPrice.Dispose();
                ExitPrice = null;
            }

            if (Fees != null)
            {
                Fees.Dispose();
                Fees = null;
            }

            if (ProfitLoss != null)
            {
                ProfitLoss.Dispose();
                ProfitLoss = null;
            }

            if (StopLoss != null)
            {
                StopLoss.Dispose();
                StopLoss = null;
            }

            if (TakeProfit != null)
            {
                TakeProfit.Dispose();
                TakeProfit = null;
            }
        }
예제 #21
0
        /// <summary>
        /// Gets the hash code
        /// </summary>
        /// <returns>Hash code</returns>
        public override int GetHashCode()
        {
            unchecked // Overflow is fine, just wrap
            {
                var hashCode = 41;
                // Suitable nullity checks etc, of course :)
                if (SessionProfitLoss != null)
                {
                    hashCode = hashCode * 59 + SessionProfitLoss.GetHashCode();
                }
                if (MarkPrice != null)
                {
                    hashCode = hashCode * 59 + MarkPrice.GetHashCode();
                }
                if (Funding != null)
                {
                    hashCode = hashCode * 59 + Funding.GetHashCode();
                }
                if (Socialized != null)
                {
                    hashCode = hashCode * 59 + Socialized.GetHashCode();
                }
                if (SessionBankrupcy != null)
                {
                    hashCode = hashCode * 59 + SessionBankrupcy.GetHashCode();
                }
                if (Timestamp != null)
                {
                    hashCode = hashCode * 59 + Timestamp.GetHashCode();
                }
                if (ProfitLoss != null)
                {
                    hashCode = hashCode * 59 + ProfitLoss.GetHashCode();
                }
                if (Funded != null)
                {
                    hashCode = hashCode * 59 + Funded.GetHashCode();
                }
                if (IndexPrice != null)
                {
                    hashCode = hashCode * 59 + IndexPrice.GetHashCode();
                }
                if (SessionTax != null)
                {
                    hashCode = hashCode * 59 + SessionTax.GetHashCode();
                }
                if (SessionTaxRate != null)
                {
                    hashCode = hashCode * 59 + SessionTaxRate.GetHashCode();
                }
                if (InstrumentName != null)
                {
                    hashCode = hashCode * 59 + InstrumentName.GetHashCode();
                }
                if (Position != null)
                {
                    hashCode = hashCode * 59 + Position.GetHashCode();
                }

                hashCode = hashCode * 59 + Type.GetHashCode();
                return(hashCode);
            }
        }
예제 #22
0
 public Equity(Model model, Performance performance)
 {
     this.model       = model;
     this.performance = performance;
     equityProfitLoss = new ProfitLossEquity();
 }
예제 #23
0
 /// <summary>
 /// Logs the profit loss.
 /// </summary>
 /// <param name="profitLoss">The profit loss.</param>
 public async Task LogProfitLoss(ProfitLoss profitLoss)
 {
     await firebase
     .Child(Constants.TableNameProfitLoss).Child(profitLoss.TransactionId.ToString())
     .PutAsync(profitLoss);
 }