Skip to main content

sgb-advisor

A tool to analyse Sovereign Gold Bonds and compare their yields.

Sovereign Gold Bond is a security issued by the RBI on behalf of the Government of India. It is linked to the price of gold.

This tool tries to use publically available data and ✨maths✨ to advise you on which SGB among all of them is trading at it's lowest "fair value".

This does not recommend anything. Calculations, data or something else can be wrong. Do your own research before investing your money anywhere.

Demo: Output is being sent in this public Telegram channel at ~10:00 AM IST every weekday!

Tools used:

  1. Playwright for getting SGB prices from NSE and the price of gold from IBJA.

  2. pyxirr to calculate XIRR

Running the app

You can use any of the 3 methods given below

  1. You can use plain pip or something like uv to build and run the project.

    # Highly recommend creating a venv using `python -m venv .venv` and then activating it (https://docs.python.org/3/library/venv.html#how-venvs-work) first.
    pip install sgb-advisor
    playwright install --with-deps firefox
    # Setup .env in same folder
    sgb-advisor
    
  2. Docker

    # Setup .env in same folder
    docker container run --env-file .env --pull always ghcr.io/vishalnandagopal/sgb-advisor:latest
    
  3. Github actions

  • An action is already setup here.
  • Fork the repo, enable the action in repo settings, setup the required GitHub secrets, vars & envs.

Environment variables

Place the required env variables in an .env file.

# How to notify the user. Accepted values are "telegram", "email", "both" or "none".
# Use "none" if you just want to run the program and generate results
SGB_MODE=telegram
SGB_LOG_LEVEL=info

# Get token from BotFather on Telegram
SGB_TELEGRAM_BOT_TOKEN=xxxxxxxxxx:xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
# Can be one or many users/channels
SGB_TELEGRAM_CHAT_IDS=xxxxxxxxx,xxxxxxx,@sgb_advisor

# No one need to set any of these if you only want to send a message through telegram
SGB_AWS_ACCESS_KEY=xxx
SGB_AWS_SECRET_ACCESS_KEY=xxx
SGB_AWS_SES_SENDER_EMAIL=SGB Advisor <sgb-advisor@your-verified-domain.com>
SGB_AWS_SES_RECIPIENT=example@example.com
SGB_AWS_REGION=us-east-1

# Highlights below mentioned SGBs in the screenshot for easier identification - Use NSE Scrip names from [scripts.csv](./src/sgb_advisor/assets/scrips.csv). Comma separated string
SGB_ALREADY_HELD_SGBS=SGBAUG28V,SGBMAR28X

Sending results to someone

  1. Telegram (recommended)

    If you have a telegram account, you can create a bot in a few seconds, making it very easy to notify you of the results of every run.

    The bot can send results to multiple telegram accounts (both users and channels) at once.

    1. Get an API key from BotFather on Telegram ("bot token").

    2. Get the chat ID of the user(s) you want to send the output to. It is the unique identifier for the target chat (integer in this case) or username of the target channel (@channelusername in this case). Output can be sent to multiple users (place comma-separated chat IDs). Errors are only sent to the first chat-id.

    If you don't know your chat ID, get it by sending a message to @JsonDumpBot. The ["chat"]["id"] in response is your chat ID.

  2. Email (AWS SES only)

    Sending results to an email address using Amazon SES is supported.

    1. Get API keys from AWS console and place it in an .env file as per the above format.

    The email address you want to send from be verified in AWS console. Even the recipient of the email must be verified if you are a new user and in AWS SES Sandbox.

License

GNU GPLv3

TODO

  • Similar tool for finding arbritages in ETFs tracking the same index.

Disclaimers

This tries to use publically available data and maths to advise you on which SGB among all of them is trading at it's lowest "fair value".

This is just a tool to maximize XIRR on interest payments, and to find possible arbritages between gold price IRL and the prices SGBs are trading at.

This does not recommend anything. Calculations, data or something else can be wrong. Do your own research

Assumptions Made

  • The price of Gold when the SGB matures will be the same as it is today. While this may sound dumb, any increase in the price of gold should lead to a somewhat similar increase in redemption prices of all SGBs. You way think that gold can fall or increase in between, but that will affect all gold investments, not just SGB

  • You are interested in gold and have finalized on SGB as a product, and are just confused among different SGBs.

Copyright (C) 2025 Vishal N (hi@vishalnandagopal.com)

Metadata

Release files for sgb-advisor 0.2.7

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for sgb-advisor 0.2.7
File Size Uploaded Provenance Actions
sgb_advisor-0.2.7.tar.gz 35.2 kB With provenance Details for sgb_advisor-0.2.7.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for sgb-advisor 0.2.7
File Interpreter ABI Platform Actions
sgb_advisor-0.2.7-py3-none-any.whl Python 3 none any Details for sgb_advisor-0.2.7-py3-none-any.whl

Total release size: 72.7 kB

Release files / sgb_advisor-0.2.7.tar.gz

Download URL sgb_advisor-0.2.7.tar.gz
Size 35.2 kB
Tags Source
SHA-256 checksum
How to use checksums
35d750a01a0440772ccab7f31cb2c10184bb5030f9792e53b5a223b57f9edfc7
BLAKE2b-256 checksum
How to use checksums
8b59ba35ce2f7d8fba0eae7df129076502ad8384bfcdd092ab98c8dc0d808fac
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

Release files / sgb_advisor-0.2.7-py3-none-any.whl

Download URL sgb_advisor-0.2.7-py3-none-any.whl
Size 37.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
b6499bb4cd2066fee8cb6489a8a7114e69f49dfe73616dd42acae5b0a8e57625
BLAKE2b-256 checksum
How to use checksums
af946f8d5068754fdffb00c998e4119d06a1f65dd3be391eb14aa86d02a89bc9
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.16

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

Security for sgb-advisor 0.2.7

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Full provenance

Both files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for sgb_advisor-0.2.7.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Nov 11, 2026.

Transparency log

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page