Download Investment Prices
If you are using YAFFA to track your investments, you can download the latest prices of certain investments automatically. This feature is useful to keep your investment portfolio up to date and to calculate the current value of your investments.
Prices are retrieved by scheduled tasks, so make sure your cron jobs (and the queue worker) are set up. Each investment uses exactly one provider, which you select on the investment itself. Provider credentials and settings are managed per user, in the investment provider settings section of your user settings. There is no global .env setting for them.
At the moment, the following data providers are supported.
Alpha Vantage
Alpha Vantage is a free API that provides historical and real-time data for stocks, forex, and cryptocurrencies. To use Alpha Vantage, you need to sign up for a free API key.
Once you have the key, enter it in the Alpha Vantage tab of the investment provider settings, and use the connection test to verify it. If the limits of your Alpha Vantage plan differ from the defaults, you can adjust them there, so YAFFA does not exceed them.
The ALPHA_VANTAGE_KEY variable of the .env file is not used anymore, and can be removed. You need to enter your key in the provider settings, otherwise the prices of your Alpha Vantage investments are not retrieved.
Read about using the feature in the Investments section.
Web scraping
Web scraping is a technique to extract data from websites. YAFFA is capable of opening a website and to look for some predefined elements to extract the data. This feature is useful if your investment provider does not host an API to access such data. This feature does not require credentials or additional configuration on the application level, besides setting up cron jobs.
The web scraping provider was reimplemented with a different HTTP client and HTML parser. It is meant to work the same way, but if the price of one of your scraped investments is not retrieved after the upgrade, check its retrieval status, and the web scraping settings of the investment.
Read about using the feature in the Investments section.
Generic API
If your data source offers a JSON HTTP API, the generic API provider lets you describe how to call it and where to find the dates and prices in the response. In the provider settings, you can define:
- the endpoint URL, which can contain the
{symbol},{from}, and{to}placeholders, and the HTTP method (GETorPOST), - optional headers, query parameters, and request body, as JSON,
- the format of the dates in the response,
- where to find the prices in the response: either a list of objects with a date and a price field, or two separate lists for dates and prices.
The settings are stored encrypted. Use the test actions in the provider settings and on the investment form to verify that the response is understood correctly before relying on it.