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

..

2 Commits

Author SHA1 Message Date
Anson 2dd67538bb add divider 2023-10-17 05:11:13 +00:00
Anson 5d1f71e19a new blogpost 2023-10-17 05:10:59 +00:00
36 changed files with 2903 additions and 2947 deletions
+1 -1
View File
@@ -27,7 +27,7 @@
]
}
},
"postCreateCommand": "pip3 install --user -r dev-reqs.txt && apt-get update && apt-get install -y nodejs npm --fix-missing && npm install"
"postCreateCommand": "pip3 install --user -r dev-reqs.txt && apt-get update && apt-get install -y nodejs npm && npm install"
// Features to add to the dev container. More info: https://containers.dev/features.
// "features": {},
// Use 'forwardPorts' to make a list of ports inside the container available locally.
+20 -12
View File
@@ -1,21 +1,29 @@
stages:
- lint
- build
- build_site
- deploy
- deploy_site
# ruff:
# stage: lint
# image: python:3.11-slim
# script:
# - pip3 install ruff
# - ruff . --output-format gitlab; ruff format . --diff
black:
stage: lint
image: registry.gitlab.com/pipeline-components/black:latest
script:
- black --check --verbose -- .
# prettier:
# stage: lint
# image: node:16-slim # Use Node.js image since prettier is a Node.js tool
# script:
# - npm install prettier
# - npx prettier --check . # Adjust the path as needed
ruff:
stage: lint
image: python:3.11-slim
script:
- pip3 install ruff
- ruff --output-format gitlab .
prettier:
stage: lint
image: node:16-slim # Use Node.js image since prettier is a Node.js tool
script:
- npm install prettier
- npx prettier --check . # Adjust the path as needed
include:
- local: /site/.gitlab-ci.yml
+1 -1
View File
@@ -3,7 +3,7 @@
"editor.formatOnPaste": true,
"editor.formatOnSaveMode": "modificationsIfAvailable",
"[python]": {
"editor.defaultFormatter": "charliermarsh.ruff",
"editor.defaultFormatter": "ms-python.black-formatter",
"editor.formatOnSave": true,
"editor.formatOnSaveMode": "file"
}
+4 -26
View File
@@ -10,7 +10,6 @@ import pytz
import requests as r
import schedule
from common.Symbol import Stock
log = logging.getLogger(__name__)
@@ -55,12 +54,9 @@ class MarketData:
self.get_symbol_list()
schedule.every().day.do(self.get_symbol_list)
def get(self, endpoint, params=None, timeout=10, headers=None) -> dict:
def get(self, endpoint, params: dict = {}, timeout=10) -> dict:
url = "https://api.marketdata.app/v1/" + endpoint
if params is None:
params = {}
# set token param if it wasn't passed.
params["token"] = self.MARKETDATA_TOKEN
@@ -68,13 +64,7 @@ class MarketData:
# monitored even if someone doesn't make it through an affiliate link.
params["application"] = "simplestockbot"
if headers is None:
headers = {}
headers = {"User-Agent": "Simple Stock Bot anson@ansonbiggs.com"} | headers
resp = r.get(url, params=params, timeout=timeout, headers=headers)
logging.error(resp.headers.items())
resp = r.get(url, params=params, timeout=timeout)
# Make sure API returned a proper status code
try:
@@ -105,15 +95,7 @@ class MarketData:
return self.symbol_list.get(symbol.upper(), None)
def get_symbol_list(self):
# Doesn't use `self.get()` since needs are much different
sec_resp = r.get(
"https://www.sec.gov/files/company_tickers.json",
headers={
"User-Agent": "Simple Stock Bot anson@ansonbiggs.com",
"Accept-Encoding": "gzip, deflate",
"Host": "www.sec.gov",
},
)
sec_resp = r.get("https://www.sec.gov/files/company_tickers.json")
sec_resp.raise_for_status()
sec_data = sec_resp.json()
@@ -230,11 +212,7 @@ class MarketData:
if data := self.get(
f"stocks/candles/{resolution}/{symbol}",
params={
"from": startTime.timestamp(),
"to": now.timestamp(),
"extended": True,
},
params={"from": startTime.timestamp(), "to": now.timestamp(), "extended": True},
):
data.pop("s")
df = pd.DataFrame(data)
-3
View File
@@ -26,9 +26,6 @@ class Symbol:
def __str__(self) -> str:
return self.id
def __hash__(self):
return hash(self.id)
class Stock(Symbol):
"""Stock Market Object. Gets data from MarketData"""
+1 -8
View File
@@ -5,11 +5,10 @@ import pandas as pd
import requests as r
import schedule
from markdownify import markdownify
from common.Symbol import Coin
from common.utilities import rate_limited
import time
log = logging.getLogger(__name__)
@@ -35,12 +34,6 @@ class cg_Crypto:
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:
+3 -1
View File
@@ -1,5 +1,6 @@
-r common/requirements.txt
-r site/requirements.txt
black==23.9.1
ipython==8.16.1
jupyter_client==8.4.0
jupyter_core==5.4.0
@@ -7,4 +8,5 @@ pylama==8.4.1
mypy==1.5.1
types-cachetools==5.3.0.6
types-pytz==2023.3.1.1
ruff==0.1.6
ruff==0.0.292
isort==5.12.0
+9
View File
@@ -1,2 +1,11 @@
[tool.black]
line-length = 130
[tool.flake8]
max-line-length = 130
[tool.pycodestyle]
max_line_length = 130
[tool.ruff]
line-length = 130
+4 -4
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,12 +10,12 @@ build_mkdocs:
paths:
- public
pages:
deploy_site:
stage: deploy
script:
- echo "Publishing site..."
dependencies:
- build_mkdocs
- build_site
artifacts:
paths:
- public
-14
View File
@@ -1,14 +0,0 @@
---
title: "Simple Bot End-of-Life"
date: 2024-05-12
tags: [Simple Stock Bot, Introduction, Telegram, Discord, Financial Insights]
authors: [Anson]
description: >
Simple Stock Bot is being sunset.
---
## What is Simple Stock Bot?
For full details see my full blog post: https://notes.ansonbiggs.com/simple-stock-bot-end-of-life/
I am shutting down Simple Stock Bot, a popular Telegram and Discord bot that provided live stock and cryptocurrency market data. The bot was created in 2018 after my group chat lost access to the Google Allo, which had integrated market data. The bot grew to 15,000 monthly active users, but maintaining the service has become challenging due to increasing data costs and changes to the Discord API. I really appreciate the community and everyone that has donated along the way, this has been a seriously great ride. The bot will soon no longer function on Telegram and Discord.
+3 -4
View File
@@ -11,13 +11,12 @@ nav:
- Home: index.md
- Commands: commands.md
- Self-Host: host.md
# - Donate: donate.md
- Donate: donate.md
- Contact: contact.md
- Blog: blog/index.md
theme:
name: material
custom_dir: overrides
language: en
features:
- navigation.instant
@@ -66,8 +65,8 @@ plugins:
markdown_extensions:
- attr_list
- pymdownx.emoji:
emoji_index: !!python/name:material.extensions.emoji.twemoji
emoji_generator: !!python/name:material.extensions.emoji.to_svg
emoji_index: !!python/name:materialx.emoji.twemoji
emoji_generator: !!python/name:materialx.emoji.to_svg
- admonition
- pymdownx.details
- pymdownx.superfences
-17
View File
@@ -1,17 +0,0 @@
{% extends "base.html" %}
<!-- Announcement bar -->
{% block announce %}
<div class="admonition danger" style="min-height: 20vh;">
<p class="admonition-title">This project is now archived!</p>
<p>
Please
<a href="/blog/2024/05/12/simple-bot-end-of-life/"
>click here for more information.</a
>
</p>
</div>
<div class="" admoniton></div>
{% endblock %}
+1 -2
View File
@@ -1,5 +1,4 @@
mkdocs-material==9.5.22
mkdocs-material-extensions==1.3.1
mkdocs-material==9.4.4
# Required for Social Cards
Pillow==10.0.1
+3 -1
View File
@@ -9,7 +9,9 @@ $tsla
/chart $tsla
/chart $$btc
/help
/trending""".split("\n")
/trending""".split(
"\n"
)
print("press enter to start")
keyboard.wait("enter")