Posts

Showing posts from August, 2023

how to make django api steps

 steps to proceed in django 1) installation python,django,rest_framework 2) create model (which type of data you want with all feilds) 3) serialisers (to convert data to django understandable lanuage)  a) used hyperlinkmodelserialisers4)  4) views banaya  companyviewset , isme serialiser class banaya and querry set me all abject data  5) then come to urls and do the mapping by help of router , register krna padta h router ko  6) 

strike project django url file

 from django.urls import path from .views import UserSelectedAPI,GetNearestStrikAPI,GetTrendingStrikAPI urlpatterns = [     path("user_selected_price", UserSelectedAPI.as_view()),     path("get_nearest_strike", GetNearestStrikAPI.as_view()),     path("get_trending_strike", GetTrendingStrikAPI.as_view()), ]

strike project django utlis

 import pytz import json import os from datetime import datetime, timedelta from multistrikeoi.get_nearest_strike import UserSelectedPrice as usp from django.db import connection import pandas as pd from rest_framework.request import Request from rest_framework.response import Response from rest_framework import status today_string=None yesterday_string=None tomorrow_string=None def detect_day(today):     global today_string, yesterday_string, tomorrow_string     date_string = today     parsed_date = datetime.strptime(date_string, "%Y-%m-%d")     day_of_week = parsed_date.weekday()     day_of_week_string = parsed_date.strftime("%A")     # print(day_of_week)     # print(day_of_week_string)     date_string = today     parsed_date = datetime.strptime(date_string, "%Y-%m-%d")     yesterday = parsed_date - timedelta(days=1)     yesterday_string = yesterday.strftime("%Y-%m-%d") ...

strike project django get nearest strike

 import pandas as pd from django.db import connection from datetime import datetime, timedelta import pytz today_string=None yesterday_string=None tomorrow_string=None def detect_day(today):     global today_string, yesterday_string, tomorrow_string     date_string = today     parsed_date = datetime.strptime(date_string, "%Y-%m-%d")     day_of_week = parsed_date.weekday()     day_of_week_string = parsed_date.strftime("%A")     # print(day_of_week)     # print(day_of_week_string)     date_string = today     parsed_date = datetime.strptime(date_string, "%Y-%m-%d")     yesterday = parsed_date - timedelta(days=1)     yesterday_string = yesterday.strftime("%Y-%m-%d")     # print("Yesterday's date:", yesterday_string)     if day_of_week == 0:         yesterday = parsed_date - timedelta(days=3)         yesterday_string = ...

strike project django user selected strike file

 import pandas as pd from django.db import connection from  multistrikeoi.utlis import utils as u from datetime import datetime,timedelta today_string=None yesterday_string=None tomorrow_string=None class UserSelectedPrice:     def combined_oi_calculation(         symbol,         instrument,         strikeprice,         option_type,         expiery,         today,         tomorrow,     ):         print(today)         print(tomorrow)         engine = connection         df = pd.read_sql_query(             f"""             SELECT symbol, expiry_date, strike_price, created_at, ticker, instrument_name, option_type, open_interest FROM indiacharts.fno_prices fp        ...

strike project django view

 import json from django.shortcuts import render from rest_framework.views import APIView from rest_framework import permissions from rest_framework.request import Request from  multistrikeoi.user_selected_price  import UserSelectedPrice as usp from multistrikeoi.serializers import UserSelectedSerializer,GetNearestStrike,GetTrendingStrike from  multistrikeoi.utlis import utils as u from datetime import datetime,timedelta import os from rest_framework.response import Response from rest_framework import status import pandas as pd from django.db import connection today_string=None yesterday_string=None tomorrow_string=None def detect_day(today):     global today_string, yesterday_string, tomorrow_string     date_string = today     parsed_date = datetime.strptime(date_string, "%Y-%m-%d")     day_of_week = parsed_date.weekday()     day_of_week_string = parsed_date.strftime("%A")     # print(day_of_week)   ...