bbstrader 0.2.4__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of bbstrader might be problematic. Click here for more details.
- bbstrader/__ini__.py +18 -0
- bbstrader/btengine/__init__.py +54 -0
- bbstrader/btengine/backtest.py +360 -0
- bbstrader/btengine/data.py +712 -0
- bbstrader/btengine/event.py +221 -0
- bbstrader/btengine/execution.py +251 -0
- bbstrader/btengine/performance.py +347 -0
- bbstrader/btengine/portfolio.py +406 -0
- bbstrader/btengine/strategy.py +779 -0
- bbstrader/config.py +133 -0
- bbstrader/core/__init__.py +0 -0
- bbstrader/core/data.py +22 -0
- bbstrader/core/utils.py +57 -0
- bbstrader/ibkr/__init__.py +0 -0
- bbstrader/ibkr/utils.py +0 -0
- bbstrader/metatrader/__init__.py +6 -0
- bbstrader/metatrader/account.py +1488 -0
- bbstrader/metatrader/rates.py +579 -0
- bbstrader/metatrader/risk.py +702 -0
- bbstrader/metatrader/trade.py +1690 -0
- bbstrader/metatrader/utils.py +641 -0
- bbstrader/models/__init__.py +10 -0
- bbstrader/models/factors.py +312 -0
- bbstrader/models/ml.py +1264 -0
- bbstrader/models/optimization.py +182 -0
- bbstrader/models/portfolio.py +223 -0
- bbstrader/models/risk.py +398 -0
- bbstrader/trading/__init__.py +11 -0
- bbstrader/trading/execution.py +726 -0
- bbstrader/trading/scripts.py +67 -0
- bbstrader/trading/strategies.py +860 -0
- bbstrader/tseries.py +1816 -0
- bbstrader-0.2.4.dist-info/LICENSE +21 -0
- bbstrader-0.2.4.dist-info/METADATA +174 -0
- bbstrader-0.2.4.dist-info/RECORD +37 -0
- bbstrader-0.2.4.dist-info/WHEEL +5 -0
- bbstrader-0.2.4.dist-info/top_level.txt +1 -0
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
import asyncio
|
|
2
|
+
|
|
3
|
+
from notifypy import Notify
|
|
4
|
+
from telegram import Bot
|
|
5
|
+
from telegram.error import TelegramError
|
|
6
|
+
|
|
7
|
+
__all__ = ["send_telegram_message", "send_notification", "send_message"]
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
async def send_telegram_message(token, chat_id, text=""):
|
|
11
|
+
"""
|
|
12
|
+
Send a message to a telegram chat
|
|
13
|
+
|
|
14
|
+
Args:
|
|
15
|
+
token: str: Telegram bot token
|
|
16
|
+
chat_id: int or str or list: Chat id or list of chat ids
|
|
17
|
+
text: str: Message to send
|
|
18
|
+
"""
|
|
19
|
+
try:
|
|
20
|
+
bot = Bot(token=token)
|
|
21
|
+
if isinstance(chat_id, (int, str)):
|
|
22
|
+
chat_id = [chat_id]
|
|
23
|
+
for id in chat_id:
|
|
24
|
+
await bot.send_message(chat_id=id, text=text)
|
|
25
|
+
except TelegramError as e:
|
|
26
|
+
print(f"Error sending message: {e}")
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
def send_notification(title, message=""):
|
|
30
|
+
"""
|
|
31
|
+
Send a desktop notification
|
|
32
|
+
|
|
33
|
+
Args:
|
|
34
|
+
title: str: Title of the notification
|
|
35
|
+
message: str: Message of the notification
|
|
36
|
+
"""
|
|
37
|
+
notification = Notify(default_notification_application_name="bbstrading")
|
|
38
|
+
notification.title = title
|
|
39
|
+
notification.message = message
|
|
40
|
+
notification.send()
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
def send_message(
|
|
44
|
+
title="SIGNAL",
|
|
45
|
+
message="New signal",
|
|
46
|
+
notify_me=False,
|
|
47
|
+
telegram=False,
|
|
48
|
+
token=None,
|
|
49
|
+
chat_id=None,
|
|
50
|
+
):
|
|
51
|
+
"""
|
|
52
|
+
Send a message to the user
|
|
53
|
+
|
|
54
|
+
Args:
|
|
55
|
+
title: str: Title of the message
|
|
56
|
+
message: str: Message of the message
|
|
57
|
+
notify_me: bool: Send a desktop notification
|
|
58
|
+
telegram: bool: Send a telegram message
|
|
59
|
+
token: str: Telegram bot token
|
|
60
|
+
chat_id: int or str or list: Chat id or list of chat ids
|
|
61
|
+
"""
|
|
62
|
+
if notify_me:
|
|
63
|
+
send_notification(title, message=message)
|
|
64
|
+
if telegram:
|
|
65
|
+
if token is None or chat_id is None:
|
|
66
|
+
raise ValueError("Token and chat_id must be provided")
|
|
67
|
+
asyncio.run(send_telegram_message(token, chat_id, text=message))
|