Skip to content

Commit

Permalink
loaf current price upto a month
Browse files Browse the repository at this point in the history
  • Loading branch information
mrzaizai2k committed Feb 13, 2024
1 parent 6732477 commit 4e02f60
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
2 changes: 2 additions & 0 deletions config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ buy_sell_df_path: data/LichSuKhopLenh_058C647873.csv
asset_data_path: data/BaoCaoTaiSan_058C647873.csv
motif_data_path: memory/motif.csv
summary_news_data_path: data/summary_stock_news.json
masterquest_url: http://localhost:8083/query
updatevectordb_url: http://localhost:8083/update

special_symbols:
CHECK_CHAR:
Expand Down
3 changes: 2 additions & 1 deletion config/help_command.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,11 @@ Available features:
- /buysellanalyze: Picture of my Buy sell for a stock (FPTS data)
- /summarynewsurl: Summary news from arbitrary url
- Summarize idea from Audio or Voice into To-Do list
- /masterquest: Answer the question with my master data in HCMUT (LLM + RAG system)
---------------

Only me features:
- /remote: Open remote tunnel to vscode on mrzaizai2k laptop
- /scrape: Manually scraping trading data and news
- /log: Send the log file
- /masterquest: Answer the question with my master data in HCMUT (LLM + RAG system)
- /updatevectordb: Update vector database for masterquest command
29 changes: 27 additions & 2 deletions src/stock_bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,41 @@ def ask_pattern_stock(message, command):

@bot.message_handler(commands=['masterquest'])
def ask_for_question(message):
if not validate_mrzaizai2k_user(message.chat.id):
bot.send_message(message.chat.id, f"This command can just be used by the owner (mrzaizai2k).\nIf you want to use this, clone the git repo and modify the code")
return
# Ask for the stock symbol
markup = types.ForceReply(selective = False)
bot.reply_to(message, "Please enter the question:", reply_markup = markup)
bot.register_next_step_handler(message, masterquest)

def masterquest(message):
query = message.text
api_url = 'http://localhost:8083/query'
response = requests.post(api_url, json={'query': query})
masterquest_url = data.get('masterquest_url')
response = requests.post(masterquest_url, json={'query': query})
print(f'Result: {response.json()}')

bot.reply_to(message, f"The answer: {response.json()['result']}")
bot.send_message(message.chat.id, f"The source: {response.json()['source_documents']}")



@bot.message_handler(commands=['updatevectordb'])
def updatevectordb(message):
if not validate_mrzaizai2k_user(message.chat.id):
bot.send_message(message.chat.id, f"This command can just be used by the owner (mrzaizai2k).\nIf you want to use this, clone the git repo and modify the code")
return

updatevectordb_url = data.get('updatevectordb_url') # Update the URL if your Flask app runs on a different port or host
try:
response = requests.post(updatevectordb_url)
if response.status_code == 200:
print("API Test Successful: Update was successful")
bot.send_message(message.chat.id, "Update was successful")
else:
print(f"API Test Failed: {response.status_code} - {response.json()['message']}")
except Exception as e:
print(f"API Test Failed: {str(e)}")


def find_similar_pattern(message, symbol):
Expand Down
3 changes: 2 additions & 1 deletion src/stock_class.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,10 @@ def load_full_data(self, start_date:str = None, end_date:str = None, resolution:
df = convert_data_type(df, [self.time_col], self.float_cols, self.cat_cols)
return df


def load_current_data(self):
current_date = datetime.now().strftime('%Y-%m-%d')
start_date = (datetime.strptime(current_date, "%Y-%m-%d") - timedelta(days=2)).strftime('%Y-%m-%d')
start_date = (datetime.strptime(current_date, "%Y-%m-%d") - timedelta(days=30)).strftime('%Y-%m-%d')
df = stock_historical_data(symbol=self.symbol, start_date = start_date,
end_date=current_date, resolution='5', type=self.type, beautify=True)
return df
Expand Down

0 comments on commit 4e02f60

Please sign in to comment.