natexcvi commited on
Commit
c70f265
β€’
1 Parent(s): 247520e

Init commit

Browse files
Files changed (4) hide show
  1. .gitignore +2 -0
  2. api.py +24 -0
  3. app.py +12 -0
  4. requirements.txt +3 -0
.gitignore ADDED
@@ -0,0 +1,2 @@
 
 
 
1
+ .venv
2
+ .env
api.py ADDED
@@ -0,0 +1,24 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import requests
2
+
3
+
4
+ class TradeAssistantAPI:
5
+ def __init__(self, token: str) -> None:
6
+ self.token = token
7
+ self.url = "https://natexcvi-trade-assistant.hf.space"
8
+ self.base_headers = {"Authorization": f"Bearer {self.token}"}
9
+
10
+ def get_recommendations(self):
11
+ url = f"{self.url}/recommend.json"
12
+ response = requests.get(url, headers=self.base_headers)
13
+ body = response.json()
14
+ if "message" in body:
15
+ raise Exception(body["message"])
16
+ return body
17
+
18
+ def train_model(self):
19
+ url = f"{self.url}/train"
20
+ response = requests.get(url, headers=self.base_headers)
21
+ body = response.json()
22
+ if "message" in body:
23
+ raise Exception(body["message"])
24
+ return body
app.py ADDED
@@ -0,0 +1,12 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import pandas as pd
2
+ import streamlit as st
3
+
4
+ from api import TradeAssistantAPI
5
+
6
+ st.title("πŸ“Š Trading Assistant")
7
+
8
+ st.sidebar.title("Settings")
9
+ token = st.sidebar.text_input("Token", type="password")
10
+ api = TradeAssistantAPI(token)
11
+
12
+ st.dataframe(pd.read_json(api.get_recommendations()))
requirements.txt ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ streamlit
2
+ requests
3
+ pandas