indicator-setup
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseSet up the complete Python environment for OpenAlgo indicator analysis, charting, and dashboard development.
为OpenAlgo指标分析、图表绘制和仪表盘开发搭建完整的Python环境。
Arguments
参数
- = Python version (optional, default:
$0). Examples:python3,python3.12python3.13
- = Python版本(可选,默认值:
$0)。示例:python3、python3.12python3.13
Steps
步骤
Step 1: Detect Operating System
步骤1:检测操作系统
bash
uname -s 2>/dev/null || echo "Windows"Map: = macOS, = Linux, // = Windows.
DarwinLinuxMINGW*CYGWIN*Windowsbash
uname -s 2>/dev/null || echo "Windows"对应关系: = macOS, = Linux,// = Windows。
DarwinLinuxMINGW*CYGWIN*WindowsStep 2: Create Virtual Environment
步骤2:创建虚拟环境
macOS / Linux:
bash
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pipWindows:
bash
python -m venv venv
venv\Scripts\activate
pip install --upgrade pipIf user specified a Python version argument, use that instead of .
python3macOS / Linux:
bash
python3 -m venv venv
source venv/bin/activate
pip install --upgrade pipWindows:
bash
python -m venv venv
venv\Scripts\activate
pip install --upgrade pip如果用户指定了Python版本参数,则使用该版本而非。
python3Step 3: Install Python Packages
步骤3:安装Python包
Install all required packages:
bash
pip install openalgo yfinance plotly dash dash-bootstrap-components streamlit numba numpy pandas python-dotenv websocket-client httpx scipy nbformat matplotlib seaborn ipywidgets安装所有必需的包:
bash
pip install openalgo yfinance plotly dash dash-bootstrap-components streamlit numba numpy pandas python-dotenv websocket-client httpx scipy nbformat matplotlib seaborn ipywidgetsStep 4: Create Project Folders
步骤4:创建项目文件夹
Create only the top-level directories. Subdirectories are created on-demand by other skills.
bash
mkdir -p charts dashboards custom_indicators scanners仅创建顶层目录。子目录将由其他技能根据需求自动创建。
bash
mkdir -p charts dashboards custom_indicators scannersStep 5: Configure .env File
步骤5:配置.env文件
5a. Ask the user for their OpenAlgo API key using AskUserQuestion:
- "Enter your OpenAlgo API key (from the OpenAlgo dashboard at /apikey):"
5b. Ask for the OpenAlgo host URL:
- Default:
http://127.0.0.1:5000 - If user has a custom domain or ngrok URL, use that
5c. Optionally ask about WebSocket URL:
- Default: derived from host automatically
- Only needed if user has a custom WebSocket setup
5d. Write the file in the project root:
.envundefined5a. 使用AskUserQuestion向用户询问他们的OpenAlgo API密钥:
- "请输入你的OpenAlgo API密钥(可从OpenAlgo仪表盘的/apikey页面获取):"
5b. 询问OpenAlgo主机URL:
- 默认值:
http://127.0.0.1:5000 - 如果用户有自定义域名或ngrok URL,请使用该地址
5c. 可选:询问WebSocket URL:
- 默认值:自动从主机地址推导
- 仅当用户有自定义WebSocket配置时需要
5d. 在项目根目录写入文件:
.envundefinedOpenAlgo API Configuration
OpenAlgo API Configuration
OPENALGO_API_KEY={user_provided_key or "your_openalgo_api_key_here"}
OPENALGO_HOST={user_provided_host or "http://127.0.0.1:5000"}
OPENALGO_API_KEY={user_provided_key or "your_openalgo_api_key_here"}
OPENALGO_HOST={user_provided_host or "http://127.0.0.1:5000"}
WebSocket (optional - auto-derived from host if not set)
WebSocket (optional - auto-derived from host if not set)
OPENALGO_WS_URL=ws://127.0.0.1:8765
OPENALGO_WS_URL=ws://127.0.0.1:8765
**5e. Add `.env` to `.gitignore`:**
```bash
grep -qxF '.env' .gitignore 2>/dev/null || echo '.env' >> .gitignore
**5e. 将`.env`添加到`.gitignore`:**
```bash
grep -qxF '.env' .gitignore 2>/dev/null || echo '.env' >> .gitignoreStep 6: Verify Installation
步骤6:验证安装
bash
python -c "
import openalgo
from openalgo import ta
import plotly
import dash
import streamlit
import numba
import numpy as np
import pandas as pd
import yfinance as yf
import matplotlib
import seaborn
import nbformat
from dotenv import load_dotenv
print('All packages installed successfully')
print(f' openalgo: {openalgo.__version__}')
print(f' plotly: {plotly.__version__}')
print(f' dash: {dash.__version__}')
print(f' streamlit: {streamlit.__version__}')
print(f' numba: {numba.__version__}')
print(f' numpy: {np.__version__}')
print(f' pandas: {pd.__version__}')
print(f' matplotlib: {matplotlib.__version__}')
print(f' seaborn: {seaborn.__version__}')bash
python -c "
import openalgo
from openalgo import ta
import plotly
import dash
import streamlit
import numba
import numpy as np
import pandas as pd
import yfinance as yf
import matplotlib
import seaborn
import nbformat
from dotenv import load_dotenv
print('All packages installed successfully')
print(f' openalgo: {openalgo.__version__}')
print(f' plotly: {plotly.__version__}')
print(f' dash: {dash.__version__}')
print(f' streamlit: {streamlit.__version__}')
print(f' numba: {numba.__version__}')
print(f' numpy: {np.__version__}')
print(f' pandas: {pd.__version__}')
print(f' matplotlib: {matplotlib.__version__}')
print(f' seaborn: {seaborn.__version__}')Quick indicator test
Quick indicator test
close = np.array([100.0, 101.0, 102.0, 103.0, 104.0, 105.0, 104.0, 103.0, 102.0, 101.0])
ema = ta.ema(close, 3)
rsi = ta.rsi(close, 5)
print(f' ta.ema test: {ema[-1]:.2f}')
print(f' ta.rsi test: {rsi[-1]:.2f}')
print('Indicator library ready')
"
undefinedclose = np.array([100.0, 101.0, 102.0, 103.0, 104.0, 105.0, 104.0, 103.0, 102.0, 101.0])
ema = ta.ema(close, 3)
rsi = ta.rsi(close, 5)
print(f' ta.ema test: {ema[-1]:.2f}')
print(f' ta.rsi test: {rsi[-1]:.2f}')
print('Indicator library ready')
"
undefinedStep 7: Print Summary
步骤7:打印总结
Print a summary showing:
- Detected OS
- Python version used
- Virtual environment path
- Installed packages and versions
- Project folders created
- file status
.env - Available skills: ,
/indicator-chart,/custom-indicator,/indicator-dashboard,/indicator-scanner/live-feed
打印包含以下内容的总结:
- 检测到的操作系统
- 使用的Python版本
- 虚拟环境路径
- 已安装的包及其版本
- 创建的项目文件夹
- 文件状态
.env - 可用技能:、
/indicator-chart、/custom-indicator、/indicator-dashboard、/indicator-scanner/live-feed
Important Notes
重要说明
- Never install packages globally — always use the virtual environment
- If the user already has a virtual environment, ask before creating a new one
- NEVER commit files — they contain API keys
.env - is used by all scripts to load
python-dotenvvia.envfind_dotenv() - The openalgo library includes Numba-optimized indicators that compile on first use
- 切勿全局安装包——始终使用虚拟环境
- 如果用户已存在虚拟环境,创建新环境前请先询问用户
- 绝对不要提交文件——它们包含API密钥
.env - 所有脚本通过使用
find_dotenv()加载python-dotenv文件.env - openalgo库包含经Numba优化的指标,首次使用时会进行编译