-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #4 from hanchiang/feature/trading-view-webhook-tel…
…egram Format vix central message and trading view message before sending to telegram
- Loading branch information
Showing
10 changed files
with
171 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
# Introduction | ||
This repository sends market data notification to channels like telegram. Data sources are trading view and vix central. | ||
|
||
# Sample | ||
## Test message | ||
 | ||
|
||
## Simulate real message | ||
 |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import os | ||
from dotenv import load_dotenv | ||
|
||
load_dotenv() | ||
|
||
def get_telegram_bot_token(): | ||
if not os.getenv('TELEGRAM_BOT_TOKEN', None): | ||
raise RuntimeError("telegram bot token is missing") | ||
return os.getenv('TELEGRAM_BOT_TOKEN') | ||
|
||
def get_telegram_channel_id(): | ||
if not os.getenv('TELEGRAM_CHANNEL_ID', None): | ||
raise RuntimeError("telegram channel is missing") | ||
return os.getenv('TELEGRAM_CHANNEL_ID') | ||
|
||
def get_is_testing_telegram(): | ||
return os.getenv('IS_TESTING_TELEGRAM', False) == 'true' | ||
|
||
def get_simulate_real_traffic(): | ||
return os.getenv('SIMULATE_REAL_TRAFFIC', False) == 'true' | ||
|
||
def get_trading_view_ips(): | ||
if not os.getenv('TRADING_VIEW_IPS', None): | ||
raise RuntimeError("trading view ips is missing") | ||
return os.getenv('TRADING_VIEW_IPS').split(',') | ||
|
||
def get_telegram_admin_id(): | ||
if not os.getenv('TELEGRAM_ADMIN_ID', None): | ||
raise RuntimeError("telegram admin id is missing") | ||
return os.getenv('TELEGRAM_ADMIN_ID') | ||
|
||
def get_contango_single_day_decrease_alert_ratio(): | ||
return 0.4 if not get_is_testing_telegram() else 0.01 | ||
|
||
def get_contango_decrease_past_n_days(): | ||
return 5 if not get_is_testing_telegram() else 2 | ||
|
||
def get_potential_overextended_by_symbol(): | ||
potential_overextended_by_symbol = { | ||
'SPY': { | ||
'up': 0.04 if not get_is_testing_telegram() else 0.01, | ||
'down': -0.065 if not get_is_testing_telegram() else -0.01 | ||
} | ||
} | ||
return potential_overextended_by_symbol |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import telegram | ||
import src.config.config as config | ||
|
||
bot = telegram.Bot(token=config.get_telegram_bot_token()) | ||
|
||
async def send_message_to_channel(message: str, chat_id = config.get_telegram_channel_id()): | ||
res = await bot.send_message(chat_id, text=message, parse_mode='MarkdownV2') | ||
return res | ||
|
||
async def send_message_to_admin(message: str, chat_id = config.get_telegram_admin_id()): | ||
res = await bot.send_message(chat_id, text=message, parse_mode='MarkdownV2') | ||
return res |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
import telegram | ||
|
||
def escape_markdown(text: str, version=2): | ||
return telegram.helpers.escape_markdown(text=text, version=version) |