use of com.github.robozonky.api.strategies.LoanDescriptor in project robozonky by RoboZonky.
the class NaturalLanguageInvestmentStrategyTest method noLoansApplicable.
@Test
void noLoansApplicable() {
final MarketplaceFilter filter = MarketplaceFilter.of(MarketplaceFilterCondition.alwaysAccepting());
final ParsedStrategy p = new ParsedStrategy(DefaultPortfolio.PROGRESSIVE, Collections.singleton(filter));
final InvestmentStrategy s = new NaturalLanguageInvestmentStrategy(p);
final PortfolioOverview portfolio = mock(PortfolioOverview.class);
when(portfolio.getCzkAvailable()).thenReturn(p.getMinimumBalance());
when(portfolio.getCzkInvested()).thenReturn(p.getMaximumInvestmentSizeInCzk() - 1);
final Stream<RecommendedLoan> result = s.recommend(Collections.singletonList(new LoanDescriptor(mockLoan(2))), portfolio, new Restrictions());
assertThat(result).isEmpty();
}
use of com.github.robozonky.api.strategies.LoanDescriptor in project robozonky by RoboZonky.
the class NaturalLanguageInvestmentStrategyTest method nothingRecommendedDueToRatingOverinvested.
@Test
void nothingRecommendedDueToRatingOverinvested() {
final ParsedStrategy p = new ParsedStrategy(DefaultPortfolio.EMPTY, Collections.emptySet());
final InvestmentStrategy s = new NaturalLanguageInvestmentStrategy(p);
final PortfolioOverview portfolio = mock(PortfolioOverview.class);
when(portfolio.getCzkAvailable()).thenReturn(p.getMinimumBalance());
when(portfolio.getCzkInvested()).thenReturn(p.getMaximumInvestmentSizeInCzk() - 1);
when(portfolio.getShareOnInvestment(any())).thenReturn(BigDecimal.ZERO);
final Loan l = mockLoan(1000);
final Stream<RecommendedLoan> result = s.recommend(Collections.singletonList(new LoanDescriptor(l)), portfolio, new Restrictions());
assertThat(result).isEmpty();
}
use of com.github.robozonky.api.strategies.LoanDescriptor in project robozonky by RoboZonky.
the class NaturalLanguageInvestmentStrategyTest method unacceptablePortfolioDueToLowBalance.
@Test
void unacceptablePortfolioDueToLowBalance() {
final ParsedStrategy p = new ParsedStrategy(DefaultPortfolio.EMPTY);
final InvestmentStrategy s = new NaturalLanguageInvestmentStrategy(p);
final PortfolioOverview portfolio = mock(PortfolioOverview.class);
when(portfolio.getCzkAvailable()).thenReturn(p.getMinimumBalance() - 1);
final Stream<RecommendedLoan> result = s.recommend(Collections.singletonList(new LoanDescriptor(mockLoan(2))), portfolio, new Restrictions());
assertThat(result).isEmpty();
}
use of com.github.robozonky.api.strategies.LoanDescriptor in project robozonky by RoboZonky.
the class ParsedStrategyTest method exitButNoSelloff.
@Test
void exitButNoSelloff() {
final DefaultPortfolio portfolio = DefaultPortfolio.EMPTY;
final DefaultValues values = new DefaultValues(portfolio);
// exit active, no sell-off yet
values.setExitProperties(new ExitProperties(LocalDate.now().plusMonths(6)));
final ParsedStrategy strategy = new ParsedStrategy(values, Collections.emptyList(), Collections.emptyMap(), new FilterSupplier(values, Collections.emptySet(), Collections.emptySet(), Collections.emptySet()));
// no loan or participation should be bought; every investment should be sold
final Loan loanUnder = mockLoan(1000);
final Loan loanOver = Loan.custom().setId(2).setAmount(2000).setTermInMonths(84).build();
final LoanDescriptor ldOver = new LoanDescriptor(loanOver);
final LoanDescriptor ldUnder = new LoanDescriptor(loanUnder);
final ParticipationDescriptor pdOver = mockParticipationDescriptor(loanOver);
final ParticipationDescriptor pdUnder = mockParticipationDescriptor(loanUnder);
final Investment iUnder = Investment.fresh((MarketplaceLoan) loanUnder, 200);
final InvestmentDescriptor idUnder = new InvestmentDescriptor(iUnder, loanUnder);
final Investment iOver = Investment.fresh((MarketplaceLoan) loanOver, 200);
final InvestmentDescriptor idOver = new InvestmentDescriptor(iOver, loanOver);
assertSoftly(softly -> {
softly.assertThat(strategy.getApplicableLoans(Arrays.asList(ldOver, ldUnder))).containsOnly(ldUnder);
softly.assertThat(strategy.getApplicableParticipations(Arrays.asList(pdOver, pdUnder))).containsOnly(pdUnder);
softly.assertThat(strategy.getApplicableInvestments(Arrays.asList(idOver, idUnder))).isEmpty();
});
}
use of com.github.robozonky.api.strategies.LoanDescriptor in project robozonky by RoboZonky.
the class ParsedStrategyTest method construct.
@Test
void construct() {
final DefaultPortfolio portfolio = DefaultPortfolio.PROGRESSIVE;
// test for default values
final ParsedStrategy strategy = new ParsedStrategy(portfolio);
assertSoftly(softly -> {
softly.assertThat(strategy.getMinimumBalance()).isEqualTo(Defaults.MINIMUM_INVESTMENT_IN_CZK);
softly.assertThat(strategy.getMaximumInvestmentSizeInCzk()).isEqualTo(Integer.MAX_VALUE);
softly.assertThat(strategy.getMinimumShare(Rating.A)).isEqualTo(portfolio.getDefaultShare(Rating.A));
softly.assertThat(strategy.getMaximumShare(Rating.B)).isEqualTo(portfolio.getDefaultShare(Rating.B));
softly.assertThat(strategy.getMinimumInvestmentSizeInCzk(Rating.C)).isEqualTo(0);
softly.assertThat(strategy.getMaximumInvestmentSizeInCzk(Rating.D)).isEqualTo(Defaults.MAXIMUM_INVESTMENT_IN_CZK);
softly.assertThat(strategy.needsConfirmation(new LoanDescriptor(mockLoan(2)))).isFalse();
});
}
Aggregations