import pandas as pd
import requests
import time
import numpy as np
from telegram import Bot
# === Telegram Bot Token ===
TELEGRAM_TOKEN = '7747083952:AAGqQncsCKjXbmYq9Ty4_rUQsxYj-jDyY8A'
TELEGRAM_CHAT_ID = 'your-chat-id-here' # Will help you find this below
bot = Bot(token=TELEGRAM_TOKEN)
# === Sample asset list (can be expanded) ===
assets = ['USD/ARS', 'EUR/JPY', 'NZD/CAD', 'AUD/USD', 'USD/JPY']
# === Get historical candle data from a dummy API (Replace with real source) ===
def get_candles(pair):
# Fake example - replace with your own API or dummy CSV if needed
url = f'https://api.example.com/candles/{pair}?timeframe=1m&limit=15'
response = requests.get(url)
data = response.json()
df = pd.DataFrame(data)
return df
# === Calculate RSI ===
def rsi(series, period=14):
delta = series.diff()
gain = np.where(delta > 0, delta, 0)
loss = np.where(delta < 0, -delta, 0)
gain = pd.Series(gain).rolling(window=period).mean()
loss = pd.Series(loss).rolling(window=period).mean()
rs = gain / loss
return 100 - (100 / (1 + rs))
# === Analyze market ===
def analyze_market():
for pair in assets:
try:
df = get_candles(pair)
df['rsi'] = rsi(df['close'])
latest = df.iloc[-1]
prev = df.iloc[-2]
if latest['rsi'] < 30 and latest['close'] > latest['open']: # Bullish
candle
send_signal(pair, 'BUY', latest['rsi'])
elif latest['rsi'] > 70 and latest['close'] < latest['open']: #
Bearish candle
send_signal(pair, 'SELL', latest['rsi'])
except Exception as e:
print(f"Error with {pair}: {e}")
# === Send Telegram Signal ===
def send_signal(pair, direction, rsi_value):
msg = f"""📢 *Quotex Signal*
Pair: {pair}
Direction: *{direction}*
RSI: {round(rsi_value, 2)}
Timeframe: 1 Minute
Expiry: 1 min
Confidence: ✅✅✅"""
bot.send_message(chat_id=TELEGRAM_CHAT_ID, text=msg, parse_mode='Markdown')
# === Loop ===
while True:
analyze_market()
time.sleep(60)