1
0
mirror of https://gitlab.com/simple-stock-bots/simple-stock-bot.git synced 2026-06-03 21:00:26 +00:00

Compare commits

..

6 Commits

Author SHA1 Message Date
Anson 77165d802d prettier applied 2023-10-15 22:59:05 +00:00
Anson 769290528d add prettier 2023-10-15 22:58:15 +00:00
Anson 57967cde47 add prettier 2023-10-15 21:52:28 +00:00
Anson d352131b2e run ruff 2023-10-15 21:43:34 +00:00
Anson 91cf799327 fix last link 2023-10-15 21:41:12 +00:00
Anson e513386376 update urls 2023-10-15 15:32:24 -06:00
9 changed files with 22 additions and 102 deletions
+2
View File
@@ -1,7 +1,9 @@
stages:
- lint
- build
- build_site
- deploy
- deploy_site
black:
stage: lint
+1 -1
View File
@@ -1,8 +1,8 @@
import datetime as dt
import logging
import os
from collections import OrderedDict
from typing import Dict
from collections import OrderedDict
import humanize
import pandas as pd
-14
View File
@@ -7,9 +7,6 @@ import schedule
from markdownify import markdownify
from common.Symbol import Coin
from common.utilities import rate_limited
import time
log = logging.getLogger(__name__)
@@ -27,21 +24,10 @@ class cg_Crypto:
self.get_symbol_list()
schedule.every().day.do(self.get_symbol_list)
# Coingecko's rate limit is 30 requests per minute.
# Since there are two bots sharing the same IP, we allocate half of that limit to each bot.
# This results in a rate limit of 15 requests per minute for each bot.
# Given this, the rate limit effectively becomes 1 request every 4 seconds for each bot.
@rate_limited(0.25)
def get(self, endpoint, params: dict = {}, timeout=10) -> dict:
url = "https://api.coingecko.com/api/v3" + endpoint
resp = r.get(url, params=params, timeout=timeout)
# Make sure API returned a proper status code
if resp.status_code == 429:
log.warning(f"CoinGecko returned 429 - Too Many Requests for endpoint: {endpoint}. Sleeping and trying again.")
time.sleep(10)
return self.get(endpoint=endpoint, params=params, timeout=timeout)
try:
resp.raise_for_status()
except r.exceptions.HTTPError as e:
-1
View File
@@ -4,5 +4,4 @@ markdownify==0.11.6
mplfinance==0.12.10b0
pandas==2.1.1
requests==2.31.0
rush==2021.4.0
schedule==1.2.1
-31
View File
@@ -1,31 +0,0 @@
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
+6 -6
View File
@@ -1,7 +1,7 @@
image: python:3.11
build_mkdocs:
stage: build_site
build_site:
stage: build
script:
- cd ./site
- pip install -r requirements.txt
@@ -10,14 +10,14 @@ build_mkdocs:
paths:
- public
pages:
deploy_site:
stage: deploy
script:
- echo "Publishing site..."
dependencies:
- build_mkdocs
- build_site
artifacts:
paths:
- public
# rules:
# - if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
rules:
- if: "$CI_COMMIT_BRANCH == $CI_DEFAULT_BRANCH"
-2
View File
@@ -25,8 +25,6 @@ Simple Stock Bot is a chatbot designed to enrich your financial discussions on T
</div>
</div>
<!-- more -->
With Simple Stock Bot, you can:
- **Fetch Real-time Quotes**: Obtain the latest stock and cryptocurrency prices instantly within your group chat.
@@ -1,40 +0,0 @@
---
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.
<!-- more -->
## 📈 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).
+12 -6
View File
@@ -11,21 +11,27 @@ import traceback
from uuid import uuid4
import mplfinance as mpf
from T_info import T_info
import telegram
from common.symbol_router import Router
from telegram import InlineQueryResultArticle, InputTextMessageContent, LabeledPrice, Update
from telegram import (
InlineQueryResultArticle,
InputTextMessageContent,
LabeledPrice,
Update,
)
from telegram.ext import (
Application,
CommandHandler,
ContextTypes,
InlineQueryHandler,
MessageHandler,
PreCheckoutQueryHandler,
MessageHandler,
filters,
ContextTypes,
)
from common.symbol_router import Router
from T_info import T_info
# Enable logging
logging.basicConfig(format="%(asctime)s - %(name)s - %(levelname)s - %(message)s", level=logging.INFO)