public void ReturnStaticListOfPortfolios() { IFundProcessor fundProcessor = new FundProcessor(); var portfolio = new PortfolioVM { Positions = new List <PositionVM> { new PositionVM { Code = "NL0000009165", Name = "Heineken", Value = 12345 }, new PositionVM { Code = "NL0000287100", Name = "Optimix Mix Fund", Value = 23456 }, new PositionVM { Code = "LU0035601805", Name = "DP Global Strategy L High", Value = 34567 }, new PositionVM { Code = "NL0000292332", Name = "Rabobank Core Aandelen Fonds T2", Value = 45678 }, new PositionVM { Code = "LU0042381250", Name = "Morgan Stanley Invest US Gr Fnd", Value = 56789 } } }; fundProcessor.GetPortfolio().Should().NotBeNull().And.BeAssignableTo(typeof(PortfolioVM)).And.BeEquivalentTo(portfolio); }
private void OnManualOpenDirectionChange(PortfolioVM portfVm) { if (CurrentPortfolio == portfVm) { OnResetSetting(); } }
public void ShouldReturnStaticListOfPortfolios() { IFundsProcessor fundProcessor = new FundProcessor(); var portfolio = new PortfolioVM { Positions = new List <PositionVM> { new PositionVM { Code = "NL0000287100", Name = "Henekens", Value = 12345 }, new PositionVM { Code = "NL000029332", Name = "Optimix", Value = 23456 }, new PositionVM { Code = "NL0000440584", Name = "DP Global", Value = 34567 }, new PositionVM { Code = "NL0000440588", Name = "Rabobank core", Value = 45678 }, new PositionVM { Code = "inc005", Name = "Morgan Stanley", Value = 56789 } } }; fundProcessor.GetPortfolio().Should().NotBeNull().And.BeAssignableTo(typeof(PortfolioVM)).And.BeEquivalentTo(portfolio); }
/// <summary> /// Method to get static Portfolio object and return back to Client. /// </summary> /// <returns></returns> public PortfolioVM GetPortfolio() { PortfolioVM portfolio = null; try { portfolio = new PortfolioVM { Positions = new List <PositionVM> { new PositionVM { Code = "NL0000287100", Name = "Henekens", Value = 12345 }, new PositionVM { Code = "NL000029332", Name = "Optimix", Value = 23456 }, new PositionVM { Code = "NL0000440584", Name = "DP Global", Value = 34567 }, new PositionVM { Code = "NL0000440588", Name = "Rabobank core", Value = 45678 }, new PositionVM { Code = "inc005", Name = "Morgan Stanley", Value = 56789 } } }; } catch (Exception e) { //Log here if any error and throw to client throw e; } return(portfolio); }
private void PublishPortfolioSelected(DataRecord dr) { if (dr != null) { PortfolioVM portf = dr.DataItem as PortfolioVM; EventAgg.GetEvent <PortfolioSelectedEvent>().Publish(portf); } }
public void GetPortfolio_ShouldReturnPositionVM() { //Act PortfolioVM portfolioVM = portfolioServices.GetPortfolio(path); //Assert portfolioVM.Should().NotBeNull(); }
public PartialViewResult CreateNewPortfolio() { PortfolioVM vm = new PortfolioVM { IsCreateMode = true }; return(PartialView("Crud/_ManagePortfolio", vm)); }
public void MockPortfolioService() { portfolioServicesMock = new Mock <IPortfolioServices>(); portfolioVM = new PortfolioVM(); portfolioServicesMock.Setup(x => x.GetPortfolio(It.IsAny <string>())).Returns(portfolioVM); configurationMock = new Mock <IConfiguration>(); configurationMock.Setup(x => x.GetSection(It.IsAny <string>())).Returns(new Mock <IConfigurationSection>().Object); }
public IActionResult Index() { PortfolioVM portfolioVM = new PortfolioVM { projectCategories = _context.projectCategories.Where(c => c.Status).ToList(), projects = _context.projects.Where(p => p.ProjectCategory.Status && p.Status).OrderByDescending(p => p.Date) }; return(View(portfolioVM)); }
public void SetPortfolio(PortfolioVM portfVm) { this.AccountId = portfVm.AccountId; this.PortfolioID = portfVm.Id; this.StrategyType = StrategySetting.GetDisplayStrategyName(portfVm.StrategySetting.Name); this.CurrentPortfolio = portfVm; BeforeCopySettings(); this.Settings.CopyFrom(portfVm.StrategySetting); AfterCopySettings(); OnSetPortfolio(portfVm); }
public void UpdatePortfolio(PortfolioVM pVM) { var portfolio = new PBPortfolio(); portfolio.Name = pVM.Name; portfolio.HedgeDelay = pVM.Delay; portfolio.Threshold = pVM.Threshold; portfolio.Hedging = pVM.Hedging; portfolio.HedgeVolume = pVM.HedgeVolume; MessageWrapper.SendMessage((uint)BusinessMessageID.MSG_ID_MODIFY_PORTFOLIO, portfolio); }
public void ValidateFundOfMandatesReturnsPositionVM() { IFundProcessor fundsProcessor = new FundProcessor(); string filePath = "..\\..\\..\\TestData\\FundsOfMandatesData.xml"; List <FundOfMandates> Result = fundsProcessor.ReadFundOfMandateFile(filePath); PortfolioVM portfolioVM = fundsProcessor.GetPortfolio(); PositionVM positionVM = null; positionVM = fundsProcessor.GetCalculatedMandates(portfolioVM.Positions.ElementAt(1), Result.ElementAt(1)); positionVM.Should().NotBeNull().And.BeOfType <PositionVM>(); }
private void OnPortfolioSelected(PortfolioVM portfVm) { if (portfVm == null) { this.DataContext = null; return; } StrategySettingVM viewModel = null; if (portfVm.StrategySetting.Name == StrategySetting.ArbitrageStrategyName) { viewModel = ServiceLocator.Current.GetInstance <ArbitrageSettingsVM>(); } else if (portfVm.StrategySetting.Name == StrategySetting.ChangePositionStrategyName) { viewModel = ServiceLocator.Current.GetInstance <ChangePositionSettingsVM>(); } else if (portfVm.StrategySetting.Name == StrategySetting.ScalperStrategyName) { viewModel = ServiceLocator.Current.GetInstance <ScalperSettingVM>(); } else if (portfVm.StrategySetting.Name == StrategySetting.ManualStrategyName) { viewModel = ServiceLocator.Current.GetInstance <ManualStrategySettingVM>(); } else if (portfVm.StrategySetting.Name == StrategySetting.MACDHistSlopeStrategyName) { viewModel = ServiceLocator.Current.GetInstance <MACDHistSlopeSettingsVM>(); } else if (portfVm.StrategySetting.Name == StrategySetting.WMATrendStrategyName) { viewModel = ServiceLocator.Current.GetInstance <WMATrendSettingsVM>(); } else if (portfVm.StrategySetting.Name == StrategySetting.LinerRegressionStrategyName) { viewModel = ServiceLocator.Current.GetInstance <LinerRegSettingsVM>(); } else if (portfVm.StrategySetting.Name == StrategySetting.ASCTrendStrategyName) { viewModel = ServiceLocator.Current.GetInstance <ASCTrendSettingsVM>(); } else if (portfVm.StrategySetting.Name == StrategySetting.RangeTrendStrategyName) { viewModel = ServiceLocator.Current.GetInstance <RangeTrendSettingsVM>(); } if (viewModel != null) { viewModel.SetPortfolio(portfVm); this.DataContext = viewModel; } }
public void SetPortfolio(PortfolioVM portfVm) { isSettingPortfolio = true; this.AccountId = portfVm.AccountId; this.PortfolioID = portfVm.Id; this.StrategyType = GetStrategyDisplayName(portfVm.StrategySetting.Name); OnSetPortfolio(portfVm); this.CurrentPortfolio = portfVm; isSettingPortfolio = false; }
protected override void OnSetPortfolio(PortfolioVM portfVm) { ArbitrageStrategySetting strategySettings = (ArbitrageStrategySetting)portfVm.StrategySetting; _isInitializing = true; this.PositionDirection = strategySettings.Direction; this.OpenCondition = strategySettings.OpenCondition; this.OpenThreshold = strategySettings.OpenThreshold; this.StopGainCondition = strategySettings.StopGainCondition; this.StopGainThreshold = strategySettings.StopGainThreshold; this.StopLossCondition = strategySettings.StopLossCondition; this.StopLossThreshold = strategySettings.StopLossThreshold; _isInitializing = false; }
public override DataTemplate SelectTemplate(object item, DependencyObject container) { PortfolioVM portfVm = item as PortfolioVM; if (portfVm != null) { if (portfVm.StrategySetting.Name == StrategySetting.ArbitrageStrategyName) { return(ArbitrageTemplate); } else if (portfVm.StrategySetting.Name == StrategySetting.ChangePositionStrategyName) { return(ChangePositionTemplate); } else if (portfVm.StrategySetting.Name == StrategySetting.ScalperStrategyName) { return(ScalperTemplate); } else if (portfVm.StrategySetting.Name == StrategySetting.MACDHistSlopeStrategyName) { return(MACDHistSlopeTemplate); } else if (portfVm.StrategySetting.Name == StrategySetting.WMATrendStrategyName) { return(WMATrendTemplate); } else if (portfVm.StrategySetting.Name == StrategySetting.LinerRegressionStrategyName) { return(LinerRegressionTemplate); } else if (portfVm.StrategySetting.Name == StrategySetting.ASCTrendStrategyName) { return(ASCTrendTemplate); } else if (portfVm.StrategySetting.Name == StrategySetting.RangeTrendStrategyName) { return(RangeTrendTemplate); } else if (portfVm.StrategySetting.Name == StrategySetting.ManualStrategyName) { return(ManualTemplate); } else if (portfVm.StrategySetting.Name == StrategySetting.QuickScoreStrategyName) { return(QuickScoreTemplate); } } return(null); }
public ActionResult UpdatePortfolio(int portfolioId) { Portfolio portfolio = CurrentUser.Portfolios.FirstOrDefault(x => x.PortfolioId == portfolioId); if (portfolio == null) { return(Json(ResultsItem.Error("Unable to find the correct portfolio associated with logged in user."))); } PortfolioVM vm = new PortfolioVM { Portfolio = portfolio, IsCreateMode = false }; return(PartialView("Crud/_ManagePortfolio", vm)); }
public void ShouldThrowArgumentExceptionIfPortfolioReturnedIsNull() { portfolioProcessor = Substitute.For <IPortfolioProcessor>(); config = Substitute.For <IConfiguration>(); loggerFactory = Substitute.For <ILoggerFactory>(); config["FundsOfMandatesFile"] = "FundOfMandatesDataV1.xml"; loggerFactory.ClearReceivedCalls(); PortfolioVM portfolio = null; portfolioProcessor.GetUpdatedPortfolio(Arg.Any <string>()).Returns(portfolio); PortfolioController controller = new PortfolioController(portfolioProcessor, config, loggerFactory); Func <PositionVM[]> func = () => controller.Get(); func.Should().Throw <ArgumentException>("Because GetPortfolio returns null here and client code mus throw an Argument Exception").WithMessage("Necessary Portfolio is not available to display"); }
public async Task <PartialViewResult> GetPortfolioList(bool isUpdated = false) { if (isUpdated) { CurrentUser.Portfolios = await CryptoLogic.GetAllUserPortfolioAsync(CurrentUser); SubmitCurrentUserUpdate(); } PortfolioVM vm = new PortfolioVM { Portfolios = CurrentUser.Portfolios }; return(PartialView("Crud/_PortfolioList", vm)); }
public void FillMandate_ShouldAddMandate_WhenInstrumentCodeMatches() { //Arrange PortfolioVM portfolioVM = new PortfolioVM(); portfolioVM.Positions.Add(new PositionVM() { Code = "NL0000287100", Name = "Optimix Mix Fund", Value = 23456 }); FundsOfMandatesData fundsOfMandatesData = portfolioServices.GetFundOfMandates(path); int expectedMandateCount = 4; //Act int actualMandateCount = portfolioServices.FillMandate(portfolioVM, fundsOfMandatesData).Positions[0].Mandates.Count; //Assert actualMandateCount.Should().Be(expectedMandateCount); }
public async Task <JsonResult> ExecutePortfolioChanges(PortfolioVM vm) { if (!ModelState.IsValid) { return(Json(ResultsItem.Error(ModelState.GetAllErrorsString()))); } int maxPortfolioAllowed = SubscriptionLogic.GetMaxAllowedPortfolioPerUser(CurrentUser.PTUserInfo.SubscriptionLevel); if (vm.IsCreateMode && CurrentUser.Portfolios.Count >= maxPortfolioAllowed) { return(Json(ResultsItem.Error($"We're sorry, you can only have {maxPortfolioAllowed} portfolios max for your subscription level: {CurrentUser.PTUserInfo.SubscriptionLevel.ToString()}"))); } var portfolioResultPair = vm.IsCreateMode ? (await CryptoLogic.InsertNewPortfolio(CurrentUser, vm.Portfolio.Name, vm.Portfolio.DisplayType, vm.Portfolio.IsDefault)) : CryptoLogic.UpdatePortfolio(vm.Portfolio.PortfolioId, vm.Portfolio.Name, vm.Portfolio.DisplayType, vm.Portfolio.IsDefault, CurrentUser); return(Json(portfolioResultPair.Result)); }
public void ShouldThrowExceptionIfPortfolioObjectDoesNowHavePositions() { portfolioProcessor = Substitute.For <IPortfolioProcessor>(); config = Substitute.For <IConfiguration>(); loggerFactory = Substitute.For <ILoggerFactory>(); config["FundsOfMandatesFile"] = "FundOfMandatesDataV1.xml"; loggerFactory.ClearReceivedCalls(); PortfolioVM portfolio = new PortfolioVM { Positions = null }; portfolioProcessor.GetUpdatedPortfolio(Arg.Any <string>()).Returns(portfolio); PortfolioController controller = new PortfolioController(portfolioProcessor, config, loggerFactory); Func <PositionVM[]> func = () => controller.Get(); func.Should().Throw <Exception>("Because GetPortfolio returns no Positions in Portfolio and client code must throw an exception").WithMessage("No Valid Positions found under portfolio."); }
public PortfolioVM GetUpdatedPortfolio(string fileName) { PortfolioVM portfolioVM = null; List <FundOfMandates> mandates = null; // IFundsProcessor fundProcessor = new FundProcessor(); //dependency injection is possible in these kind of cases portfolioVM = FundsProcessor.GetPortfolio(); mandates = FundsProcessor.ReadFundOfMandatesFile(fileName); portfolioVM.Positions.ForEach(position => { mandates.ForEach(fundofmandate => { position = FundsProcessor.GetCalculatedMandates(position, fundofmandate); }); }); return(portfolioVM); }
public void FillMandate_ShouldMatchMandates_WhenInstrumentCodeMatches() { //Arrange PortfolioVM portfolioVM = new PortfolioVM(); portfolioVM.Positions.Add(new PositionVM() { Code = "NL0000287100", Name = "Optimix Mix Fund", Value = 23456 }); List <MandateVM> expectedListOfMandates = new List <MandateVM>() { new MandateVM() { Name = "Robeco Factor Momentum Mandaat", Allocation = (decimal)0.355, Value = 8327 }, new MandateVM() { Name = "BNPP Factor Value Mandaat", Allocation = (decimal)0.383, Value = 8984 }, new MandateVM() { Name = "Robeco Factor Quality Mandaat", Allocation = (decimal)0.261, Value = 6122 }, new MandateVM() { Name = "Liquidity", Allocation = (decimal)0.001, Value = 23 }, }; FundsOfMandatesData fundsOfMandatesData = portfolioServices.GetFundOfMandates(path); //Act List <MandateVM> actualListOfMandates = portfolioServices.FillMandate(portfolioVM, fundsOfMandatesData).Positions[0].Mandates; MandateVM actualMandateVM = actualListOfMandates.Where(x => x.Name == "Robeco Factor Momentum Mandaat").FirstOrDefault(); //Assert actualListOfMandates.Should().BeEquivalentTo(expectedListOfMandates); actualMandateVM.Should().BeEquivalentTo(new MandateVM() { Name = "Robeco Factor Momentum Mandaat", Allocation = (decimal)0.355, Value = 8327 }); }
public override DataTemplate SelectTemplate(object item, DependencyObject container) { PortfolioVM portfVm = item as PortfolioVM; if (portfVm != null) { if (portfVm.StrategySetting.Name == StrategySetting.ArbitrageStrategyName) { return(ArbitrageTemplate); } else if (portfVm.StrategySetting.Name == StrategySetting.ChangePositionStrategyName) { return(ChangePositionTemplate); } else if (portfVm.StrategySetting.Name == StrategySetting.ScalperStrategyName) { return(ScalperTemplate); } } return(null); }
private async Task <PortfolioVM> GeneratePortfolioVM(PortfolioRequest request) { PortfolioVM vm = new PortfolioVM { ViewOtherUser = request.ViewOtherUser, ViewUser = request.ViewUser, Portfolios = request.ViewOtherUser ? request.ViewUser?.Portfolios : CurrentUser.Portfolios }; if (request.ViewOtherUser && request.ViewUser != null) { vm.SelectedPortfolio = request.PortfolioID = request.ViewUser.SelectedPortfolioID; vm.CoinsVM = await GenerateCoinsVM(request); } else if (CurrentUser.IsValidUser() || CurrentUser.IsDemoUser()) { request.PortfolioID = vm.Portfolios.FirstOrDefault(x => x.IsDefault)?.PortfolioId ?? vm.Portfolios.First().PortfolioId; vm.CoinsVM = await GenerateCoinsVM(request); } return(vm); }
public void ShouldReturnCorrectPortfolioObjectBackAndRunSuccessfully() { portfolioProcessor = Substitute.For <IPortfolioProcessor>(); config = Substitute.For <IConfiguration>(); loggerFactory = Substitute.For <ILoggerFactory>(); config["FundsOfMandatesFile"] = "FundOfMandatesDataV1.xml"; loggerFactory.ClearReceivedCalls(); var dummyPortfolio = new PortfolioVM { Positions = new List <PositionVM> { new PositionVM { Code = "NL0000287100", Name = "Henekens", Value = 12345 }, new PositionVM { Code = "NL000029332", Name = "Optimix", Value = 23456 }, new PositionVM { Code = "NL0000440584", Name = "DP Global", Value = 34567 }, new PositionVM { Code = "NL0000440588", Name = "Rabobank core", Value = 45678 }, new PositionVM { Code = "inc005", Name = "Morgan Stanley", Value = 56789 }, new PositionVM { Code = "inc005", Name = "Morgan Stanley", Value = 56789 } } }; portfolioProcessor.GetUpdatedPortfolio(Arg.Any <string>()).Returns(dummyPortfolio); PortfolioController controller = new PortfolioController(portfolioProcessor, config, loggerFactory); var httpResult = controller.Get(); httpResult.Should().HaveCount(6, "Because we passed 6 Positions in dummy return object"); }
private void OnPortfolioSelected(PortfolioVM porfVm) { StrategySettingVM viewModel = null; if (porfVm.StrategySetting.Name == StrategySetting.ArbitrageStrategyName) { viewModel = ServiceLocator.Current.GetInstance <ArbitrageSettingsVM>(); } else if (porfVm.StrategySetting.Name == StrategySetting.ChangePositionStrategyName) { viewModel = ServiceLocator.Current.GetInstance <ChangePositionSettingsVM>(); } else if (porfVm.StrategySetting.Name == StrategySetting.ScalperStrategyName) { viewModel = ServiceLocator.Current.GetInstance <ScalperSettingVM>(); } if (viewModel != null) { viewModel.SetPortfolio(porfVm); this.DataContext = viewModel; } }
public async Task <PartialViewResult> LoadPortfolioViewMode(PortfolioRequest request, string username, string portfolioName, bool coinsOnly = false) { if (string.IsNullOrEmpty(username) || string.IsNullOrEmpty(portfolioName)) { return(null); } request.ViewUser = new ViewUser { Username = username, PortfolioName = portfolioName, }; request.ViewUser.PortfolioName = Utilities.FormatPortfolioName(request.ViewUser.PortfolioName); request.ViewOtherUser = true; ResultsPair <ViewUser> viewUserResult = AuthorizationLogic.AuthorizeViewUser(request.ViewUser.Username, request.ViewUser.PortfolioName); if (!viewUserResult.Result.IsSuccess) { return(GeneratePartialViewError(viewUserResult.Result.Message)); } request.ViewUser = viewUserResult.Value; if (coinsOnly) { request.PortfolioID = request.ViewUser.SelectedPortfolioID; CoinsVM coinsVM = await GenerateCoinsVM(request); return(PartialView("_FullCoins", coinsVM)); } PortfolioVM vm = await GeneratePortfolioVM(request); return(PartialView("_Portfolio", vm)); }
public void FillMandate_ShouldNotAddMandateForEmptyFundsOfMandateData_WhenFundsOfMandateIsEmpty() { //Arrange PortfolioVM portfolioVM = new PortfolioVM(); portfolioVM.Positions.Add(new PositionVM() { Code = "NL0000009165", Name = "Heineken", Value = 12345 }); portfolioVM.Positions.Add(new PositionVM() { Code = "NL0000287100", Name = "Optimix Mix Fund", Value = 23456 }); portfolioVM.Positions.Add(new PositionVM() { Code = "LU0035601805", Name = "DP Global Strategy L High", Value = 34567 }); portfolioVM.Positions.Add(new PositionVM() { Code = "NL0000292332", Name = "Rabobank Core Aandelen Fonds T2", Value = 45678 }); portfolioVM.Positions.Add(new PositionVM() { Code = "LU0042381250", Name = "Morgan Stanley Invest US Gr Fnd", Value = 56789 }); FundsOfMandatesData fundsOfMandatesData = new FundsOfMandatesData(); //Act portfolioVM = portfolioServices.FillMandate(portfolioVM, fundsOfMandatesData); //Assert foreach (var position in portfolioVM.Positions) { position.Mandates.Count.Should().Be(0); } }