Skip to content

Commit

Permalink
v2024.12.5 - various bug fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
codereverser committed Dec 5, 2024
1 parent aaa21fd commit 9c28178
Show file tree
Hide file tree
Showing 6 changed files with 684 additions and 593 deletions.
19 changes: 8 additions & 11 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,17 +1,14 @@
repos:
- repo: 'https://github.com/pre-commit/pre-commit-hooks'
rev: v4.4.0
hooks:
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: v0.0.287
rev: v0.8.2
hooks:
- id: ruff-format
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: 'https://github.com/psf/black'
rev: 23.7.0
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.5.0
hooks:
- id: black
- id: trailing-whitespace
- id: end-of-file-fixer
- id: check-yaml
- id: check-added-large-files
2 changes: 1 addition & 1 deletion casparser_isin/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,4 @@
"__version__",
]

__version__ = "2023.9.10"
__version__ = "2024.12.5"
Binary file modified casparser_isin/isin.db
Binary file not shown.
17 changes: 11 additions & 6 deletions casparser_isin/mf_isin.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
from collections import namedtuple
from decimal import Decimal
import re
import sqlite3
from collections import namedtuple
from decimal import Decimal
from typing import Optional

from rapidfuzz import process, utils
from rapidfuzz import fuzz, process, utils

from .utils import get_isin_db_path

Expand Down Expand Up @@ -74,7 +74,9 @@ def direct_isin_lookup(self, isin: str):
:param isin: Fund ISIN
:return:
"""
sql = """SELECT name, isin, amfi_code, type from scheme WHERE isin = :isin"""
sql = (
"""SELECT name, isin, amfi_code, type from scheme WHERE isin = :isin order by id desc"""
)
return self.run_query(sql, {"isin": isin})

def scheme_lookup(self, rta: str, scheme_name: str, rta_code: str):
Expand Down Expand Up @@ -118,7 +120,7 @@ def scheme_lookup(self, rta: str, scheme_name: str, rta_code: str):
else:
where.append("rta_code = :rta_code")

sql_statement = "{} WHERE {} GROUP BY isin".format(sql, " AND ".join(where))
sql_statement = "{} WHERE {} order by id desc".format(sql, " AND ".join(where))
results = self.run_query(sql_statement, args)
if len(results) == 0 and "rta_code" in args:
args["rta_code"] = args["rta_code"][:-1]
Expand Down Expand Up @@ -172,7 +174,10 @@ def isin_lookup(
x["name"]: (x["name"], x["isin"], x["amfi_code"], x["type"]) for x in results
}
key, score, _ = process.extractOne(
scheme_name, schemes.keys(), processor=utils.default_process
scheme_name,
schemes.keys(),
processor=utils.default_process,
scorer=fuzz.token_sort_ratio,
)
if score >= min_score:
name, isin, amfi_code, scheme_type = schemes[key]
Expand Down
Loading

0 comments on commit 9c28178

Please sign in to comment.