Spaces:
Build error
Build error
David Li commited on
Commit ·
87d5fd6
1
Parent(s): 91f9814
fix: try again
Browse files- app.py +7 -0
- pages/economy.py +34 -0
- pages/ta.py +1 -24
- pages/utils/__init__.py +0 -0
- pages/utils/util.py +25 -0
app.py
CHANGED
|
@@ -0,0 +1,7 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
|
| 3 |
+
st.write("""
|
| 4 |
+
# Technical Analysis Web Application
|
| 5 |
+
Leveraging the openbb sdk, we can build a web application to display
|
| 6 |
+
technical analysis graphs for any stock.
|
| 7 |
+
""")
|
pages/economy.py
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import streamlit as st
|
| 2 |
+
from openbb_terminal.economy.wsj_model import market_overview, us_indices, us_bonds, top_commodities, global_bonds, global_currencies
|
| 3 |
+
|
| 4 |
+
# openbb.economy.overview
|
| 5 |
+
# openbb.economy.indices
|
| 6 |
+
# openbb.economy.usbonds
|
| 7 |
+
# openbb.economy.glbonds
|
| 8 |
+
# openbb.economy.currencies
|
| 9 |
+
def openbb_economy():
|
| 10 |
+
"""Open the Blackboard website in the default web browser."""
|
| 11 |
+
economy_dfs = []
|
| 12 |
+
file_names = []
|
| 13 |
+
# append two entries to economy dfs from top_commodities and us_bonds
|
| 14 |
+
economy_dfs.append(top_commodities())
|
| 15 |
+
file_names.append("top_commodities")
|
| 16 |
+
economy_dfs.append(us_bonds())
|
| 17 |
+
file_names.append("us_bonds")
|
| 18 |
+
economy_dfs.append(us_indices())
|
| 19 |
+
file_names.append("us_indices")
|
| 20 |
+
economy_dfs.append(global_bonds())
|
| 21 |
+
file_names.append("global_bonds")
|
| 22 |
+
economy_dfs.append(global_currencies())
|
| 23 |
+
file_names.append("global_currencies")
|
| 24 |
+
economy_dfs.append(market_overview())
|
| 25 |
+
file_names.append("market_overview")
|
| 26 |
+
|
| 27 |
+
return economy_dfs, file_names
|
| 28 |
+
|
| 29 |
+
economy_dfs, file_names = openbb_economy()
|
| 30 |
+
|
| 31 |
+
# output all economy tables with labels above
|
| 32 |
+
for i in range(len(economy_dfs)):
|
| 33 |
+
st.write(f"# {file_names[i]}")
|
| 34 |
+
st.write(economy_dfs[i])
|
pages/ta.py
CHANGED
|
@@ -2,10 +2,7 @@ import streamlit as st
|
|
| 2 |
import datetime
|
| 3 |
import pandas as pd
|
| 4 |
import requests
|
| 5 |
-
import
|
| 6 |
-
import sys
|
| 7 |
-
from PIL import Image
|
| 8 |
-
from io import StringIO
|
| 9 |
from openbb_terminal.stocks.stocks_helper import load
|
| 10 |
from openbb_terminal.common.technical_analysis.volatility_view import display_bbands, display_donchian
|
| 11 |
|
|
@@ -28,26 +25,6 @@ def user_input_features():
|
|
| 28 |
symbol, start, end = user_input_features()
|
| 29 |
|
| 30 |
|
| 31 |
-
def remove_existing_file(func):
|
| 32 |
-
def wrapper(*args, **kwargs):
|
| 33 |
-
old_stdin = sys.stdin
|
| 34 |
-
sys.stdin = StringIO("y")
|
| 35 |
-
stream = os.popen('cd ~ && pwd')
|
| 36 |
-
root_dir = stream.read()
|
| 37 |
-
sample_dir = root_dir.strip()
|
| 38 |
-
# remove /home/codespace/OpenBBUserData/exports/bbands.png already
|
| 39 |
-
# get last arg as export
|
| 40 |
-
export = args[-1]
|
| 41 |
-
temp_image = os.path.join(sample_dir, "OpenBBUserData", "exports", export)
|
| 42 |
-
# if exists erase
|
| 43 |
-
if os.path.exists(temp_image):
|
| 44 |
-
os.remove(temp_image)
|
| 45 |
-
func(*args, **kwargs)
|
| 46 |
-
sys.stdin = old_stdin
|
| 47 |
-
if os.path.exists(temp_image):
|
| 48 |
-
return temp_image
|
| 49 |
-
return None
|
| 50 |
-
return wrapper
|
| 51 |
|
| 52 |
@remove_existing_file
|
| 53 |
@st.experimental_memo
|
|
|
|
| 2 |
import datetime
|
| 3 |
import pandas as pd
|
| 4 |
import requests
|
| 5 |
+
from utils.util import remove_existing_file
|
|
|
|
|
|
|
|
|
|
| 6 |
from openbb_terminal.stocks.stocks_helper import load
|
| 7 |
from openbb_terminal.common.technical_analysis.volatility_view import display_bbands, display_donchian
|
| 8 |
|
|
|
|
| 25 |
symbol, start, end = user_input_features()
|
| 26 |
|
| 27 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 28 |
|
| 29 |
@remove_existing_file
|
| 30 |
@st.experimental_memo
|
pages/utils/__init__.py
ADDED
|
File without changes
|
pages/utils/util.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import os
|
| 2 |
+
import sys
|
| 3 |
+
from PIL import Image
|
| 4 |
+
from io import StringIO
|
| 5 |
+
|
| 6 |
+
def remove_existing_file(func):
|
| 7 |
+
def wrapper(*args, **kwargs):
|
| 8 |
+
old_stdin = sys.stdin
|
| 9 |
+
sys.stdin = StringIO("y")
|
| 10 |
+
stream = os.popen('cd ~ && pwd')
|
| 11 |
+
root_dir = stream.read()
|
| 12 |
+
sample_dir = root_dir.strip()
|
| 13 |
+
# remove /home/codespace/OpenBBUserData/exports/bbands.png already
|
| 14 |
+
# get last arg as export
|
| 15 |
+
export = args[-1]
|
| 16 |
+
temp_image = os.path.join(sample_dir, "OpenBBUserData", "exports", export)
|
| 17 |
+
# if exists erase
|
| 18 |
+
if os.path.exists(temp_image):
|
| 19 |
+
os.remove(temp_image)
|
| 20 |
+
func(*args, **kwargs)
|
| 21 |
+
sys.stdin = old_stdin
|
| 22 |
+
if os.path.exists(temp_image):
|
| 23 |
+
return temp_image
|
| 24 |
+
return None
|
| 25 |
+
return wrapper
|