Add telegram dependency installation cell to notebook
Cell 27 now installs python-telegram-bot automatically before the Telegram Bot Commander starts. New cell structure: - Cell 27: Dependency Installation (pip install) - Cell 28: Telegram Bot Info (Markdown) - Cell 29: Telegram Bot Commander (Start Bot) - Cell 30: execute_trade Integration (Wrapper) Instructions: Run Cell 27 first, then 29, then 30
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,76 @@
|
||||
#!/usr/bin/env python3
|
||||
"""
|
||||
Fügt Telegram Dependencies Installation Cell ins Notebook hinzu
|
||||
"""
|
||||
|
||||
import json
|
||||
|
||||
notebook_path = "TradingBot_V1.6_Adaptive_Complete_CORRECTED.ipynb"
|
||||
|
||||
print(f"📖 Loading notebook: {notebook_path}")
|
||||
with open(notebook_path, 'r', encoding='utf-8') as f:
|
||||
notebook = json.load(f)
|
||||
|
||||
# Find Cell 28 (Telegram Bot Commander)
|
||||
# We need to insert a dependency installation cell BEFORE it
|
||||
|
||||
# Create new cell for dependency installation (will be Cell 27.5)
|
||||
dependency_cell = {
|
||||
"cell_type": "code",
|
||||
"execution_count": None,
|
||||
"metadata": {},
|
||||
"outputs": [],
|
||||
"source": [
|
||||
"# ==========================================\n",
|
||||
"# INSTALL TELEGRAM BOT DEPENDENCIES\n",
|
||||
"# ==========================================\n",
|
||||
"\n",
|
||||
"import sys\n",
|
||||
"import subprocess\n",
|
||||
"\n",
|
||||
"print(\"📦 Installing python-telegram-bot...\")\n",
|
||||
"\n",
|
||||
"try:\n",
|
||||
" # Install or upgrade python-telegram-bot\n",
|
||||
" subprocess.check_call([\n",
|
||||
" sys.executable, \"-m\", \"pip\", \"install\", \n",
|
||||
" \"python-telegram-bot\", \"--upgrade\", \"--quiet\"\n",
|
||||
" ])\n",
|
||||
" print(\"✅ python-telegram-bot installed successfully!\")\n",
|
||||
" \n",
|
||||
" # Verify\n",
|
||||
" import telegram\n",
|
||||
" print(f\"✅ telegram module version: {telegram.__version__}\")\n",
|
||||
" \n",
|
||||
"except Exception as e:\n",
|
||||
" print(f\"❌ Installation failed: {e}\")\n",
|
||||
" print(\"\\n⚠️ Please run manually:\")\n",
|
||||
" print(\" pip install python-telegram-bot --upgrade\")\n"
|
||||
]
|
||||
}
|
||||
|
||||
# Insert at position 27 (before the markdown info cell)
|
||||
insert_position = 27
|
||||
|
||||
print(f"📝 Inserting dependency installation cell at position {insert_position}...")
|
||||
notebook['cells'].insert(insert_position, dependency_cell)
|
||||
|
||||
# Update cell count
|
||||
new_total = len(notebook['cells'])
|
||||
print(f"✅ New total cells: {new_total}")
|
||||
|
||||
# Save notebook
|
||||
print(f"💾 Saving notebook...")
|
||||
with open(notebook_path, 'w', encoding='utf-8') as f:
|
||||
json.dump(notebook, f, indent=1, ensure_ascii=False)
|
||||
|
||||
print("✅ Notebook updated successfully!")
|
||||
print(f"\n🎯 NEW CELL STRUCTURE:")
|
||||
print(f" Cell 27: Dependency Installation (NEW)")
|
||||
print(f" Cell 28: Telegram Bot Info (Markdown)")
|
||||
print(f" Cell 29: Telegram Bot Commander (Code)")
|
||||
print(f" Cell 30: execute_trade Integration (Code)")
|
||||
print(f"\n📋 INSTRUCTIONS:")
|
||||
print(f" 1. Run Cell 27 FIRST (install dependencies)")
|
||||
print(f" 2. Then run Cell 29 (Telegram Bot Commander)")
|
||||
print(f" 3. Then run Cell 30 (Integration)")
|
||||
Reference in New Issue
Block a user