Search in sources :

Example 1 with RecommendedInvestment

use of com.github.robozonky.api.strategies.RecommendedInvestment in project robozonky by RoboZonky.

the class NaturalLanguageSellStrategyTest method noLoansApplicable.

@Test
void noLoansApplicable() {
    final MarketplaceFilter filter = MarketplaceFilter.of(MarketplaceFilterCondition.alwaysAccepting());
    final ParsedStrategy p = new ParsedStrategy(DefaultPortfolio.PROGRESSIVE, Collections.singleton(filter));
    final SellStrategy s = new NaturalLanguageSellStrategy(p);
    final PortfolioOverview portfolio = mock(PortfolioOverview.class);
    when(portfolio.getCzkAvailable()).thenReturn(p.getMinimumBalance());
    when(portfolio.getCzkInvested()).thenReturn(p.getMaximumInvestmentSizeInCzk() - 1);
    final Stream<RecommendedInvestment> result = s.recommend(Collections.singletonList(mockDescriptor()), portfolio);
    assertThat(result).isEmpty();
}
Also used : SellStrategy(com.github.robozonky.api.strategies.SellStrategy) MarketplaceFilter(com.github.robozonky.strategy.natural.conditions.MarketplaceFilter) RecommendedInvestment(com.github.robozonky.api.strategies.RecommendedInvestment) PortfolioOverview(com.github.robozonky.api.strategies.PortfolioOverview) Test(org.junit.jupiter.api.Test)

Example 2 with RecommendedInvestment

use of com.github.robozonky.api.strategies.RecommendedInvestment in project robozonky by RoboZonky.

the class Selling method processInvestment.

private Optional<Investment> processInvestment(final Zonky zonky, final RecommendedInvestment r) {
    Events.fire(new SaleRequestedEvent(r));
    final Investment i = r.descriptor().item();
    if (isDryRun) {
        LOGGER.debug("Not sending sell request for loan #{} due to dry run.", i.getLoanId());
    } else {
        LOGGER.debug("Sending sell request for loan #{}.", i.getLoanId());
        zonky.sell(i);
        LOGGER.trace("Request over.");
    }
    Investment.putOnSmp(i);
    Events.fire(new SaleOfferedEvent(i, r.descriptor().related()));
    return Optional.of(i);
}
Also used : SaleRequestedEvent(com.github.robozonky.api.notifications.SaleRequestedEvent) SaleOfferedEvent(com.github.robozonky.api.notifications.SaleOfferedEvent) RecommendedInvestment(com.github.robozonky.api.strategies.RecommendedInvestment) Investment(com.github.robozonky.api.remote.entities.sanitized.Investment) RawInvestment(com.github.robozonky.api.remote.entities.RawInvestment)

Aggregations

RecommendedInvestment (com.github.robozonky.api.strategies.RecommendedInvestment)2 SaleOfferedEvent (com.github.robozonky.api.notifications.SaleOfferedEvent)1 SaleRequestedEvent (com.github.robozonky.api.notifications.SaleRequestedEvent)1 RawInvestment (com.github.robozonky.api.remote.entities.RawInvestment)1 Investment (com.github.robozonky.api.remote.entities.sanitized.Investment)1 PortfolioOverview (com.github.robozonky.api.strategies.PortfolioOverview)1 SellStrategy (com.github.robozonky.api.strategies.SellStrategy)1 MarketplaceFilter (com.github.robozonky.strategy.natural.conditions.MarketplaceFilter)1 Test (org.junit.jupiter.api.Test)1