Compare commits

...
3 Commits
Author SHA1 Message Date
cmallwitz e22dc7448f Fix SSL issue on MacOS 2021-09-11 23:46:42 +01:00
cmallwitz ab34a246e3 Update Readme 2021-08-19 19:50:41 +01:00
cmallwitz aa20845ae4 Fix yield for US mutuals and EFTs 2021-06-08 17:29:47 +01:00
6 changed files with 37 additions and 5 deletions
+15 -2
View File
@@ -12,16 +12,19 @@ Additionally, starting with version 3 of the extension, it contains all non-stan
### Feedback requested:
Please provide feedback about using the extension here: https://github.com/cmallwitz/Financials-Extension/issues/10
Please provide feedback about using the extension [here](https://github.com/cmallwitz/Financials-Extension/issues/10)
### Usage:
Under 'Releases' on GitHub there is downloadable **Financials-Extension.oxt** file - load it into Calc
Under 'Releases' on GitHub [there](https://github.com/cmallwitz/Financials-Extension/releases) is a downloadable **Financials-Extension.oxt** file - load it into Calc
under menu item: Tools, Extension Manager...
Please make sure, not to rename the OXT file when downloading and before installing: LO will mess up the installation otherwise and the extension won't work.
Getting data should be a simple as having this in a cell:
- `=GETREALTIME("IBM",21,"YAHOO")`
- `=GETREALTIME("IBM:NYQ",21,"FT")`
- `=GETREALTIME("EURUSD","LAST_PRICE","FT")`
- `=GETHISTORIC("IBM",90,"2020-12-01","YAHOO")`
Codes 21 and 90 stand for "last price" and "close" (see below), respectively.
@@ -36,6 +39,15 @@ assets in other regions, drop me a line (best to include full URLs and possibly
site for comparison). While data for last price is most likely consistent across sites, they may differ for other data
points.
List of example URLs for checking symbols. You can start from these and search for other symbols. If you think some data
is available on the website but not from the extension, a good place to start when raising an issue is to include a similar
URL to compare results.
|Website|Symbol|Example URL for Vodafone Group Plc UK |
| :--- | :--- | :--- |
|YAHOO|VOD.L|https://finance.yahoo.com/quote/VOD.L|
|FT|VOD:LSE|https://markets.ft.com/data/equities/tearsheet/summary?s=VOD:LSE|
### LibreOffice: using , (comma) vs ; (semicolon) to separate arguments in formula
There is a setting in "Tools" / "Options..." / "LibreOffice Calc" / "Formula" called "Functions". Here the user can specify the character used to separate arguments in formula.
@@ -120,6 +132,7 @@ python3 -m unittest discover src
### Tested with:
- Windows 10 / LibreOffice Calc 7.1.2.2 / Python 3.8.8
- Ubuntu 20.04 / LibreOffice Calc 6.4.3.2 / Python 3.8.2
- MacOS 10.15.7 / LibeOffice Calc 7.2.0.4 / Python 3.8.10
(Previous versions)
- Debian 10.3 / LibreOffice Calc 6.1.5.2 / Python 3.7.3
BIN
View File
Binary file not shown.
+13 -1
View File
@@ -14,6 +14,7 @@ import logging
import os
import pathlib
import platform
import ssl
import sys
import time
from functools import wraps
@@ -60,6 +61,16 @@ import financials_ft as ft
implementation_name = "com.financials.getinfo.python.FinancialsImpl" # as defined in Financials.xcu
implementation_services = ("com.sun.star.sheet.AddIn",)
# Disabling SSL certificate validation as Python setup on MacOS seems to be broken
# Only reading public data so this should be safe
try:
_create_unverified_https_context = ssl._create_unverified_context
except AttributeError:
pass
else:
ssl._create_default_https_context = _create_unverified_https_context
def profile(fn):
@wraps(fn)
@@ -230,7 +241,7 @@ class FinancialsImpl(unohelper.Base, Financials):
if e.tag.endswith('version'):
version = e.attrib['value']
s = 'ctx={}\nid(self)={}\nversion={}\nfile={}\ncwd={}\nhome={}\nuname={}\npid={}\nsys.executable={}\nsys.version={}\nlocale={}\ndefaultlocale={}\ndateutil={}\npytz={}\npyparsing={}\nsix={}'.format(
s = 'ctx={}\nid(self)={}\nversion={}\nfile={}\ncwd={}\nhome={}\nuname={}\npid={}\nsys.executable={}\nsys.version={}\nsys.path={}\nlocale={}\ndefaultlocale={}\ndateutil={}\npytz={}\npyparsing={}\nsix={}'.format(
self.ctx,
id(self),
version,
@@ -241,6 +252,7 @@ class FinancialsImpl(unohelper.Base, Financials):
os.getpid(),
sys.executable,
sys.version.replace("\n", " "),
sys.path,
locale.getlocale(),
locale.getdefaultlocale(),
dateutil.__version__,
+4
View File
@@ -238,6 +238,10 @@ class Yahoo(BaseClient):
if match:
tick[Datacode.CURRENCY] = match.group(1)
# fallback for yield on US mutual funds and ETFs, which is in different field
if not tick[Datacode.DIV_YIELD]:
tick[Datacode.DIV_YIELD] = float(raw(summaryDetail, 'yield'))
name = price['longName'] or price['shortName']
if name:
tick[Datacode.NAME] = html.unescape(str(name))
+1 -1
View File
@@ -14,7 +14,7 @@ import os
cur_dir = os.getcwd()
addin_id = "com.financials.getinfo"
addin_version = "3.0.2"
addin_version = "3.0.4"
addin_displayname = "Financial Market Extension"
addin_publisher_link = "https://github.com/cmallwitz/Financials-Extension"
addin_publisher_name = "The Publisher"
+4 -1
View File
@@ -123,6 +123,9 @@ class Test(unittest.TestCase):
s = financials.getRealtime('VFIAX', Datacode.LAST_PRICE_TIME.value, 'YAHOO')
self.assertEqual(str, type(s), 'test_realtime_US_mutuals LAST_PRICE_TIME {}'.format(s))
s = financials.getRealtime('VFIAX', Datacode.DIV_YIELD.value, 'YAHOO')
self.assertTrue(testutils.is_positive_float(s), 'test_realtime_US_mutuals DIV_YIELD {}'.format(s))
def test_realtime_US_options(self):
# symbol from https://finance.yahoo.com/quote/IBM/options?p=IBM
@@ -272,7 +275,7 @@ class Test(unittest.TestCase):
# Note: quarterly dividend and splits will change past adjusted prices - will fail after the next dividend
s = financials.getHistoric('IBM', Datacode.ADJ_CLOSE.value, '2017-01-03', 'YAHOO')
self.assertEqual(136.249847, s, 'test_historic_US_equity ADJ_CLOSE {}'.format(s))
self.assertEqual(134.699081, s, 'test_historic_US_equity ADJ_CLOSE {}'.format(s))
def test_historic_UK_ETF(self):