原创内容第1011篇,专注AGI+,AI量化投资、个人成长与财富自由。
今日推荐策略:年化422%,回撤7%,夏普比5.4。

因子挖掘:

新增qlib的因子库:
import numpy as npimport pandas as pd
import numpy as npimport pandas as pd
def sign(se: pd.Series): return np.sign(se)
def signed_power(se: pd.Series, a): return np.where(se < 0, -np.abs(se) ** a, np.abs(se) ** a)
def log(se: pd.Series): return np.log(se)
def abs(se:pd.Series): return np.abs(se)
def scale(x:pd.Series, a:int=1): """ Scales the array x such that the sum of the absolute values equals a.
Parameters: x (array-like): The input array to be scaled. a (float, optional): The target sum of absolute values. Default is 1.
Returns: numpy.ndarray: The scaled array. """ import numpy as np x = np.array(x) # 确保输入是numpy数组 sum_abs_x = np.sum(np.abs(x)) # 计算x的绝对值之和 if sum_abs_x == 0: raise ValueError("The sum of absolute values of x is zero, cannot scale by a non-zero value.") scale_factor = a / sum_abs_x # 计算缩放因子 return x * scale_factor # 应用缩放因子
def decay_linear(series:pd.Series, window:int): """ 对输入的时间序列进行线性衰减。
:param series: 输入的时间序列。 :param window: 衰减的窗口大小。 :return: 衰减后的序列。 """ weights = np.arange(1, window + 1) decay = np.convolve(series, weights, 'valid') / np.sum(weights) return decay
def delay(se: pd.Series, periods:int=5): return se.shift(periods=periods)
def delta(se: pd.Series, periods:int=20): se_result = se - se.shift(periods=periods) return se_result
def ts_min(se: pd.Series, periods:int=5): return se.rolling(window=periods).min()
def ts_max(se: pd.Series, periods:int=5): return se.rolling(window=periods).max()
def ts_argmin(se: pd.Series, periods:int=5): return se.rolling(periods, min_periods=2).apply(lambda x: x.argmin())
def ts_argmax(se: pd.Series, periods:int=5): return se.rolling(periods, min_periods=2).apply(lambda x: x.argmax())
def stddev(se:pd.Series, periods:int=5): return se.rolling(window=periods).std()
def ts_rank(se: pd.Series, periods:int=9): ret = se.rolling(window=periods).rank(pct=True) return ret
def sum(se: pd.Series, N:int): ret = se.rolling(N).sum() ret.name = 'sum_{}'.format(N) return ret
def shift(se: pd.Series, N:int): return se.shift(N)
def roc(se: pd.Series, N:int): return se / shift(se, N) - 1
def product(se: pd.Series, d:int): return se.rolling(window=d).apply(np.product)
def zscore(se: pd.Series, N:int): def _zscore(x):
try: x.dropna(inplace=True) #print('sub', x) value = (x[-1] - x.mean()) / x.std() if value: return value except: return -1
ret = se.rolling(window=N).apply(lambda x: _zscore(x)) return ret
代码和数据下载:AI量化实验室------2025量化投资的星辰大海
吾日三省吾身
总有人说细节决定成败,可又有人说,能决定成败的,还能叫细节么?
我见过做事特别细的人,一份文档,细细抠表达细节。
当然,你可以找到很多"例子",比如ppt或者哪里出现了错别字,影响了什么什么结果等等。
当然说,写邮件,写ppt不错别字,这是规范,并不是所谓细节。
就像房间脏了,需要打扫一样。但并不需要一尘不染。就是这个差别。
如果厘清了这个道理。
过于关注细节,就是"用战略的懒惰来掩盖战术的勤奋"。
一个产品经理,如果只关注文档里的逻辑表述顺不顺,全不全,那就只是初级产品经理。产品经理更重要的是,想清楚产品的商业模式,发展路径,用户价值。
就像投资,你的投资体系和投资逻辑,远比选择哪一个具体标的,以及早买一天或者晚买一天要有用得多。
当然屋子还是要有人打扫,错别字要有人去检查,没那么重要,但也是体验的一部分。
每天"不管"一点点,每天就变强一天天。
点击 "查看原文",直接访问策略集合。
扩展 • 历史文章