add historical shares into db
This commit is contained in:
parent
44a64c3277
commit
457db2ae4c
@ -1,13 +1,11 @@
|
||||
import aiohttp
|
||||
import asyncio
|
||||
import sqlite3
|
||||
import certifi
|
||||
import json
|
||||
import ujson
|
||||
import pandas as pd
|
||||
import os
|
||||
from tqdm import tqdm
|
||||
import re
|
||||
import pandas as pd
|
||||
from datetime import datetime
|
||||
from ta.utils import *
|
||||
@ -15,8 +13,6 @@ from ta.volatility import *
|
||||
from ta.momentum import *
|
||||
from ta.trend import *
|
||||
from ta.volume import *
|
||||
import subprocess
|
||||
import time
|
||||
import warnings
|
||||
|
||||
from dotenv import load_dotenv
|
||||
@ -118,7 +114,8 @@ class StockDatabase:
|
||||
f"https://financialmodelingprep.com/api/v3/ratios/{symbol}?period=quarter&apikey={api_key}",
|
||||
f"https://financialmodelingprep.com/api/v3/historical-price-full/stock_split/{symbol}?apikey={api_key}",
|
||||
f"https://financialmodelingprep.com/api/v4/stock_peers?symbol={symbol}&apikey={api_key}",
|
||||
f"https://financialmodelingprep.com/api/v4/institutional-ownership/institutional-holders/symbol-ownership-percent?date=2023-09-30&symbol={symbol}&page=0&apikey={api_key}",
|
||||
f"https://financialmodelingprep.com/api/v4/institutional-ownership/institutional-holders/symbol-ownership-percent?date=2024-03-31&symbol={symbol}&page=0&apikey={api_key}",
|
||||
f"https://financialmodelingprep.com/api/v4/historical/shares_float?symbol={symbol}&apikey={api_key}",
|
||||
f"https://financialmodelingprep.com/api/v4/revenue-product-segmentation?symbol={symbol}&structure=flat&period=annual&apikey={api_key}",
|
||||
f"https://financialmodelingprep.com/api/v4/revenue-geographic-segmentation?symbol={symbol}&structure=flat&apikey={api_key}",
|
||||
f"https://financialmodelingprep.com/api/v3/analyst-estimates/{symbol}?apikey={api_key}",
|
||||
@ -315,6 +312,9 @@ class StockDatabase:
|
||||
elif "institutional-ownership/institutional-holders" in url:
|
||||
# Handle list response, save as JSON object
|
||||
fundamental_data['shareholders'] = ujson.dumps(parsed_data)
|
||||
elif "historical/shares_float" in url:
|
||||
# Handle list response, save as JSON object
|
||||
fundamental_data['historicalShares'] = ujson.dumps(parsed_data)
|
||||
elif "revenue-product-segmentation" in url:
|
||||
# Handle list response, save as JSON object
|
||||
fundamental_data['revenue_product_segmentation'] = ujson.dumps(parsed_data)
|
||||
|
||||
15
app/main.py
15
app/main.py
@ -1,7 +1,7 @@
|
||||
import random
|
||||
import numpy as np
|
||||
from fastapi import FastAPI,Depends,HTTPException, status
|
||||
from typing import List, Dict, Union, Set
|
||||
from typing import List, Dict, Set
|
||||
from fastapi.middleware.cors import CORSMiddleware
|
||||
|
||||
from fastapi.openapi.docs import get_swagger_ui_html
|
||||
@ -10,23 +10,16 @@ from fastapi.security import HTTPBasic, HTTPBasicCredentials
|
||||
import secrets
|
||||
from benzinga import financial_data
|
||||
|
||||
from GetStartEndDate import GetStartEndDate
|
||||
|
||||
import ssl
|
||||
import io
|
||||
import gzip
|
||||
from fastapi.responses import StreamingResponse
|
||||
|
||||
from collections import defaultdict
|
||||
from datetime import date, datetime, timedelta, time
|
||||
import json
|
||||
import ujson
|
||||
import pandas as pd
|
||||
import sqlite3
|
||||
from pydantic import BaseModel
|
||||
#from arima import arima
|
||||
import re
|
||||
import asyncio
|
||||
import aiohttp
|
||||
#import time
|
||||
import pandas as pd
|
||||
@ -115,10 +108,6 @@ cursor_inst.close()
|
||||
load_dotenv()
|
||||
|
||||
pb = PocketBase('http://127.0.0.1:8090')
|
||||
pb_admin_email = os.getenv('POCKETBASE_ADMIN_EMAIL')
|
||||
pb_password = os.getenv('POCKETBASE_PASSWORD')
|
||||
|
||||
admin_data = pb.admins.auth_with_password(pb_admin_email, pb_password)
|
||||
|
||||
api_key = os.getenv('FMP_API_KEY')
|
||||
benzinga_key = os.getenv('BENZINGA_API_KEY')
|
||||
@ -2573,7 +2562,7 @@ async def get_wiim(data:TickerData):
|
||||
res = []
|
||||
|
||||
redis_client.set(cache_key, ujson.dumps(res))
|
||||
redis_client.expire(cache_key, 60*60*2) # Set cache expiration time to 1 day
|
||||
redis_client.expire(cache_key, 60*60*2)
|
||||
return res
|
||||
|
||||
@app.get("/rss-feed-wiim")
|
||||
|
||||
@ -3,6 +3,7 @@ let serverRunning = false;
|
||||
|
||||
const fastify = require('fastify')({})
|
||||
const cors = require('@fastify/cors');
|
||||
|
||||
//Load API KEYS
|
||||
require('dotenv').config({ path: '../app/.env' });
|
||||
const fmpAPIKey = process.env.FMP_API_KEY;
|
||||
|
||||
6
fastify/package-lock.json
generated
6
fastify/package-lock.json
generated
@ -1066,9 +1066,9 @@
|
||||
}
|
||||
},
|
||||
"node_modules/got": {
|
||||
"version": "11.8.3",
|
||||
"resolved": "https://registry.npmjs.org/got/-/got-11.8.3.tgz",
|
||||
"integrity": "sha512-7gtQ5KiPh1RtGS9/Jbv1ofDpBFuq42gyfEib+ejaRBJuj/3tQFeR5+gw57e4ipaU8c/rCjvX6fkQz2lyDlGAOg==",
|
||||
"version": "11.8.6",
|
||||
"resolved": "https://registry.npmjs.org/got/-/got-11.8.6.tgz",
|
||||
"integrity": "sha512-6tfZ91bOr7bOXnK7PRDCGBLa1H4U080YHNaAQ2KsMGlLEzRbk44nsZF2E1IeRc3vtJHPVbKCYgdFbaGO2ljd8g==",
|
||||
"dependencies": {
|
||||
"@sindresorhus/is": "^4.0.0",
|
||||
"@szmarczak/http-timer": "^4.0.5",
|
||||
|
||||
@ -8,8 +8,8 @@
|
||||
"axios": "^1.6.2",
|
||||
"blob-util": "^2.0.2",
|
||||
"cheerio": "^1.0.0-rc.12",
|
||||
"fastify": "^4.26.0",
|
||||
"dotenv": "^16.4.5",
|
||||
"fastify": "^4.26.0",
|
||||
"got": "^11.8.3",
|
||||
"https": "^1.0.0",
|
||||
"mixpanel": "^0.18.0",
|
||||
@ -24,4 +24,3 @@
|
||||
"nodemon": "^3.0.1"
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user