Git Product home page Git Product logo

finance-bomse's Introduction

Introduction:

BOMSE is a PERL Module to fetch stock quotes for stocks listed on the National Stock Exchange of India, developed for use with Gnucash. Quotes are picked from the NSE website using the nsetools python module in JSON format and then parsed.

The files here are intended to augment those that come with the PERL Finance::Quote package (usually located in /usr/share/perl5/Finance) The code here is based on the BSERO module for Romanian stocks documented here: http://www.strainu.ro/projects/bse-stock-prices-in-gnucash/

The module is named BOMSE because the plan was to pick quotes from the BOMbay Stock Exchange, but later changed to using Yahoo Finance, and when Yahoo closed down its JSON service, moved to python-nsetools. An older version of this module (using Yahoo-JSON service) was integrated into the PERL finance quote module as Yahoo-JSON.

The code here is licensed under the GPL v2. See the license file for the full license.

Prerequisites:

This module requires Perl (at least v5). This has been tested on Debian 8 and Ubuntu 16.04 as of November 1 2017.

Although no other distributions or operating systems have been tested yet, there should be no major problems.

This module requires the JSON and Datetime modules installed for Perl. This version also requires python modules nsetools and its dependencies.

Installation:

Basically the following needs to be done:

  1. Add "BOMSE" to the list of available methods in Quote.pm (located by default in /usr/share/perl5/Finance directory, or equivalent). You can edit this file by hand or try to apply the patch provided (Quotes.pm.patch).

  2. Copy the module (BOMSE.pm) next to the other modules (typically under /usr/share/perl5/Finance/Quote/)

  3. Copy the file nsetoolsfetch.py somewhere in your $PATH The easiest way, in my opinion, is to create a hard link to this file in your users bin directory, with a command such as the following: #$ ln ./nsetoolsfetch ~/bin/ Note that symlinks don't seem to work, hard links do.

Tip: Look at the commands in install.sh.

Testing:

Once installed, run the script nsetoolsfetch.py with a single ticker as argument. E.g.:

$./nsetoolsfetch.py INDIGO

This should print out a valid JSON-formatted quote. If you get {"Sucess":0} it means that either your ticker symbol is wrong, or python is unable to fetch quotes.

Next, to test whether Perl modules are correctly installed, run

$ gnc-fq-check

The output lists all quote fetch methods and should include "bomse"

Then, to test quote fetch using bomse, run

$./BOMTest.pl

This is a test script and will attempt to fetch quotes for a few stocks. If you see "not ok" anywhere the accompanying error message should tell you what has failed. If you are behind a proxy you may need to set the http_proxy environment variable.

Usage:

Scrip names:

Scrip names can be looked up on the NSE website https://www.nseindia.com/ Note that some equities such as ETFs or derivatives can be seen on the NSE website but cannot be fetched. Try nsefetchtools to check which quotes can be fetched.

With Gnucash:

In gnucash

  • go to Tools>Security Editor. Select "Add".
  • Fill up the following fields:
    • Full name :Name of stock as you want to see it.
    • Symbol/Abbreviation :The scrip name exactly as determined above, with the exchange information (e.g. SBIN)
    • Type :Not critical, suggest use of NSE
    • ISIN... :Blank
    • Fraction traded :1/1
    • Get online Quotes :Selected
    • Type of Source Quote :Unknown > bomse
    • Timezone :Use local time
  • Now hit OK, close the Security editor and save the Gnucash File.
  • Go to Tools > Price Editor and click on Get online quotes. See the gnucash manual on setting up automatic price retrieval. (http://gnucash.org/docs/v2.4/C/gnucash-guide/invest-stockprice1.html#invest-stockprice-auto2)

Contributing:

Visit the project page on github: https://github.com/abhijit86k/finance-bomse

Notes:

Yahoo Finance seems to have permanently closed down the JSON Quote service for some exchanges. Since 2016, it does not seem to work for Indian stocks.

finance-bomse's People

Contributors

abhijit86k avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

Forkers

shekarsiri

finance-bomse's Issues

Error Running BOMSE.pm

Hi,

Followed instructions, getting bomse on gnc-fq-check, but error on Debian 9.0. Please correct me if there is something basic that I am missing:

rs@debian:/media/rs/backup/Reserve/1-finances/gnucash/bomse$ ./nsetoolsfetch.py INDIGO
Traceback (most recent call last):
File "./nsetoolsfetch.py", line 26, in
from nsetools import Nse
ImportError: No module named nsetools

Traceback (most recent call last):
File "./nsetoolsfetch.py", line 26, in
from nsetools import Nse
ImportError: No module named nsetools
Uncaught exception from user code:
malformed JSON string, neither tag, array, object, number, string or atom, at character offset 0 (before "(end of string)") at /usr/share/perl5/Finance/Quote/BOMSE.pm line 65.
Finance::Quote::BOMSE::bomse(Finance::Quote=HASH(0x55a0764c8c90), "SBIN") called at /usr/share/perl5/Finance/Quote.pm line 579
Finance::Quote::fetch(Finance::Quote=HASH(0x55a0764c8c90), "bomse", "SBIN") called at /usr/bin/gnc-fq-dump line 180

rs

error running finance-bomse and finance_yson

rs@debian:~/Documents$ gnc-fq-dump yahoo_json SBIN.NS
Finance::Quote fields Gnucash uses:
symbol: SBIN.NS <=== required
date: ** missing ** <=== recommended
currency: ** missing ** <=== required
last: <=\
nav: <=== one of these
price: <=/
timezone: <=== optional

** This stock quote cannot be used by GnuCash!

As can be seen, I have the pm in right place, Quote.pm edited. Both BOMSE and yahoo_json do not work.
Am I missing something basic ? Mumbaistock.pm works on my system.
I am pursuing this with a request to generate quote for debt instruments on BSE from http://www.bseindia.com/markets/equity/EQReports/BhavCopyDebt.aspx?expandable=3

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.