Skip to content

Commit

Permalink
move some func to bot_utils
Browse files Browse the repository at this point in the history
  • Loading branch information
mrzaizai2k authored Dec 2, 2023
1 parent 7352b1f commit c82b21b
Showing 1 changed file with 8 additions and 13 deletions.
21 changes: 8 additions & 13 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,10 @@
from vnstock import *
from dotenv import load_dotenv
load_dotenv()

import subprocess
import schedule
import time
import yaml
from functools import wraps
from src.trading_record import TradeScraper
Expand Down Expand Up @@ -37,19 +41,10 @@ def convert_data_type(df, time_cols=[], float_cols=[], cat_cols=[]):
def validate_symbol(symbol):
return (symbol in listing_companies(live=True).ticker.tolist()) or (symbol in ['VNINDEX','VN30'])

def validate_symbol_decorator(bot):
def decorator(func):
@wraps(func)
def wrapper(message, command):
symbol = message.text.upper()
if not validate_symbol(symbol):
bot.send_message(message.chat.id, f'Sorry! There is no stock {symbol}')
return
return func(message, command, symbol)

return wrapper

return decorator
def schedule_checker():
while True:
schedule.run_pending()
time.sleep(1)

def memoization(func):
def wrapper(file_path, *args, **kwargs):
Expand Down

0 comments on commit c82b21b

Please sign in to comment.