Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix Edge cases, adds workflows and updates dependencies #43

Open
wants to merge 88 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
21939c3
feat : adds renovate bot for upgrading dependencies
rajadilipkolli May 10, 2024
51bb8c4
fix : issue with starting docker in local
rajadilipkolli May 10, 2024
bccc396
fix : remove unnecessary change
rajadilipkolli May 10, 2024
3c38158
Merge pull request #5 from rajadilipkolli/patch-1
rajadilipkolli May 10, 2024
54f135e
fix : permission issue as a non root user
rajadilipkolli May 10, 2024
c4d68ff
fix : issue while building image
rajadilipkolli May 10, 2024
9bb7e88
fix : edge cases
rajadilipkolli May 11, 2024
fbab549
Merge pull request #10 from rajadilipkolli/fix-permission
rajadilipkolli May 11, 2024
8e5783c
chore(deps): update dependency @types/nuxtjs__auth to v4.8.11 (#2)
renovate[bot] May 11, 2024
3477e09
fix(deps): update dependency @nuxtjs/auth-next to v5.0.0-1667386184.d…
renovate[bot] May 11, 2024
2c880d6
chore(deps): update dependency celery to v5.4.0 (#16)
renovate[bot] May 11, 2024
d47bb44
chore(deps): update dependency django-celery-beat to v2.6.0 (#18)
renovate[bot] May 11, 2024
b385680
chore(deps): update dependency django-environ to v0.11.2 (#20)
renovate[bot] May 11, 2024
06dc3f7
chore(deps): update dependency djangorestframework to v3.15.1 (#23)
renovate[bot] May 11, 2024
8e5cedc
chore(deps): update dependency django-celery-results to v2.5.1 (#19)
renovate[bot] May 11, 2024
6e0d368
chore(deps): update dependency django-import-export to v2.9.0 (#21)
renovate[bot] May 11, 2024
d89fbad
chore(deps): update dependency djangorestframework-simplejwt to v5.3.…
renovate[bot] May 11, 2024
9baaf42
chore(deps): update dependency django-redis to v5.4.0 (#22)
renovate[bot] May 11, 2024
6ffe64d
chore(deps): update dependency django to v4.2.13 (#17)
renovate[bot] May 11, 2024
427e376
chore(deps): update dependency eslint-config-prettier to v8.10.0 (#25)
renovate[bot] May 11, 2024
50ee05e
chore(deps): update dependency postcss to v8.4.38 (#26)
renovate[bot] May 11, 2024
e3beadf
chore(deps): update dependency autoprefixer to v10.4.19 (#14)
renovate[bot] May 11, 2024
4d62411
fix(deps): update dependency highcharts to v9.3.3 (#8)
renovate[bot] May 11, 2024
0cbbd12
fix(deps): update dependency nuxt-highcharts to v2.0.4 (#9)
renovate[bot] May 11, 2024
a2d26f0
chore(deps): update dependency redis to v4.4.4 [security] (#28)
renovate[bot] May 11, 2024
7fdc6e4
chore(deps): update dependency prettier to v2.8.8 (#27)
renovate[bot] May 11, 2024
cad5e25
chore(deps): update dependency sentry-sdk to v1.14.0 [security] (#30)
renovate[bot] May 11, 2024
9cb5b71
chore(deps): update dependency @babel/eslint-parser to v7.24.5 (#11)
renovate[bot] May 11, 2024
37bee9e
chore(deps): update dependency @nuxtjs/eslint-module to v3.1.0 (#12)
renovate[bot] May 11, 2024
4c69f2e
chore(deps): update dependency @nuxtjs/stylelint-module to v4.2.2 (#13)
renovate[bot] May 11, 2024
7f99392
chore(deps): update dependency requests to v2.31.0 [security] (#29)
renovate[bot] May 11, 2024
d69e20b
chore(deps): update dependency gunicorn to v22 [security] (#31)
renovate[bot] May 11, 2024
84fe500
chore(deps): update dependency quandl to v3.7.0
renovate[bot] May 11, 2024
2d22b48
chore(deps): update dependency redis to v4.6.0
renovate[bot] May 11, 2024
51bf554
chore(deps): update dependency casparser to v0.7.4 (#15)
renovate[bot] May 11, 2024
6918fdb
chore(deps): update dependency sass to v1.77.1
renovate[bot] May 11, 2024
5ef499b
chore(deps): update dependency sentry-sdk to v1.45.0 (#37)
renovate[bot] May 11, 2024
33ae9d8
fix : issue with parsing the pdf data (#41)
rajadilipkolli May 11, 2024
32d194c
chore(deps): update dependency sass-loader to v10.5.2
renovate[bot] May 11, 2024
98c40fe
chore(deps): update dependency tablib to v3.6.1
renovate[bot] May 11, 2024
a4b5661
chore(deps): update yarn to v3.8.2
renovate[bot] May 12, 2024
e0d256e
fix(deps): update dependency @vue/composition-api to v1.7.2
renovate[bot] May 12, 2024
3716cc1
fix : issue with calculating xirr
rajadilipkolli May 12, 2024
559f37a
fix(deps): update dependency nuxt-typed-vuex to ^0.3.0 (#45)
renovate[bot] May 12, 2024
5c9a8bd
fix(deps): update dependency core-js to v3.37.0
renovate[bot] May 12, 2024
34d05a8
fix(deps): update dependency primevue to v2.10.4
renovate[bot] May 12, 2024
d259df1
Revert : UI changes
rajadilipkolli May 16, 2024
7d25286
fix : permission issue
rajadilipkolli May 16, 2024
cc3cc5f
Revert-casparser-update (#54)
rajadilipkolli May 16, 2024
07a71ae
build(deps): bump the npm_and_yarn group across 1 directory with 19 u…
dependabot[bot] May 16, 2024
21be908
fix(deps): update dependency nuxt-typed-vuex to ^0.3.0 (#55)
rajadilipkolli May 16, 2024
98eca70
chore(deps): update dependency @nuxtjs/eslint-module to v3.1.0 (#57)
renovate[bot] May 16, 2024
2daa994
chore(deps): update dependency @nuxtjs/eslint-module to v4 (#51)
renovate[bot] May 16, 2024
d42c835
chore(deps): update dependency @nuxtjs/stylelint-module to v4.2.2 (#58)
renovate[bot] May 16, 2024
698718d
feat : remove dead code and organize imports
rajadilipkolli May 16, 2024
2f4c941
chore(deps): update dependency @babel/eslint-parser to v7.24.5 (#56)
renovate[bot] May 19, 2024
940761e
chore(deps): update dependency @nuxtjs/stylelint-module to v5 (#52)
renovate[bot] May 19, 2024
3d85b31
chore(deps): update dependency @types/nuxtjs__auth to v4.8.11 (#59)
renovate[bot] May 19, 2024
b24311f
chore(deps): update dependency @nuxtjs/eslint-config to v12 (#49)
renovate[bot] May 19, 2024
df1736d
fix(deps): update dependency highcharts to v9.3.3 (#62)
renovate[bot] May 19, 2024
cc3ac98
chore(deps): update yarn to v3.8.2 (#61)
renovate[bot] May 19, 2024
911ee59
fix(deps): update dependency nuxt-highcharts to v2.0.4 (#63)
renovate[bot] May 19, 2024
50cb779
fix(deps): update dependency @nuxtjs/auth-next to v5.0.0-1667386184.d…
renovate[bot] May 19, 2024
27f8972
build(deps): bump qs in /ui in the npm_and_yarn group across 1 direct…
dependabot[bot] May 19, 2024
f686587
chore(deps): update dependency autoprefixer to v10.4.19 (#65)
renovate[bot] May 19, 2024
0809a16
fix: handle case where KYC is NoneType (#67)
rajadilipkolli May 19, 2024
448d7bc
chore(deps): update dependency eslint-config-prettier to v8.10.0 (#68)
renovate[bot] May 19, 2024
e9fbf5d
chore(deps): update dependency prettier to v2.8.8 (#69)
renovate[bot] May 19, 2024
ae1bc8b
chore(deps): update dependency sass to v1.77.2
renovate[bot] May 19, 2024
7429017
chore(deps): update dependency sass-loader to v10.5.2 (#71)
renovate[bot] May 19, 2024
10201ba
fix(deps): update dependency @vue/composition-api to v1.7.2 (#73)
renovate[bot] May 19, 2024
6aaa09a
chore(deps): update dependency @nuxtjs/eslint-config-typescript to v1…
renovate[bot] May 19, 2024
0d1f838
fix(deps): update dependency core-js to v3.37.1
renovate[bot] May 19, 2024
f1176f5
fix(deps): update dependency primevue to v2.10.4 (#75)
renovate[bot] May 20, 2024
49ec06a
chore(deps): update dependency redis to v5 (#81)
renovate[bot] May 21, 2024
20815d2
chore(deps): update dependency requests to v2.32.0 [security]
renovate[bot] May 21, 2024
70fef29
chore(deps): update dependency requests to v2.32.1 (#80)
renovate[bot] May 21, 2024
afb1484
chore(deps): update dependency pug to v3.0.3 [security]
renovate[bot] May 28, 2024
b5f6482
chore(deps): update dependency django to v5 (#77)
renovate[bot] Jun 3, 2024
9e1619c
chore(deps): update dependency djangorestframework to v3.15.2 [security]
renovate[bot] Jun 26, 2024
2a2fc70
build(deps): bump ws from 7.5.5 to 7.5.10 in /ui (#87)
dependabot[bot] Jun 28, 2024
9bfe31f
feat : adds debugger extension
rajadilipkolli Jun 28, 2024
a20bd86
feat : update browser list
rajadilipkolli Jun 28, 2024
7aee645
chore(deps): update yarn to v3.8.3 (#91)
renovate[bot] Jun 28, 2024
590f0b8
chore(deps): update dependency redis to v5.0.7
renovate[bot] Jun 28, 2024
4065916
chore(deps): update dependency django to v5.0.7 [security]
renovate[bot] Jul 10, 2024
27109e2
build(deps): bump sentry-sdk from 1.45.0 to 2.8.0 in /api (#95)
dependabot[bot] Aug 2, 2024
233ce0f
chore(deps): update dependency django to v5.0.8 [security]
renovate[bot] Aug 7, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .devcontainer/devcontainer.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
// For format details, see https://aka.ms/devcontainer.json. For config options, see the
// README at: https://github.com/devcontainers/templates/tree/main/src/python
{
"name": "Python 3",
// Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
"image": "mcr.microsoft.com/devcontainers/python:1-3.12-bullseye",
"customizations": {
"vscode": {
"extensions": [
"ms-python.python",
"Vue.volar",
"ms-python.debugpy"
]
}
},

// Features to add to the dev container. More info: https://containers.dev/features.
"features": {
"ghcr.io/devcontainers/features/docker-in-docker:2": {},
"ghcr.io/devcontainers/features/github-cli:1": {},
"ghcr.io/devcontainers/features/node:1": {}
},

// Use 'forwardPorts' to make a list of ports inside the container available locally.
"forwardPorts": [5050, 8000]

// Use 'postCreateCommand' to run commands after the container is created.
// "postCreateCommand": "pip3 install --user -r requirements.txt",

// Configure tool-specific properties.
// "customizations": {},

// Uncomment to connect as root instead. More info: https://aka.ms/dev-containers-non-root.
// "remoteUser": "root"
}
12 changes: 12 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# To get started with Dependabot version updates, you'll need to specify which
# package ecosystems to update and where the package manifests are located.
# Please see the documentation for more information:
# https://docs.github.com/github/administering-a-repository/configuration-options-for-dependency-updates
# https://containers.dev/guide/dependabot

version: 2
updates:
- package-ecosystem: "devcontainers"
directory: "/"
schedule:
interval: weekly
51 changes: 51 additions & 0 deletions .github/workflows/api.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: Django Tests CI

on:
push:
paths:
- "api/**"
branches: [ main ]
pull_request:
paths:
- "api/**"
types:
- opened
- synchronize
- reopened

jobs:
build:
name: Run Unit & Integration Tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: "./api"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.11'
cache: 'pip'
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
- name: Install Required softwares
run: |
cd ..
docker compose up -d timedb cache
sleep 5
docker ps -a
- name: Test
env:
SECRET_KEY: '%k8!x4pm=mf!iqz^jws)ijn=)-md-uf_i=^mya1t*d!4f#^74k'
DATABASE_URL: psql://postgres:foliop4sswd@127.0.0.1:15432/folioman
CACHE_URL: rediscache://localhost:16379/1?client_class=django_redis.client.DefaultClient&timeout=86400
CELERY_BROKER_URL: redis://localhost:16379/3
CELERY_RESULT_BACKEND: redis://localhost:16379/5
QUANDL_API_KEY: PUT_QUANDL_API_HERE
ENVIRONMENT: dev
run: python manage.py test folioman.tests mutualfunds.tests
36 changes: 36 additions & 0 deletions .github/workflows/ui.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Nuxt Build CI

on:
push:
paths:
- "ui/**"
branches: [ main ]
pull_request:
paths:
- "ui/**"
types:
- opened
- synchronize
- reopened

jobs:
build:
name: Run Unit & Integration Tests
runs-on: ubuntu-latest
defaults:
run:
working-directory: "./ui"
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0 # Shallow clones should be disabled for a better relevancy of analysis
- name: Install dependencies
run: yarn
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "16"
- name: RUN build
run: |
yarn install
yarn run build
5 changes: 5 additions & 0 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@

vscode:
extensions:
- ms-python.python
- Vue.volar
42 changes: 42 additions & 0 deletions .vscode/launch.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
{
// Use IntelliSense to learn about possible attributes.
// Hover to view descriptions of existing attributes.
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
"version": "0.2.0",
"configurations": [
{
"name": "Django",
"type": "debugpy",
"request": "launch",
"args": [
"runserver"
],
"django": true,
"autoStartBrowser": false,
"program": "${workspaceFolder}/api/manage.py"
},
{
"name": "Celery",
"type": "debugpy",
"request": "launch",
"module": "celery",
"console": "integratedTerminal",
"cwd": "${workspaceFolder}/api",
"args": [
"-A",
"taskman",
"worker",
"-l",
"info",
"-P",
"solo",
]
}
],
"compounds": [
{
"name": "Celery and Django",
"configurations": ["Celery", "Django"]
}
]
}
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Once the process is complete, visit the following urls to get started.

- http://localhost:8000 - frontend
- http://localhost:8000/admin/ - backend
- http://localhost:5050 - pgadmin

The default username and password is given below; it can be changed from the backend dashboard.
```
Expand Down
33 changes: 33 additions & 0 deletions api/ReadMe.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@

## Start in local

assuming python is installed, open code in Visual Studio Code, right-click and select 'Run Python'.

This will prompt you to create a virtual environment, select `.venv`, and install all required software.

then open the terminal and issue the command below to set up lookup data

```shell
python manage.py migrate
```

Issue below command to start local server

```shell
python manage.py runserver
```

## How to update the dependencies in virtual environment

```shell
pip install -r requirements.txt
```

## Running the Celery worker
In the new terminal tab, run the following command:

```shell
celery -A taskman worker -l info -P solo
```

where celery is the version of Celery, with the -A option to specify the celery instance to use (in our case, it's celery in the app.py file, so it's taskman), and worker is the subcommand to run the worker, and --loglevel=info to set the verbosity log level to INFO.
2 changes: 0 additions & 2 deletions api/env.example
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,6 @@ DATABASE_URL=psql://postgres:foliop4sswd@timedb:5432/folioman
CACHE_URL=rediscache://cache:6379/1?client_class=django_redis.client.DefaultClient&timeout=86400
CELERY_BROKER_URL=redis://cache:6379/3
CELERY_RESULT_BACKEND=redis://cache:6379/5
QUANDL_API_KEY=PUT_QUANDL_API_HERE
# help: https://help.quandl.com/article/320-where-can-i-find-my-api-key

# Uncomment and update the following variable to enable sentry logging support.
# SENTRY_DSN="https://projectcode@sentry.example.com/pid"
Expand Down
2 changes: 1 addition & 1 deletion api/folioman/urls.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from django.urls import path
from rest_framework.urlpatterns import format_suffix_patterns
from . import views

from . import views

urlpatterns = [
path("me", views.UserView.as_view(), name="me"),
Expand Down
11 changes: 6 additions & 5 deletions api/mutualfunds/importers/cas.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
from datetime import date
import re
from typing import List

from casparser.types import CASParserDataType, FolioType
from dateutil.parser import parse as dateparse
from typing import List

from mutualfunds.models import (
Portfolio,
Expand All @@ -26,19 +25,19 @@ def import_cas(data: CASParserDataType, user_id):
if not (email and name):
raise ValueError("Email or Name invalid!")

folios: List[FolioType] = data.get("folios", []) or []
try:
pf = Portfolio.objects.get(email=email)
except Portfolio.DoesNotExist:
pf = Portfolio(
email=email, name=name, user_id=user_id, pan=(investor_info.get("pan") or "").strip()
email=email, name=name, user_id=user_id, pan=(folios[0].get("PAN") or "").strip()
)
pf.save()

num_created = 0
num_total = 0
new_folios = 0

folios: List[FolioType] = data.get("folios", []) or []
fund_scheme_ids = []
scheme_dates = {}
for folio in folios:
Expand Down Expand Up @@ -92,6 +91,8 @@ def import_cas(data: CASParserDataType, user_id):
folio["PANKYC"] = "notok"
if not folio["PAN"]:
folio["PAN"] = "noregister"
if not folio["KYC"]:
folio["KYC"] = "notok"
folio_obj = Folio(
amc_id=folio["amc_id"],
number=folio_number,
Expand Down Expand Up @@ -131,7 +132,7 @@ def import_cas(data: CASParserDataType, user_id):
units=str(transaction["units"] or 0),
defaults={
"description": transaction["description"].strip(),
"amount": transaction["amount"],
"amount": transaction["amount"] or 0.00001,
"nav": transaction["nav"] or 0,
"order_type": Transaction.get_order_type(
transaction["description"], transaction["amount"]
Expand Down
2 changes: 1 addition & 1 deletion api/mutualfunds/importers/daily_value.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
"""Bulk import various DailyValue models"""

import pandas as pd
from import_export.fields import Field
from import_export.instance_loaders import ModelInstanceLoader
from import_export.resources import ModelResource
from import_export.widgets import DateWidget
import pandas as pd

from mutualfunds.models import FolioValue, PortfolioValue, SchemeValue

Expand Down
46 changes: 1 addition & 45 deletions api/mutualfunds/importers/fetcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@
import io
import logging
import re
import zipfile

import requests
from django.conf import settings
from lxml.html import fromstring
import requests
from requests.utils import default_user_agent

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -35,49 +34,6 @@ def fetch_bse_star_master_data():
logger.info("BSE Master data downloaded.")
return response.text


def fetch_quandl_amfi_metadata():
logger.info("Downloading quandl AMFI data...")
params = {"api_key": settings.QUANDL_API_KEY}
response = requests.get(settings.QUANDL_METADATA_URL, params=params, timeout=300)
if response.status_code != 200:
raise requests.exceptions.RequestException("Invalid response!")
content = io.BytesIO(response.content)
data = {}
dividends = ("payout", "reinvest")

def category(x):
name = x["name"]
desc = x["description"].lower()
if "payout" in name.lower() or (
"payout" in desc and "reinvest" not in desc and "growth" not in desc
):
return "payout"
elif "reinvest" in name.lower() or (
"payout" not in desc and "reinvest" in desc and "growth" not in desc
):
return "reinvest"
return "n/a"

with zipfile.ZipFile(content) as zipf:
with zipf.open("AMFI_metadata.csv") as csvf:
reader = csv.DictReader(io.TextIOWrapper(csvf, encoding="utf-8"))
for row in reader:
isins = re.findall(r"\sIN[a-zA-Z0-9]{10}", row["description"])

is_dividend = False
if len(isins) > 2:
raise ValueError("Unexpected layout. Debug needed")
elif len(isins) == 2:
is_dividend = True
for idx, isin in enumerate(isins):
if is_dividend:
data[isin.strip()] = row, dividends[idx]
else:
data[isin.strip()] = row, category(row)
return data


def fetch_amfi_scheme_data():
logger.info("Downloading AMFI scheme data...")
response = requests.get(settings.AMFI_SCHEME_DATA_URL, timeout=300)
Expand Down
4 changes: 2 additions & 2 deletions api/mutualfunds/importers/master.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,17 +7,17 @@
import tablib
from dateutil.parser import parse as dateparse
from import_export.fields import Field
from import_export.resources import ModelResource
from import_export.instance_loaders import CachedInstanceLoader
from import_export.resources import ModelResource
from import_export.results import Error, Result, RowResult
from rapidfuzz import fuzz, process

from mutualfunds.models import AMC, FundCategory, FundScheme
from mutualfunds.importers.fetcher import (
fetch_amfi_code_isin_mapping,
fetch_amfi_scheme_data,
fetch_bse_star_master_data
)
from mutualfunds.models import AMC, FundCategory, FundScheme

logger = logging.getLogger(__name__)

Expand Down
Loading