APISonar


name.abuchen.portfolio.model.Security.Security

> name > abuchen > portfolio > model > Security > Security
name APIs abuchen APIs portfolio APIs model APIs Security APIs Security APIs

Example 1
public EditSecurityWizard(Client client, Security security)
    {
        this.client = client;
        this.security = security;

        this.editable = new Security();

        shallowCopy(security, editable);

        this.setNeedsProgressMonitor(true);
    }
Example 2
public SecurityBuilder(String currencyCode)
    {
        this.security = new Security(UUID.randomUUID().toString(), currencyCode);
        this.security.setIsin("DE0001"); //$NON-NLS-1$
        this.security.setTickerSymbol("DAX.DE"); //$NON-NLS-1$
    }
Example 3
private VariableURL getURL()
    {
        Security security = new Security();
        security.setIsin("DE0007100000");
        security.setWkn("710000");
        security.setTickerSymbol("DAI.DE");
        security.setCurrencyCode("EUR");

        VariableURL variableURL = Factory.fromString(
            "https://192.0.2.1/quotes.php?isin={ISIN}&wkn={WKN}&ticker={TICKER}&currency={CURRENCY}"
        );
        variableURL.setSecurity(security);
        return variableURL;
    }
Example 4
public void testVariations()
    {
        LocalDate date = LocalDate.now();
        assertVariations(new Security(),
                        Arrays.asList(date, date.minusMonths(1), date.minusMonths(2), date.minusMonths(3)));

        Security security = new Security();
        date = LocalDate.of(2017, 1, 1);
        security.addPrice(new SecurityPrice(date, 1000));
        assertVariations(security, Arrays.asList(date, date.plusMonths(1), date.plusMonths(2), date.plusMonths(3)));
    }
Example 5
public void testThatSecurityIsMatchedByNameOnlyIfWKNMatches()
    {
        SecurityCache cache = new SecurityCache(client);
        Security lookup = cache.lookup(null, null, "BASF11", "Security Name", () -> new Security());
        assertThat(client.getSecurities().get(0), not(is(lookup)));
    }
Example 6
public void testTransactionIfSecurityIsIndex()
    {
        Account account = new Account();
        account.setCurrencyCode("EUR");

        Security security = new Security("", null);

        AccountTransaction t = new AccountTransaction();
        t.setMonetaryAmount(Money.of("EUR", 1_00));
        t.setSecurity(security);
        assertThat(action.process(t, account).getCode(), is(Status.Code.ERROR));
    }
Example 7
public void testDuplicateKeyReplacement()
    {
        Bookmark page = new Bookmark("", "https://www.flatex.de/suche/?q={isin}&isin={isin}");
        Security security = new Security("Daimler", "DE0007100000", "", YahooFinanceQuoteFeed.ID);
        security.setWkn("12345");

        assertThat(page.constructURL(new Client(), security),
                        equalTo("https://www.flatex.de/suche/?q=DE0007100000&isin=DE0007100000"));
    }
Example 8
public void testNoForexGrossValueExistsIfCurrenciesMatch()
    {
        Portfolio portfolio = new Portfolio();
        Security security = new Security("", "EUR");

        PortfolioTransaction t = new PortfolioTransaction();
        t.setType(Type.DELIVERY_INBOUND);
        t.setMonetaryAmount(Money.of("EUR", 1_00));
        t.setSecurity(security);
        t.addUnit(new Unit(Unit.Type.GROSS_VALUE, Money.of("EUR", 1_00), Money.of("USD", 2_00), BigDecimal.valueOf(0.5)));
        assertThat(action.process(t, portfolio).getCode(), is(Status.Code.ERROR));
    }
Example 9
public void setupClient()
    {
        client = new Client();
        account = new Account();
        client.addAccount(account);
        portfolio = new Portfolio();
        client.addPortfolio(portfolio);
        security = new Security();
        client.addSecurity(security);
    }
Example 10
public void testToday()
    {
        Today today = new Today("TODAY");
        assertThat(today.resolve(new Security()), is(LocalDate.now().toString()));
    }
Example 11
private void assertMaxFailedAttempts(String variableURL, long maxFailedAttempts)
    {
        VariableURL url = Factory.fromString(variableURL);
        url.setSecurity(new Security());
        assertThat(url.getMaxFailedAttempts(), equalTo(maxFailedAttempts));
    }
Example 12
private VariableURL getURL()
    {
        VariableURL variableURL = Factory.fromString("https://192.0.2.1/quotes.php?page={PAGE}");
        variableURL.setSecurity(new Security());
        return variableURL;
    }
Example 13
public void testValidAndExistingISIN() throws ParseException
    {
        Client client = new Client();
        client.addSecurity(new Security("BASF", "DE000BASF111", "BAS.DE", QuoteFeed.MANUAL));

        ISINField field = new ISINField("isin", Messages.CSVColumn_ISIN);

        Format format = field.guessFormat(client, null).getFormat();

        assertThat(format.parseObject("DE000BASF111"), is("DE000BASF111"));
    }
Example 14
public void testFIFOPurchasePrice()
    {
        List<PortfolioTransaction> tx = new ArrayList<PortfolioTransaction>();
        tx.add(new PortfolioTransaction(LocalDateTime.now(), CurrencyUnit.EUR, 100000, null, 100 * Values.Share.factor(),
                        Type.BUY, 0, 0));
        tx.add(new PortfolioTransaction(LocalDateTime.now(), CurrencyUnit.EUR, 50000, null, 50 * Values.Share.factor(),
                        Type.SELL, 0, 0));
        SecurityPosition position = new SecurityPosition(new Security(), new TestCurrencyConverter(),
                        new SecurityPrice(), tx);

        assertThat(position.getShares(), is(50L * Values.Share.factor()));
        assertThat(position.getFIFOPurchasePrice(), is(Money.of(CurrencyUnit.EUR, 10_00)));
        assertThat(position.getMovingAveragePurchasePrice(), is(Money.of(CurrencyUnit.EUR, 10_00)));
    }