Daily Shaarli
April 11, 2024
https://github.com/features/actions https://github.com/features/packages https://github.com/features/security https://github.com/features/codespaces https://github.com/features/copilot https://github.com/features/code-review https://github.com/features/issues https://github.com/features/discussions Explore https://github.com/features https://docs.github.com https://skills.github.com/ https://github.blog [...] Resources https://resources.github.com/learn/pathways/ https://resources.github.com/ https://github.com/customer-stories https://partner.github.com/ https://github.com/sponsors https://github.com/readme [...] We read every piece of feedback, and take your input very seriously. [...] Use saved searches to filter your results more quickly https://github.com/login?return_to=https%3A%2F%2Fgithub.com%2Fmyinvestpilot%2Fgravestones https://github.com/signup?ref_cta=Sign+up&ref_loc=header+logged+out&ref_page=%2F%3Cuser-name%3E%2F%3Crepo-name%3E&source=header-repo&source_repo=myinvestpilot%2Fgravestones
上面这个策略的代码如下: python import pandas as pd from trade_strategies import BaseTradeStrategy, TradeSignalState class RsiStrategy(BaseTradeStrategy): """Relative Strength Index (RSI) Trading Strategy""" # 默认参数 params = { 'rsi_period': 14, 'rsi_overbought': 70, 'rsi_oversold': 30, } def __init__(self, params=None): super().__init__() if params: self.params.update(params) def set_data(self, symbol, data): self.symbol = symbol self.data = data self.calculate_indicators() def calculate_indicators(self): delta = self.data['Close'].diff() gain = (delta.where(delta > 0, 0)).rolling(window=self.params['rsi_period'], min_periods=1).mean() loss = (-delta.where(delta self.params['rsi_overbought'] def generate_signals(self): signals = [TradeSignalState.EMPTY.value for _ in range(len(self.data))] for i in range(1, len(self.data)): if self.is_buy_signal(self.data['rsi'].iloc[i]): signals[i] = TradeSignalState.BUY.value elif self.is_sell_signal(self.data['rsi'].iloc[i]): signals[i] = TradeSignalState.SELL.value else: signals[i] = TradeSignalState.EMPTY.value signal_df = pd.DataFrame({ 'symbol': self.symbol, 'open': self.data['Open'], 'high': self.data['High'], 'low': self.data['Low'], 'close': self.data['Close'], 'volume': self.data['Volume'], 'rsi': self.data['rsi'], 'signal': signals }) return signal_df
https://www.myinvestpilot.com/portfolios/myinvestpilot_cn_1基于双均线策略的A股精选ETF组合 https://www.myinvestpilot.com/portfolios/myinvestpilot_cn_2基于双均线策略的A股创业板ETF组合 https://www.myinvestpilot.com/portfolios/myinvestpilot_cn_global基于双均线策略的A股全球ETF组合 美股(美元) https://www.myinvestpilot.com/portfolios/myinvestpilot_us_1基于特定止损与均线策略的美股杠杆ETF组合 https://www.myinvestpilot.com/portfolios/myinvestpilot_us_2基于特定止损与均线策略的美股精选ETF组合 https://www.myinvestpilot.com/portfolios/myinvestpilot_us_3基于特定止损与均线策略的美股纳指三倍做多ETF组合 https://www.myinvestpilot.com/portfolios/myinvestpilot_us_4基于买入持有定投策略的美股行业ETF组合 https://www.myinvestpilot.com/portfolios/myinvestpilot_us_global基于双均线策略的美股全球ETF组合 组合策略交易提醒怎么订阅? 目前组合策略的每日交易提醒邮件订阅是付费会员专享的功能,如果你是https://www.myinvestpilot.com/pricing,可以在每个组合详情页面中订阅,周二到周六每日会收到当天的交易提醒邮件。 交易策略与资金策略的介绍详见https://www.myinvestpilot.com/post的相关文章或视频。