Giter Site home page Giter Site logo

vanomak / smf-extension Goto Github PK

View Code? Open in Web Editor NEW

This project forked from dhocker/smf-extension

0.0 1.0 0.0 586 KB

LibreOffice extension for retrieving stock market data. This fork adds historical data access to the extension.

License: GNU Lesser General Public License v3.0

Shell 1.35% Python 98.65%

smf-extension's Introduction

SMF Extension for LibreOffice Calc (Forked Version)

The SMF extension allows you to create customized spreadsheets with stock market data directly from the web. Currently supported online sources include

Download

You can download the latest version of the SMF Extension here.

NOTE: The extension itself is SMF.oxt. The example .ods worksheets demonstrate how to use the extension.

Before Installing

LibreOffice runs on multiple operating systems. For unknown reasons, the content of a LibreOffice install is different depending on the operating system. In particular, LibreOffice ships with an embedded version of Python and the configuration of the embedded version varies significantly.

Windows

The forked SMF Extension uses Sqlite3 to cache historical price quotes. Unfortunately, the Windows version of LibreOffice does not come with Sqlite3. If you want to use the forked SMF Extension on Windows, you will need to install Python 3 and set up PYTHONPATH according to your installation. See the prerequisite installation instructions below.

macOS

Some of the web services used by the forked SMF Extension require secure connections through HTTPS. The urllib package in the embedded version of Python does not recognize or use the CA certificates installed under macOS. To compensate for this issue you will need to install the certifi package and create an intrinio.conf file. Refer to the prerequisite installation instructions below.

Linux/Ubuntu

To be determined.

Intrinio Service

If you want to use the Intrinio historical quote function you will need to obtain a free Intrinio account. Once you have signed up for an account you can get the username and password keys that are required to access the Intrinio service. These keys need to go into the intrinio.conf file as described in the prerequisite installation instructions below.

Installation

There are two major steps for installation.

  1. Install/setup prerequisites.
  2. Install the extension under LibreOffice

Install/Setup Prerequisites

Windows

If you want to run the SMF Extension under Windows, it is recomended that you install the latest version of Python 3. Be sure to note where you install it. For simplicity, you might consider installing to C:\python36 or C:\python3.

After you install Python 3, go to the Control Panel and set up the PYTHONPATH variable. Open the menu and type environment variables. This should lead you to the System Properties dialog box. Click on the Environment Variables button.

Create a new user variable named PYTHONPATH. Set the value to the following.

c:\python33;c:\python33\Lib;c:\python33\Lib\site-packages;c:\python33\Lib\sqlite3;c:\python33\DLLs

This assumes you installed Python 3 to C:\python33. If you installed to a different directory, adjust accordingly.

macOS

If you want to use the Intrinio service, you need to install the certifi package package. The easiest way to do this is to open a terminal and enter the following commmand.

pip install certifi

This will install the certifi package for the system. If you are using Python virtual environments, you can install certifi in a VENV by activating the VENV and running the same command. The important file in the certifi package is cacert.pem.

On a stock macOS system the cacert.pem file should be found at

/Library/Python/X.X/site-packages/certifi/cacert.pem

where X.X is the version of Python. Typically the version will be something like 2.7. You will need the location of the cacert.pem file to set up the Intrinio service.

Linux/Ubuntu

To be determined.

Intrinio

In order to use the Intrinio service you must set up an intrinio.conf file. For Windows, this file goes in the LOCALAPPDATA directory.

c:\Users\username\AppData\Local\libreoffice\intrinio\intrinio.conf

Here, username will be whatever your Windows user name is.

For macOS and Linux, this file goes in the home directory.

~/username/libreoffice/intrinio/intrinio.conf

The intrinio.conf file is JSON formatted text specifying the Intrinio username and password plus the full path to the cacert.pem file. Note that the path to the cacert.pem file is only required for macOS. Here's an example.

{
"user":"intrinio-user-id-goes-here",
"password":"intrinio-password-goes-here",
"certifi":"/for/macOS/path/to/certifi/cacert.pem"
}

Once you have created the intrinio.conf file, you should set its file permissions so only you have read/write access to it. Otherwise, your Intrinio username and password could be exposed.

If you open a LibreOffice Calc file containing Intrinio references before creating the intrinio.conf file, the extension will prompt you for Intrinio access credentials. However, it does not do anything with the cacert.pem file. In this case, the intrinio.conf file will be created for you. If you are on Windows all you will have to do is set the file permissions on intrinio.conf. On macOS you will still need to edit the intrinio.conf file for the cacert.pem location.

Install Extension

Once you have dealt with the prerequisites you can install the extension. If you have not fulfilled the prerequisites, you are likely to encounter errors and LibreOffice does not seem to handle errors very gracefully.

  1. Download the latest version of SMF.oxt here.
  2. Start LibreOffice.
  3. Select Menu -> Tools -> Extension Manager.
  4. Click the Add button.
  5. In the file selection dialog, navigate to where you downloaded SMF.oxt and select it.
  6. LibreOffice will install the extension. This may take some time.

Usage

The SMF Extension adds several new functions to Calc:

GETYAHOO(Ticker,Datacode) 
GETMORNINGKEY(Ticker,Datacode) 
GETMORNINGFIN(Ticker,Datacode)
GETMORNINGQFIN(Ticker,Datacode)
GETHISTORICALQUOTE(Ticker, Date)
GETINTRINIOQUOTE(Ticker, Date)

Quotes must be used when entering the ticker directly ex: GETYAHOO("AAPL",1), but are not needed when referencing another cell ex: GETYAHOO(A1,1).

In the latter case the data in A1 should be AAPL, not "AAPL".

NOTE: The full set of datacodes are demonstrated in the example .ods worksheets included with the release.

Dates should be in ISO format YYYY-MM-DD.

Notes

Somewhere around 5/15/2017 Yahoo terminated its historical stock data service. As a result the Yahoo historical data function was removed and partially replaced by two new functions.

  • A Google based function that can return the closing price for a given stock on a given date.
  • An Intrinio based function that can return the closing price for a given stock on a given date.

Intrinio is a relatively new service that can provide a vast amount of stock market related data. Some data is free (like the API used to get historical stock quotes) but has limitations on quantity. For example, with a free account you can request 500 data points per day. While the free account has limitations, the service is reliable. Refer to the web site for details.

Support

For general support please visit the forums. If you find a bug or wish to request a feature please file an issue at the issue tracker.

Contribute

Help is always welcome with development. If you would like to contribute you will need to fork the main repo, make your changes, and send a pull request to have your changes moderated and merged back into the main repo. Details on that process can be found here.

License

The SMF Extension is released under the which in layman's terms means:

  • You are permitted to use, copy and redistribute the work "as-is".
  • You may adapt, remix, transform and build upon the material, releasing any derivatives under your own name.
  • You may use the material for commercial purposes as long as the derivative is licenced under the GPL.
  • You must track changes you make in the source files.
  • You must include or make available the source code with your release.

Other Contributors and Thanks!

  • Villeroy - conversion from string to float to make the extension useful
  • karolus - optimization of keymapping code
  • Corey Goldberg - Inspiration with the Yahoo portion of the extension
  • Dave Hocker - Google Financial Historical data support, Intrinio historical data support.

smf-extension's People

Contributors

dhocker avatar madsailor avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.