Exemplo n.º 1
0
        public static Investment FromType(InvestmentType investmentType, int exchangeId, string baseCurrency, string quoteCurrency, Account account)
        {
            if (investmentType == null)
            {
                throw new InvestingDomainException("InvestmentType must be provided when creating investment.");
            }

            return(new Investment(
                       Guid.NewGuid().ToString(),
                       investmentType.Id,
                       exchangeId,
                       baseCurrency,
                       quoteCurrency,
                       new Trace(),
                       account));
        }
Exemplo n.º 2
0
        public void ChangeInvestmentType(InvestmentType investmentType)
        {
            if (this._investmentStatusId != InvestmentStatus.Prepare.Id)
            {
                throw new InvestingDomainException("Investment's investmentType can only be change at prepare state.");
            }
            if (investmentType == null)
            {
                throw new InvestingDomainException("InvestmentType must be provided when changing investment type.");
            }


            if (this._investmentTypeId == InvestmentType.Backtesting.Id)
            {
                this.DateStarted    = null;
                this.DateClosed     = null;
                this.InitialBalance = 0;
                this.CurrentBalance = 0;
            }

            this._investmentTypeId = investmentType.Id;
        }