From 68390f450e174cd8bb36945523f056f80b25565f Mon Sep 17 00:00:00 2001
From: Debasish Pal <48341250+debpal@users.noreply.github.com>
Date: Tue, 26 Nov 2024 12:31:03 +0200
Subject: [PATCH] update code
---
.github/workflows/linting.yml | 2 +-
.github/workflows/typing.yml | 2 +-
BharatFinTrack/nse_tri.py | 1 -
README.md | 21 +++++++++------------
pyproject.toml | 2 +-
tests/test_bharatfintrack.py | 33 +++++++++++++++++++++++++++++----
6 files changed, 41 insertions(+), 20 deletions(-)
diff --git a/.github/workflows/linting.yml b/.github/workflows/linting.yml
index 90d8d97..ac0d2cf 100644
--- a/.github/workflows/linting.yml
+++ b/.github/workflows/linting.yml
@@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- python-version: ["3.12"]
+ python-version: ["3.12", "3.11"]
steps:
- uses: actions/checkout@v4
diff --git a/.github/workflows/typing.yml b/.github/workflows/typing.yml
index 8151e62..1b331aa 100644
--- a/.github/workflows/typing.yml
+++ b/.github/workflows/typing.yml
@@ -18,7 +18,7 @@ jobs:
strategy:
fail-fast: false
matrix:
- python-version: ["3.12"]
+ python-version: ["3.12", "3.11"]
steps:
- uses: actions/checkout@v4
diff --git a/BharatFinTrack/nse_tri.py b/BharatFinTrack/nse_tri.py
index 7d0ebf7..32cd274 100644
--- a/BharatFinTrack/nse_tri.py
+++ b/BharatFinTrack/nse_tri.py
@@ -1066,7 +1066,6 @@ def sip_growth_comparison_across_indices(
return aggregate_df
- # not testes yet
def sip_xirr_comparison_across_indices(
self,
indices: list[str],
diff --git a/README.md b/README.md
index d1583ff..364d77d 100644
--- a/README.md
+++ b/README.md
@@ -1,5 +1,14 @@
# BharatFinTrack
+| Status | Description |
+| --- | --- |
+| **PyPI**| ![PyPI - Version](https://img.shields.io/pypi/v/BharatFinTrack) ![PyPI - Status](https://img.shields.io/pypi/status/BharatFinTrack) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/BharatFinTrack) ![PyPI - Wheel](https://img.shields.io/pypi/wheel/BharatFinTrack) |
+| **GitHub** | ![GitHub last commit](https://img.shields.io/github/last-commit/debpal/BharatFinTrack) [![flake8](https://github.com/debpal/BharatFinTrack/actions/workflows/linting.yml/badge.svg)](https://github.com/debpal/BharatFinTrack/actions/workflows/linting.yml) [![mypy](https://github.com/debpal/BharatFinTrack/actions/workflows/typing.yml/badge.svg)](https://github.com/debpal/BharatFinTrack/actions/workflows/typing.yml) [![pytest](https://github.com/debpal/BharatFinTrack/actions/workflows/testing.yml/badge.svg)](https://github.com/debpal/BharatFinTrack/actions/workflows/testing.yml) |
+| **Codecov** | [![codecov](https://codecov.io/github/debpal/BharatFinTrack/graph/badge.svg?token=6DIYX8MUTM)](https://codecov.io/github/debpal/BharatFinTrack) |
+| **Read** _the_ **Docs** | [![Documentation Status](https://readthedocs.org/projects/bharatfintrack/badge/?version=latest)](https://bharatfintrack.readthedocs.io/en/latest/?badge=latest) |
+| **PePy** | ![Pepy Total Downloads](https://img.shields.io/pepy/dt/BharatFinTrack)|
+| **License** | ![PyPI - License](https://img.shields.io/pypi/l/BharatFinTrack) |
+
`BharatFinTrack` is a Python package designed to simplify the process of downloading and analyzing financial data from India. Conceptualized on September 1, 2024, and launched on September 8, 2024, this package is tailored for long-term investors seeking to streamline their financial data workflows.
@@ -85,15 +94,3 @@ If this project has been helpful and you'd like to contribute to its development
[![Buy Me a Coffee](https://img.shields.io/badge/☕_Buy_me_a_coffee-FFDD00?style=for-the-badge)](https://www.buymeacoffee.com/debasish_pal)
-
-
-## Toolkit
-
-| Status | Description |
-| --- | --- |
-| **PyPI**| ![PyPI - Version](https://img.shields.io/pypi/v/BharatFinTrack) ![PyPI - Status](https://img.shields.io/pypi/status/BharatFinTrack) ![PyPI - Python Version](https://img.shields.io/pypi/pyversions/BharatFinTrack) ![PyPI - Wheel](https://img.shields.io/pypi/wheel/BharatFinTrack) |
-| **GitHub** | ![GitHub last commit](https://img.shields.io/github/last-commit/debpal/BharatFinTrack) [![flake8](https://github.com/debpal/BharatFinTrack/actions/workflows/linting.yml/badge.svg)](https://github.com/debpal/BharatFinTrack/actions/workflows/linting.yml) [![mypy](https://github.com/debpal/BharatFinTrack/actions/workflows/typing.yml/badge.svg)](https://github.com/debpal/BharatFinTrack/actions/workflows/typing.yml) [![pytest](https://github.com/debpal/BharatFinTrack/actions/workflows/testing.yml/badge.svg)](https://github.com/debpal/BharatFinTrack/actions/workflows/testing.yml) |
-| **Codecov** | [![codecov](https://codecov.io/github/debpal/BharatFinTrack/graph/badge.svg?token=6DIYX8MUTM)](https://codecov.io/github/debpal/BharatFinTrack) |
-| **Read** _the_ **Docs** | [![Documentation Status](https://readthedocs.org/projects/bharatfintrack/badge/?version=latest)](https://bharatfintrack.readthedocs.io/en/latest/?badge=latest) |
-| **PePy** | ![Pepy Total Downloads](https://img.shields.io/pepy/dt/BharatFinTrack)|
-| **License** | ![PyPI - License](https://img.shields.io/pypi/l/BharatFinTrack) |
diff --git a/pyproject.toml b/pyproject.toml
index 024df15..7d2e963 100644
--- a/pyproject.toml
+++ b/pyproject.toml
@@ -19,7 +19,7 @@ dependencies = [
"pyxirr"
]
readme = "README.md"
-requires-python = ">=3.11"
+requires-python = ">=3.10, <3.13"
classifiers = [
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python :: 3.12",
diff --git a/tests/test_bharatfintrack.py b/tests/test_bharatfintrack.py
index 9780014..e654b79 100644
--- a/tests/test_bharatfintrack.py
+++ b/tests/test_bharatfintrack.py
@@ -507,12 +507,20 @@ def test_sip(
start_date='15-Oct-2022',
end_date='15-Oct-2024'
)
- merged_df = nse_tri.sip_growth_comparison_across_indices(
+ # SIP growth comparison
+ aggregate_df = nse_tri.sip_growth_comparison_across_indices(
indices=[index, index_1],
folder_path=tmp_dir,
- excel_file=os.path.join(tmp_dir, 'sip_invest_growth_across_indices.xlsx')
+ excel_file=os.path.join(tmp_dir, 'compare_sip_growth_across_indices.xlsx')
)
- assert len(merged_df.columns) == 5
+ assert len(aggregate_df.columns) == 2
+ # SIP XIRR comparison
+ aggregate_df = nse_tri.sip_xirr_comparison_across_indices(
+ indices=[index, index_1],
+ folder_path=tmp_dir,
+ excel_file=os.path.join(tmp_dir, 'compare_sip_xirr_across_indices.xlsx')
+ )
+ assert len(aggregate_df.columns) == 2
# error test for unequal end date of two indices
nse_tri.download_historical_daily_data(
index='NIFTY ALPHA 50',
@@ -527,11 +535,20 @@ def test_sip(
figure_file=figure_file
)
assert exc_info.value.args[0] == 'Last date must be equal across all indices in the Excel files.'
+ # SIP growth comparison
with pytest.raises(Exception) as exc_info:
nse_tri.sip_growth_comparison_across_indices(
indices=['NIFTY 50', 'NIFTY ALPHA 50'],
folder_path=tmp_dir,
- excel_file=os.path.join(tmp_dir, 'sip_invest_growth_across_indices.xlsx')
+ excel_file=os.path.join(tmp_dir, 'comare_sip_growth_across_indices.xlsx')
+ )
+ assert exc_info.value.args[0] == 'Last date must be equal across all indices in the Excel files.'
+ # SIP XIRR comparison
+ with pytest.raises(Exception) as exc_info:
+ nse_tri.sip_xirr_comparison_across_indices(
+ indices=['NIFTY 50', 'NIFTY ALPHA 50'],
+ folder_path=tmp_dir,
+ excel_file=os.path.join(tmp_dir, 'compare_sip_xirr_across_indices.xlsx')
)
assert exc_info.value.args[0] == 'Last date must be equal across all indices in the Excel files.'
# error test for invalid input of year and month
@@ -637,6 +654,14 @@ def test_error_excel(
)
assert exc_info.value.args[0] == message['error_excel']
+ with pytest.raises(Exception) as exc_info:
+ nse_tri.sip_xirr_comparison_across_indices(
+ indices=['NIFTY 50'],
+ folder_path=r"C:\Users\Username\Folder",
+ excel_file='output.xl'
+ )
+ assert exc_info.value.args[0] == message['error_excel']
+
def test_error_figure(
visual,