diff --git a/common/utilities.py b/common/utilities.py index 6a19019..6e0e5ca 100644 --- a/common/utilities.py +++ b/common/utilities.py @@ -1,31 +1,31 @@ -import time -import logging - -log = logging.getLogger(__name__) - - -def rate_limited(max_per_second): - """ - Decorator that ensures the wrapped function is called at most `max_per_second` times per second. - """ - min_interval = 1.0 / max_per_second - - def decorate(func): - last_called = [0.0] - - def rate_limited_function(*args, **kwargs): - elapsed = time.time() - last_called[0] - left_to_wait = min_interval - elapsed - - if left_to_wait > 0: - log.info(f"Rate limit exceeded. Waiting for {left_to_wait:.2f} seconds.") - time.sleep(left_to_wait) - - ret = func(*args, **kwargs) - last_called[0] = time.time() - - return ret - - return rate_limited_function - - return decorate +import time +import logging + +log = logging.getLogger(__name__) + + +def rate_limited(max_per_second): + """ + Decorator that ensures the wrapped function is called at most `max_per_second` times per second. + """ + min_interval = 1.0 / max_per_second + + def decorate(func): + last_called = [0.0] + + def rate_limited_function(*args, **kwargs): + elapsed = time.time() - last_called[0] + left_to_wait = min_interval - elapsed + + if left_to_wait > 0: + log.info(f"Rate limit exceeded. Waiting for {left_to_wait:.2f} seconds.") + time.sleep(left_to_wait) + + ret = func(*args, **kwargs) + last_called[0] = time.time() + + return ret + + return rate_limited_function + + return decorate diff --git a/site/docs/blog/posts/intro.md b/site/docs/blog/posts/intro.md index f10c29c..0b8c652 100644 --- a/site/docs/blog/posts/intro.md +++ b/site/docs/blog/posts/intro.md @@ -25,6 +25,8 @@ Simple Stock Bot is a chatbot designed to enrich your financial discussions on T + + With Simple Stock Bot, you can: - **Fetch Real-time Quotes**: Obtain the latest stock and cryptocurrency prices instantly within your group chat. diff --git a/site/docs/blog/posts/marketdata-release.md b/site/docs/blog/posts/marketdata-release.md new file mode 100644 index 0000000..e290555 --- /dev/null +++ b/site/docs/blog/posts/marketdata-release.md @@ -0,0 +1,40 @@ +--- +title: "v2023.1 Release! New Stock Market Data Provider and More!" +date: 2023-10-16 +tags: [Simple Stock Bot, Telegram, Discord, MarketDataApp] +authors: [Anson] +description: > + Discover the latest updates for Simple Stock Bot, including our new integration with MarketData.app for enhanced real-time stock market insights. +--- + +## 🌐 General Updates: + +- **New Home**: We've transitioned to our fresh and updated website at [simplestockbot.com](https://simplestockbot.com/). +- **New Data Provider**: We're excited to announce [MarketData.app](https://dashboard.marketdata.app/marketdata/aff/go/misterbiggs?keyword=web) as our new provider for real-time stock market data, ensuring timely and accurate insights for our users. + + + +## 📈 MarketData.app Integration Enhancements: + +- We've introduced **additional options** to our MarketData.app integration, ensuring even more precise and varied financial data. +- **Afterhours Data Fix**: Addressed an issue where after hours stock market data caused errors. +- **Trending Symbol Accuracy**: Fixed a bug that led to the display of invalid symbols in the `/trending` command. + +## 🤖 Bot Improvements & Fixes: + +- **Unified Repository**: To streamline our development and deployment, we've merged the Discord and Telegram bots into a single monorepo. Check it out on [GitLab](https://gitlab.com/simple-stock-bots/simple-stock-bot). Contributions welcome! +- **Inline Functionality Restoration**: Fixed the telegram bot's inline functionality. +- **Python Telegram Bot Update**: Migrated to the latest version of `Python Telegram Bot` for superior performance and more features. +- **Rate Limiting Addition**: Implemented rate limiting to ensure optimal performance during peak usage times. +- **SO MUCH MORE**: [Move to Marketdata.app GitLab Issues](https://gitlab.com/simple-stock-bots/simple-stock-bot/-/milestones/3) + +## 📝 Documentation & Repository Overhauls: + +- **Centralized Documentation**: For convenience and improved maintenance, we've shifted our documentation into the monorepo. +- **Documentation Refinement**: Updated our documentation to reflect the latest homepage details. + +**Special Mention**: Immense gratitude to our dedicated community for their continual feedback and unwavering support. Dive deeper into the financial realm with Simple Stock Bot! + +--- + +📥 For any concerns, queries, or feedback, don't hesitate to [Contact Us](../../contact.md).