Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New dashboard widget to show the timeliness of security prices #2990

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,120 @@
package name.abuchen.portfolio.util;

import static org.junit.Assert.assertFalse;
import static org.junit.Assert.assertTrue;

import java.time.Clock;
import java.time.LocalDate;
import java.time.ZoneId;

import org.junit.Test;

import name.abuchen.portfolio.model.LatestSecurityPrice;
import name.abuchen.portfolio.model.Security;

@SuppressWarnings("nls")
public class SecurityTimelinessTest
{
private static final LocalDate LOCAL_DATE = LocalDate.of(2020, 5, 6);
private Clock clock;

public SecurityTimelinessTest()
{
this.clock = Clock.fixed(LOCAL_DATE.atStartOfDay(ZoneId.systemDefault()).toInstant(), ZoneId.systemDefault());
}

@Test
public void testStaleIfNoLatestFeed()
{
Security security = new Security();
security.setRetired(false);

SecurityTimeliness st = new SecurityTimeliness(security, 7, this.clock);

assertTrue(st.isStale());
}

@Test
public void testNotStaleIfRetired()
{
Security security = new Security();
security.setRetired(true);

SecurityTimeliness st = new SecurityTimeliness(security, 7, this.clock);

assertFalse(st.isStale());
}

@Test
public void testStaleIfNotUpdatedWithin8DaysWith1HolidayAndWeekend()
{
Security security = new Security();
security.setRetired(false);
security.setLatest(new LatestSecurityPrice(LocalDate.of(2020, 4, 23), 10));

SecurityTimeliness st = new SecurityTimeliness(security, 7, this.clock);

assertTrue(st.isStale());
}

@Test
public void testNotStaleIfNotUpdatedWithin7DaysWith1HolidayAndWeekend()
{
Security security = new Security();
security.setRetired(false);
security.setLatest(new LatestSecurityPrice(LocalDate.of(2020, 4, 24), 10));

SecurityTimeliness st = new SecurityTimeliness(security, 7, this.clock);

assertFalse(st.isStale());
}

@Test
public void testNotStaleIfUpdatedToday()
{
Security security = new Security();
security.setRetired(false);
security.setLatest(new LatestSecurityPrice(LocalDate.of(2020, 5, 6), 10));

SecurityTimeliness st = new SecurityTimeliness(security, 7, this.clock);

assertFalse(st.isStale());
}

@Test
public void testNotStaleIfUpdatedYesterday()
{
Security security = new Security();
security.setRetired(false);
security.setLatest(new LatestSecurityPrice(LocalDate.of(2020, 5, 5), 10));

SecurityTimeliness st = new SecurityTimeliness(security, 7, this.clock);

assertFalse(st.isStale());
}

@Test
public void testStaleIfUpdatedYesterdayAndInterval0()
{
Security security = new Security();
security.setRetired(false);
security.setLatest(new LatestSecurityPrice(LocalDate.of(2020, 5, 5), 10));

SecurityTimeliness st = new SecurityTimeliness(security, 0, this.clock);

assertTrue(st.isStale());
}

@Test
public void testNoHolidaysOrWeekendsIfSecurityHasNoCalendar()
{
Security security = new Security();
security.setRetired(false);
security.setLatest(new LatestSecurityPrice(LocalDate.of(2020, 4, 28), 10));
security.setCalendar("empty");

SecurityTimeliness st = new SecurityTimeliness(security, 7, this.clock);

assertTrue(st.isStale());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -749,6 +749,7 @@ public class Messages extends NLS
public static String LabelSearch;
public static String LabelSearchForQuoteFeeds;
public static String LabelSecurities;
public static String LabelSecuritiesPriceTimeliness;
public static String LabelSecurityLatestPrice;
public static String LabelSecurityPerformance;
public static String LabelSecurityTransfer;
Expand Down Expand Up @@ -1105,6 +1106,8 @@ public class Messages extends NLS
public static String PrefPortfolioReportAPIKey;
public static String PrefPortfolioReportAPIURL;
public static String PrefQuandlAPIKey;
public static String PrefQuotesStaleAfterDays;
public static String PrefQuotesStaleNote;
public static String PrefRelativeBackupDirectoryName;
public static String PrefStoreSettingsNextToFile;
public static String PrefUpdateQuotesAfterFileOpen;
Expand All @@ -1126,6 +1129,7 @@ public class Messages extends NLS
public static String PrefTitleLeeway;
public static String PrefTitlePortfolioReport;
public static String PrefTitleQuandl;
public static String PrefTitleQuotes;
public static String PrefTitleTwelveData;
public static String PrefTwelveDataAPIKey;
public static String PresetsPrefPageDescription;
Expand Down Expand Up @@ -1255,6 +1259,7 @@ public class Messages extends NLS
public static String TooltipQuoteAtDate;
public static String TooltipRebalancingIndicator;
public static String TooltipSecurityLatestPrice;
public static String TooltipSecurityPriceTimeliness;
public static String TooltipSemiVolatility;
public static String TooltipTurnoverRate;
public static String TooltipVolatility;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,7 @@ interface Preferences // NOSONAR
*/
String CSV_EXPORT_PATH = "CSV_EXPORT_PATH"; //$NON-NLS-1$

String QUOTES_STALE_AFTER_DAYS_PATH = "QUOTES_STALE_AFTER_DAYS_PATH"; //$NON-NLS-1$
}

interface CSS // NOSONAR
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@
import name.abuchen.portfolio.ui.preferences.PresetsPreferencePage;
import name.abuchen.portfolio.ui.preferences.ProxyPreferencePage;
import name.abuchen.portfolio.ui.preferences.QuandlPreferencePage;
import name.abuchen.portfolio.ui.preferences.QuotesPreferencePage;
import name.abuchen.portfolio.ui.preferences.ThemePreferencePage;
import name.abuchen.portfolio.ui.preferences.TwelveDataPreferencePage;
import name.abuchen.portfolio.ui.preferences.UpdatePreferencePage;
Expand Down Expand Up @@ -75,6 +76,8 @@ public void execute(@Named(IServiceConstants.ACTIVE_SHELL) Shell shell,

pm.addToRoot(new PreferenceNode("calendar", new CalendarPreferencePage())); //$NON-NLS-1$

pm.addToRoot(new PreferenceNode("quotes", new QuotesPreferencePage()));

pm.addToRoot(new PreferenceNode("api", new APIKeyPreferencePage())); //$NON-NLS-1$
pm.addTo("api", new PreferenceNode("alphavantage", new AlphaVantagePreferencePage())); //$NON-NLS-1$ //$NON-NLS-2$
pm.addTo("api", new PreferenceNode("divvydiary", new DivvyDiaryPreferencePage())); //$NON-NLS-1$ //$NON-NLS-2$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1576,6 +1576,8 @@ LabelSearchForQuoteFeeds = Search for suppliers of historical prices

LabelSecurities = Securities

LabelSecuritiesPriceTimeliness = Securities: Price Timeliness

LabelSecurityCalendar = Calendar

LabelSecurityCalendarToolTip = Calendar of Stock Exchange to determine missing trading days
Expand Down Expand Up @@ -2240,6 +2242,10 @@ PrefPortfolioReportAPIURL = Portfolio Report API URL

PrefQuandlAPIKey = Quandl API Key

PrefQuotesStaleAfterDays = Number of days after a security price is not up-to-date anymore

PrefQuotesStaleNote = After this amount of days a security price is marked as not up-to-date.\nPlease note that only days with open stock exchanges are considered\n(depends on the configured calendar for each security).

PrefRelativeBackupDirectoryName = Directory name next to data file

PrefStoreSettingsNextToFile = Store GUI settings next to Portfolio Performance file
Expand Down Expand Up @@ -2282,6 +2288,8 @@ PrefTitleTwelveData = Twelve Data

PrefTwelveDataAPIKey = Twelve Data API Key

PrefTitleQuotes = Quotes

PrefUpdateQuotesAfterFileOpen = Automatically update quotes after opening a file

PrefUpdateSite = &Update URL:
Expand Down Expand Up @@ -2538,6 +2546,8 @@ TooltipRebalancingIndicator = Color coding according to the {0}/{1} Rule:\n\n{0}

TooltipSecurityLatestPrice = Latest security price of {0} from {1}

TooltipSecurityPriceTimeliness = {0} of {1} security prices are older than {2} days

TooltipSemiVolatility = Semivariance only looks at the negative fluctuations of an asset.\n\nIf the negative and postive fluctuations are equal, then the following holds\n\nVolatility (v) = Semi-variance (s) * \u221A2\n\nIf the current data set is evenly distributed, then the semivariance is\n\n s = v \u00F7 \u221A2 = {2} \u00F7 \u221A2 = {0}\n\nCompare that with the actual semivariance\n\n {0} {1} {3}\n evenly distributed {1} actual semivariance\n\n\nThe semivariance is calculated using the "accumulated" data series. Therefore performance-neutral transactions have no impact. Weekends and public holidays are ignored (for example Easter and Christmas days).

TooltipTurnoverRate = The Portfolio Turnover Rate measures how much of the portfolio was "replaced" throughout the holding period, as a fraction of the average portfolio value.\n\nPurchases: {0}\nSales: {1}\nAverage portfolio volume: {2}\nPortfolio Turnover Rate: {3}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1570,6 +1570,8 @@ LabelSearchForQuoteFeeds = Vyhled\u00E1v\u00E1n\u00ED dodavatel\u016F historick\

LabelSecurities = Cenn\u00E9 pap\u00EDry

LabelSecuritiesPriceTimeliness = Cenn\u00E9 pap\u00EDry: V\u010Dasnost ceny

LabelSecurityCalendar = kalend\u00E1\u0159

LabelSecurityCalendarToolTip = Kalend\u00E1\u0159 burzy cenn\u00FDch pap\u00EDr\u016F pro ur\u010Den\u00ED chyb\u011Bj\u00EDc\u00EDch obchodn\u00EDch dn\u016F
Expand Down Expand Up @@ -2232,6 +2234,10 @@ PrefPortfolioReportAPIURL = Portfolio Report ADRESA URL API

PrefQuandlAPIKey = Quandl API kl\u00ED\u010D

PrefQuotesStaleAfterDays = Po\u010Det dn\u00ED pot\u00E9, co cena cenn\u00E9ho pap\u00EDru ji\u017E nen\u00ED aktu\u00E1ln\u00ED

PrefQuotesStaleNote = Po uplynut\u00ED t\u00E9to doby je cena cenn\u00E9ho pap\u00EDru ozna\u010Dena jako neaktu\u00E1ln\u00ED.\nVezm\u011Bte pros\u00EDm na v\u011Bdom\u00ED, \u017Ee se berou v \u00FAvahu pouze dny s otev\u0159en\u00FDmi burzami.\n(z\u00E1le\u017E\u00ED na nakonfigurovan\u00E9m kalend\u00E1\u0159i pro ka\u017Ed\u00FD cenn\u00FD pap\u00EDr).

PrefRelativeBackupDirectoryName = N\u00E1zev adres\u00E1\u0159e vedle datov\u00E9ho souboru

PrefStoreSettingsNextToFile = Ulo\u017Een\u00ED nastaven\u00ED grafick\u00E9ho u\u017Eivatelsk\u00E9ho rozhran\u00ED vedle souboru Portfolio Performance
Expand Down Expand Up @@ -2274,6 +2280,8 @@ PrefTitleTwelveData = Twelve Data

PrefTwelveDataAPIKey = Twelve Data API kl\u00ED\u010D

PrefTitleQuotes = Kurzy

PrefUpdateQuotesAfterFileOpen = Automaticky aktualizovat kurzy po otev\u0159en\u00ED souboru

PrefUpdateSite = &Aktualizovat adresu URL:
Expand Down Expand Up @@ -2530,6 +2538,8 @@ TooltipRebalancingIndicator = Barevn\u00E9 k\u00F3dov\u00E1n\u00ED podle pravidl

TooltipSecurityLatestPrice = Nejnov\u011Bj\u0161\u00ED cena cenn\u00E9ho pap\u00EDru {0} od {1}

TooltipSecurityPriceTimeliness = {0} z {1} cen cenn\u00FDch pap\u00EDr\u016F jsou star\u0161\u00ED ne\u017E {2} dn\u016F

TooltipSemiVolatility = Variogram se zab\u00FDv\u00E1 pouze z\u00E1porn\u00FDmi v\u00FDkyvy aktiva.\n\nPokud jsou z\u00E1porn\u00E9 a kladn\u00E9 fluktuace stejn\u00E9, pak plat\u00ED n\u00E1sleduj\u00EDc\u00ED tvrzen\u00ED\n\nVolatilita (v) = Variogram (s) * \u221A2\n\nPokud je aktu\u00E1ln\u00ED soubor dat rovnom\u011Brn\u011B rozlo\u017Een, pak je variogram roven\n\n s = v \u00F7 \u221A2 = {2} \u00F7 \u221A2 = {0}\n\nPorovnejte to se skute\u010Dn\u00FDm variogramem\n\n {0} {1} {3}\n rovnom\u011Brn\u011B rozd\u011Blen\u00FD {1} skute\u010Dn\u00FD variogram\n\n\nVariogram se vypo\u010D\u00EDt\u00E1 pomoc\u00ED "akumulovan\u00E9" datov\u00E9 \u0159ady. V\u00FDkonov\u011B neutr\u00E1ln\u00ED transakce proto nemaj\u00ED \u017E\u00E1dn\u00FD vliv. V\u00EDkendy a st\u00E1tn\u00ED sv\u00E1tky se ignoruj\u00ED (nap\u0159\u00EDklad velikono\u010Dn\u00ED a v\u00E1no\u010Dn\u00ED dny).

TooltipTurnoverRate = Obr\u00E1tkovost portfolia se m\u011B\u0159\u00ED, jak velk\u00E1 \u010D\u00E1st portfolia byla b\u011Bhem doby dr\u017Eby "nahrazena", a to jako pod\u00EDl pr\u016Fm\u011Brn\u00E9 hodnoty portfolia.\n\nN\u00E1kupy: {0}\nProdeje: {1}\nPr\u016Fm\u011Brn\u00FD objem portfolia: {2}\nObr\u00E1tkovost portfolia: {3}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1569,6 +1569,8 @@ LabelSearchForQuoteFeeds = Suche nach Kurslieferanten

LabelSecurities = Wertpapiere

LabelSecuritiesPriceTimeliness = Wertpapiere: Preis-Aktualit\u00E4t

LabelSecurityCalendar = Kalender

LabelSecurityCalendarToolTip = Kalender der B\u00F6rse zur Ermittlung fehlender Handelstagen
Expand Down Expand Up @@ -2233,6 +2235,10 @@ PrefPortfolioReportAPIURL = Portfolio Report API URL

PrefQuandlAPIKey = Quandl API-Schl\u00FCssel

PrefQuotesStaleAfterDays = Anzahl der Tage, nachdem ein Wertpapierkurs nicht mehr aktuell ist

PrefQuotesStaleNote = Nach dieser Anzahl von Tagen wird ein Wertpapierkurs als nicht aktuell markiert.\nBitte beachten, dass nur Tage mit offenen B\u00F6rsen ber\u00FCcksichtigt werden\n(abh\u00E4ngig vom konfigurierten Kalender f\u00FCr jedes Wertpapier).

PrefRelativeBackupDirectoryName = Verzeichnisname neben der Datendatei

PrefStoreSettingsNextToFile = GUI Einstellungen neben Portfolio Performance Datei speichern
Expand Down Expand Up @@ -2275,6 +2281,8 @@ PrefTitleTwelveData = Twelve Data

PrefTwelveDataAPIKey = Twelve Data API-Schl\u00FCssel

PrefTitleQuotes = Kurse

PrefUpdateQuotesAfterFileOpen = Wertpapierkurse nach dem \u00D6ffnen der Datei automatisch aktualisieren

PrefUpdateSite = &Update URL:
Expand Down Expand Up @@ -2533,6 +2541,8 @@ TooltipSecurityLatestPrice = Letzter Wertpapierkurs von {0} vom {1}

TooltipSemiVolatility = Die Semivolatilit\u00E4t betrachtet im Gegensatz zur Volatilit\u00E4t nur die negativen Abweichungen der erzielten Renditen zum arithmetischen Mittelwert der Renditen.\n\nSind die negativen und positiven Abweichungen gleich verteilt, so gilt \n\n Volatilit\u00E4t (v) = Semivolatilit\u00E4t (s) * \u221A2\n\nBei der aktuellen Datenreihe ist die gleich verteilte Semivolatilit\u00E4t\n\n s = v \u00F7 \u221A2 = {2} \u00F7 \u221A2 = {0}\n\nDer Vergleich mit der tats\u00E4chlichen Semivolatilit\u00E4t zeigt\n\n {0} {1} {3}\n gleich verteilte {1} tats\u00E4chliche Semivolatilit\u00E4t\n\n\nIm Programm wird die Semivolatilit\u00E4t mit der "akkumuliert" Datenreihe errechnet. Performanceneutrale Bewegungen haben keinen Einfluss. Wochenenden und B\u00F6rsenfeiertage (z.B. Ostern oder Weihnachten) werden ignoriert.

TooltipSecurityPriceTimeliness = {0} von {1} Wertpapierkursen sind \u00E4lter als {2} Tage

TooltipTurnoverRate = Das Turnover-Verh\u00E4ltnis gibt an, welchen Anteil des Portfolios die K\u00E4ufe bzw. Verk\u00E4ufe im Berichtszeitraum ausmachen.\n\nK\u00E4ufe: {0}\nVerk\u00E4ufe: {1}\nDurchschnittliches Portfoliovolumen: {2}\nPortfolio Turnover Rate: {3}

TooltipVolatility = Die Volatilit\u00E4t gibt an, wie stark ein Kurs schwankt. Je h\u00F6her die Volatilit\u00E4t ist, desto st\u00E4rker weichen die einzelnen Renditen vom erwarteten Mittelwert ab, sowohl nach Oben als auch nach Unten. Die Volatilit\u00E4t ist definiert als die Standardabweichung zwischen der erzielten Rendite und dem arithmetischen Durchschnitt der Renditen.\n\nHier wird die Volatilit\u00E4t mit der "akkumuliert" Datenreihe errechnet. Performanceneutrale Bewegungen haben keinen Einfluss. Wochenenden und B\u00F6rsenfeiertage (z. B. Ostern oder Weihnachten) werden ignoriert.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1569,6 +1569,8 @@ LabelSearchForQuoteFeeds = B\u00FAsqueda de proveedores de cotizaciones

LabelSecurities = Valores

LabelSecuritiesPriceTimeliness = Valores: Puntualidad de los precios

LabelSecurityCalendar = Calendario

LabelSecurityCalendarToolTip = Calendario de la Bolsa de Valores para determinar los \u00EDas de negociaci\u00F3n faltantes
Expand Down Expand Up @@ -2233,6 +2235,10 @@ PrefPortfolioReportAPIURL = Portfolio Report API URL

PrefQuandlAPIKey = Clave API de Quandl

PrefQuotesStaleAfterDays = N\u00FAmero de d\u00EDas despu\u00E9s de que la cotizaci\u00F3n de un valor deje de estar actualizada

PrefQuotesStaleNote = Despu\u00E9s de esta cantidad de d\u00EDas, la cotizaci\u00F3n de un valor se marca como no actualizada.\nTenga en cuenta que s\u00F3lo se consideran los d\u00EDas con bolsas abiertas\n(depende del calendario configurado para cada valor).

PrefRelativeBackupDirectoryName = Nombre del directorio junto al archivo de datos

PrefStoreSettingsNextToFile = Guardar la configuraci\u00F3n de la interfaz junto al archivo de Portfolio Performance
Expand Down Expand Up @@ -2277,6 +2283,10 @@ PrefTwelveDataAPIKey = Clave API de Twelve Data

PrefUpdateQuotesAfterFileOpen = Actualizar autom\u00E1ticamente las cotizaciones tras de abrir un archivo

PrefTitleQuotes = Cotizaciones

PrefUpdateQuotesAfterFileOpen = Actualizar autom\u00E1ticamente las cotizaciones tras de abrir un fichero

PrefUpdateSite = &URL de actualizaciones:

PresetsPrefPageDescription = Valores preestablecidos para nuevos datos.
Expand Down Expand Up @@ -2533,6 +2543,8 @@ TooltipSecurityLatestPrice = \u00DAltima cotizaci\u00F3n de {0} desde {1}

TooltipSemiVolatility = La semivolatilidad s\u00F3lo tiene en cuenta las fluctuaciones negativas de un activo.\n\nSi las fluctuaciones negativas y positivas son iguales, se cumple lo siguiente:\n\nVolatilidad (v) = Semivolatilidad (s) \u00D7 \u221A2\n\nSi el conjunto de datos actual est\u00E1 distribuido uniformemente, entonces la semivolatilidad es:\n s = v \u00F7 \u221A2 = {2} \u00F7 \u221A2 = {0}\n\nComparela con la semivolatilidad real\n\n {0} {1} {3}\n uniformemente distribuida {1} semivolatilidad real\n\nLa semivolatilidad se calcula usando la serie de datos "acumulada". Las transacciones con rendimiento neutro no tienen efecto. Los fines de semana y festivos no se tienen en cuenta (por ejemplo, Semana Santa y Navidad).

TooltipSecurityPriceTimeliness = {0} de {1} cotizaciones de valores tienen m\u00E1s de {2} d\u00EDas

TooltipTurnoverRate = El Indice de Rotaci\u00F3n de la cartera mide qu\u00E9 parte de la cartera fue "reemplazada" durante el per\u00EDodo de tenencia, como fracci\u00F3n del valor promedio de la cartera.\n\nCompras: {0}\nVentas: {1}\nVolumen promedio de cartera: {2}\nIndice de rotaci\u00F3n de la cartera: {3}

TooltipVolatility = La volatilidad (o varianza) es una medida de la variaci\u00F3n del precio de un instrumento financiero a lo largo del tiempo.\n\nLa volatilidad se calcula usando las series de datos "acumuladas". Por tanto, las operaciones con rendimiento neutro (sin ganancias ni perdidas) no tienen impacto. Se ignoran los fines de semana y los festivos (por ejemplo, Semana Santa y Navidad).
Expand Down
Loading