Skip to content

Commit

Permalink
minor updates
Browse files Browse the repository at this point in the history
  • Loading branch information
krishnakuruvadi committed Jan 20, 2025
1 parent 51f3b12 commit 11dbdc8
Show file tree
Hide file tree
Showing 4 changed files with 3,035 additions and 1,308 deletions.
16 changes: 15 additions & 1 deletion India/code/helpers/mf_amfi.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
from mftool import Mftool
import json
import pandas as pd
from .mf_entry import write_entries, get_new_entry, get_mf_entries
from .utils import get_float_or_zero_from_string

Expand Down Expand Up @@ -76,7 +78,19 @@ def get_schemes(as_json=False):
print(f'ignoring fund with no isin: {scheme_data}')
ignored += 1

return mf.render_response(scheme_info, as_json), ignored
return render_response(scheme_info, as_json), ignored

def render_response(data, as_json=False, as_Dataframe=False):
if as_json is True:
return json.dumps(data)
# parameter 'as_Dataframe' only works with get_scheme_historical_nav()
elif as_Dataframe is True:
df = pd.DataFrame.from_records(data['data'])
df['dayChange'] = df['nav'].astype(float).diff(periods=-1)
df = df.set_index('date')
return df
else:
return data

'''
def get_amfi_schemes():
Expand Down
4 changes: 2 additions & 2 deletions India/code/helpers/mf_kuvera.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,15 +28,15 @@ def update_kuvera_mapping():
for fund in fund_details:
name = fund['n']
code = fund['c']
scheme_url = f"https://api.kuvera.in/mf/api/v4/fund_schemes/{code}.json"
scheme_url = f"https://api.kuvera.in/mf/api/v5/fund_schemes/{code}.json?v=1.230.10"

response = requests.get(scheme_url, timeout=15)
if response.status_code != 200:
print('failed to get scheme details for {scheme_url}')
continue
j = response.json()
#dt = fund['r'].get('date')
#print(j)
print(f'{scheme_url} got {j}')
k_isin = j[0]['ISIN']
for code,det in a_schemes.items():
if k_isin != '' and (det['isin1'] == k_isin or det['isin2'] == k_isin):
Expand Down
Loading

0 comments on commit 11dbdc8

Please sign in to comment.