Skip to content

Instantly share code, notes, and snippets.

@thomasjimmy
thomasjimmy / fetch_stock_prices_for_gnucash.py
Last active March 24, 2019 09:10 — forked from pedrovgp/fetch_stock_prices_for_gnucash.py
Python script to fetch stock prices for Stocks in India for GNUCash. Forked from the original as Alphavantage doesn't work for Stocks in Indian Stock Exchange. This uses another free API which is at https://api.mfapi.in/mf/.
# INSTALL DEPENDENCIES BEFORE RUNNING: pandas, sqlite3, sqlalchemy, requests
# There is one thing you have to do though: gnucash needs to know the price's currency and it needs a guid (unique identifier)
# for this. This guid is unique for each installation, so you need to find yours and assign it to CURRENCY_GUID.
# OR: you can just leave it, and the script will fetch the currency from the last price added
#This creates a backup of your account file with the filename .backup. In case your original file is
#corrupted and GNU cash is unable to open the same, please rename the backup file and use the same.
import pandas as pd
import sqlite3
import sqlalchemy