Release 1.0
This commit is contained in:
parent
7e0adeeda1
commit
1112df5b82
@ -27,7 +27,7 @@ from dash import Dash, html, dcc, callback, Output, Input, State, no_update, ctx
|
|||||||
from waitress import serve
|
from waitress import serve
|
||||||
from flask_caching import Cache
|
from flask_caching import Cache
|
||||||
from dash.exceptions import PreventUpdate
|
from dash.exceptions import PreventUpdate
|
||||||
from dash_auth import OIDCAuth
|
from dash_auth import BasicAuth
|
||||||
import yahoo_fin.stock_info as si
|
import yahoo_fin.stock_info as si
|
||||||
from dotenv import load_dotenv
|
from dotenv import load_dotenv
|
||||||
import os
|
import os
|
||||||
@ -57,7 +57,7 @@ def intelligent_loop_plots(sym : str, stk_data):
|
|||||||
"""
|
"""
|
||||||
price = stk_data["adjclose"]
|
price = stk_data["adjclose"]
|
||||||
vol = stk_data["volume"]
|
vol = stk_data["volume"]
|
||||||
stk = security(sym, price, vol)
|
stk = Security(sym, price, vol)
|
||||||
|
|
||||||
rsi = stk.rsi()
|
rsi = stk.rsi()
|
||||||
vorsi = stk.volume_rsi()
|
vorsi = stk.volume_rsi()
|
||||||
@ -166,55 +166,33 @@ def intelligent_loop_plots(sym : str, stk_data):
|
|||||||
|
|
||||||
return data, vol.to_frame('_VOL'), macd, rsi, plot_indicator
|
return data, vol.to_frame('_VOL'), macd, rsi, plot_indicator
|
||||||
|
|
||||||
# VALID_USERNAME_PASSWORD_PAIRS = {
|
VALID_USERNAME_PASSWORD_PAIRS = {
|
||||||
# 'ce16559af2caf7bb54bebd57a1602e29ada331b3356004265abeab0e568278cc':
|
os.environ['USER1']:os.environ['PASS1'],
|
||||||
# 'b4db36eb3f887ca0bc15de7feb0b41a9589b65dbd5325aedf1c76b3ee63b8871'
|
os.environ['USER2']:os.environ['PASS2'],
|
||||||
# }
|
}
|
||||||
|
|
||||||
# def user_login(username, password):
|
class Auth:
|
||||||
# if VALID_USERNAME_PASSWORD_PAIRS.get(hash_password(username)) == hash_password(password):
|
def __init__(self) -> None:
|
||||||
# return True
|
|
||||||
# return False
|
|
||||||
|
|
||||||
class OIDCAuthCustom(OIDCAuth): # overide OIDCAuth to get logged in user info
|
|
||||||
|
|
||||||
def __init__(self, *args, **kwargs):
|
|
||||||
self.username = None
|
self.username = None
|
||||||
super().__init__(*args, **kwargs)
|
|
||||||
|
|
||||||
def callback(self, idp: str):
|
def user_login(self, username, password):
|
||||||
return_value = super().callback(idp)
|
if VALID_USERNAME_PASSWORD_PAIRS.get(username) == hash_password(password):
|
||||||
|
self.username = username
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
client = self.get_oauth_client(idp)
|
auth = Auth()
|
||||||
self.username = client.userinfo().get("username")
|
|
||||||
# ...
|
|
||||||
|
|
||||||
return return_value
|
|
||||||
|
|
||||||
# Initialize the app
|
# Initialize the app
|
||||||
app = Dash(__name__)
|
app = Dash(__name__)
|
||||||
|
|
||||||
# dash_auth.BasicAuth(
|
BasicAuth(
|
||||||
# app,
|
app,
|
||||||
# # VALID_USERNAME_PASSWORD_PAIRS,
|
# VALID_USERNAME_PASSWORD_PAIRS,
|
||||||
# auth_func=user_login,
|
auth_func=auth.user_login,
|
||||||
# secret_key="MK8dyS6PyDDuEuzrmqa7dJTJZ7eH2Jkh",
|
secret_key=os.environ['SECRET_KEY'],
|
||||||
# )
|
|
||||||
|
|
||||||
# auth = OIDCAuth(app, secret_key=os.environ['SECRET_KEY'])
|
|
||||||
|
|
||||||
auth = OIDCAuthCustom(app, secret_key=os.environ['SECRET_KEY'])
|
|
||||||
|
|
||||||
auth.register_provider(
|
|
||||||
"stock",
|
|
||||||
token_endpoint_auth_method="client_secret_post",
|
|
||||||
client_id=os.environ['APP_ID'],
|
|
||||||
client_secret=os.environ['APP_SECRET'],
|
|
||||||
server_metadata_url=os.environ['SERVER_URL'],
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# watchlist = get_watchlist(auth.username)
|
|
||||||
# symbols = (watchlist.iloc[:, 0] + " - " + watchlist.iloc[:, 1]).tolist()
|
|
||||||
|
|
||||||
CACHE_CONFIG = {'CACHE_TYPE': 'SimpleCache'}
|
CACHE_CONFIG = {'CACHE_TYPE': 'SimpleCache'}
|
||||||
cache = Cache()
|
cache = Cache()
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
# Define the __all__ variable
|
# Define the __all__ variable
|
||||||
__all__ = ["security", "remove_from_db", "insert_into_db", "get_watchlist"]
|
__all__ = ["Security", "remove_from_db", "insert_into_db", "get_watchlist", "hash_password"]
|
||||||
|
|
||||||
# Import the submodules
|
# Import the submodules
|
||||||
from .security import security, get_crossing, get_sma_slope
|
from .security import Security, get_crossing, get_sma_slope
|
||||||
from .dbutil import remove_from_db, insert_into_db, get_watchlist
|
from .dbutil import remove_from_db, insert_into_db, get_watchlist, hash_password
|
||||||
|
@ -2,7 +2,7 @@ import numpy as np
|
|||||||
from numpy.fft import fft, ifft
|
from numpy.fft import fft, ifft
|
||||||
import scipy.signal as sig
|
import scipy.signal as sig
|
||||||
|
|
||||||
class security:
|
class Security:
|
||||||
"""
|
"""
|
||||||
This can be a list of stocks, bonds, or otherinvestment vehicles.
|
This can be a list of stocks, bonds, or otherinvestment vehicles.
|
||||||
price - Pandas DataFrame with datetime as index sorted to chronical order
|
price - Pandas DataFrame with datetime as index sorted to chronical order
|
||||||
|
Loading…
x
Reference in New Issue
Block a user