Initial Commit

This commit is contained in:
Nemo 2023-03-27 13:26:17 +05:30
commit ec6e64af01
5 changed files with 4492 additions and 0 deletions

19
.github/workflows/update.yml vendored Normal file
View File

@ -0,0 +1,19 @@
name: Update Data
on:
schedule:
# Run every 2 hours
- cron: '30 */2 * * *'
jobs:
update:
name: Update data
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
ref: ${{ github.head_ref }}
- name: Update data
run: make all
- uses: stefanzweifel/git-auto-commit-action@v4
with:
commit_message: Update Kuvera Mutual Fund Mapping
commit_author: 'github-actions[bot] <github-actions[bot]@users.noreply.github.com>'

9
Makefile Normal file
View File

@ -0,0 +1,9 @@
kuvera:
curl --retry 10 \
--connect-timeout 30 \
--retry-max-time 100 \
--silent https://api.kuvera.in/mf/api/v4/fund_schemes/list.json | \
jq -r '.[] | .[] | .[] | .[] | .c' | sort -u | xargs -n150 src/fetch.sh
sort -uo _.csv _.csv
cat src/header.csv _.csv > data.csv
rm _.csv

4435
data.csv Normal file

File diff suppressed because it is too large Load Diff

28
src/fetch.sh Executable file
View File

@ -0,0 +1,28 @@
#!/bin/bash
IFS='|'
fetch(){
c="$#"
f=$(mktemp -u --suffix=.json)
curl --request GET --fail \
--silent \
--url "https://api.kuvera.in/mf/api/v5/fund_schemes/$*.json" \
--header 'Content-Type: application/json' --output $f
if [ $? -ne 0 ]; then
if [ $c -ne 1 ]; then
half=$((c/2))
left=("${*:1:$half}")
right=("${*:$half+1}")
# Invoke an explicit subshell for recursion
(fetch $left )
(fetch $right )
else
echo "[FAIL] $*"
fi
else
cat "$f" | jq -r '.[] | [.ISIN,.code]|@csv' >> _.csv
fi
}
fetch $*

1
src/header.csv Normal file
View File

@ -0,0 +1 @@
ISIN,code
1 ISIN code