Initial Commit
This commit is contained in:
commit
ec6e64af01
|
@ -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>'
|
|
@ -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
|
|
@ -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 $*
|
|
@ -0,0 +1 @@
|
|||
ISIN,code
|
|
Loading…
Reference in New Issue