Loading...
Loading...
Compare original and translation side by side
/query?function=TIME_SERIES_DAILYstrategy.run('MA_Crossover', params)backtest --data CSV_FILE --strategy STRATEGY_NAMErsi = talib.RSI(close, timeperiod=14); signals = np.where(rsi > 70, 'sell', 'buy')/query?function=TIME_SERIES_DAILYstrategy.run('MA_Crossover', params)backtest --data CSV_FILE --strategy STRATEGY_NAMErsi = talib.RSI(close, timeperiod=14); signals = np.where(rsi > 70, 'sell', 'buy')import openclaw; oc = openclaw.Skill('algo-trading')openclaw algo-trading init --config config.jsonoc.execute_strategy('MA_Crossover', symbols=['AAPL'], timeframe='1d')oc.run_live('--broker alpaca --key $ALPACA_KEY')export ALPHA_VANTAGE_API_KEY=$SERVICE_API_KEYimport openclaw; oc = openclaw.Skill('algo-trading')openclaw algo-trading init --config config.jsonoc.execute_strategy('MA_Crossover', symbols=['AAPL'], timeframe='1d')oc.run_live('--broker alpaca --key $ALPACA_KEY')openclaw algo-trading run --strategy MA_Crossover --symbols AAPL,GOOG --timeframe 1himport openclaw
oc = openclaw.Skill('algo-trading')
data = oc.fetch_data('AAPL', '1d') # Fetches daily data
signals = oc.analyze_strategy('MA_Crossover', data)openclaw algo-trading load-config path/to/config.jsonopenclaw algo-trading backtest --file historical.csv --strategy RSI_Overbought --iterations 100openclaw algo-trading run --strategy MA_Crossover --symbols AAPL,GOOG --timeframe 1hhttps://www.alphavantage.co/query?function=TIME_SERIES_INTRADAY&symbol=IBM&apikey=$SERVICE_API_KEYimport openclaw
oc = openclaw.Skill('algo-trading')
data = oc.fetch_data('AAPL', '1d') # 获取日线数据
signals = oc.analyze_strategy('MA_Crossover', data){"strategy": "MA_Crossover", "params": {"short_window": 50, "long_window": 200}, "symbols": ["AAPL"]}openclaw algo-trading load-config path/to/config.jsonopenclaw algo-trading backtest --file historical.csv --strategy RSI_Overbought --iterations 100https://api.alpaca.markets/v2/orders{"symbol": "AAPL", "qty": 10, "side": "buy", "type": "market"}$ALPACA_KEYopenclaw add-skill algo-tradingoc.set_auth('alpaca', os.environ['BROKER_API_KEY'])oc.register_webhook('/triggers', lambda event: oc.execute_strategy('event_strategy'))--sandbox trueopenclaw add-skill algo-tradingexport BROKER_API_KEY=$SERVICE_API_KEYoc.set_auth('alpaca', os.environ['BROKER_API_KEY'])oc.register_webhook('/triggers', lambda event: oc.execute_strategy('event_strategy'))--sandbox truetry:
response = oc.fetch_data('AAPL', '1d')
except APIError as e:
print(f"API Error: {e.code} - {e.message}") # Handles 429 for rate limitsoc.retry_on_error(call_func, max_retries=3)openclaw algo-trading validate-config config.jsonoc.log_error('Trade failed: insufficient funds')try:
response = oc.fetch_data('AAPL', '1d')
except APIError as e:
print(f"API Error: {e.code} - {e.message}") # 处理429请求超限错误oc.retry_on_error(call_func, max_retries=3)openclaw algo-trading validate-config config.jsonoc.log_error('Trade failed: insufficient funds')$SERVICE_API_KEYopenclaw algo-trading backtest --file aapl_historical.csv --strategy MA_Crossoveroc = openclaw.Skill('algo-trading')
data = oc.load_data('aapl_historical.csv')
results = oc.backtest_strategy('MA_Crossover', data)
print(results['sharpe_ratio']) # Outputs e.g., 1.2openclaw algo-trading run --strategy RSI_Overbought --symbols TSLA --broker alpacaoc = openclaw.Skill('algo-trading')
rsi_data = oc.fetch_data('TSLA', '1m')
signal = oc.analyze_strategy('RSI_Overbought', rsi_data)
if signal == 'sell':
oc.execute_trade('TSLA', 'sell', 5) # Sells 5 sharesopenclaw algo-trading backtest --file aapl_historical.csv --strategy MA_Crossoveroc = openclaw.Skill('algo-trading')
data = oc.load_data('aapl_historical.csv')
results = oc.backtest_strategy('MA_Crossover', data)
print(results['sharpe_ratio']) # 输出示例:1.2openclaw algo-trading run --strategy RSI_Overbought --symbols TSLA --broker alpacaoc = openclaw.Skill('algo-trading')
rsi_data = oc.fetch_data('TSLA', '1m')
signal = oc.analyze_strategy('RSI_Overbought', rsi_data)
if signal == 'sell':
oc.execute_trade('TSLA', 'sell', 5) # 卖出5股