随笔分类 - quant
摘要:早晨之星(黎明之星) def morning_star(df, inplace=False): if not inplace: df = df.copy() # 计算三日移动平均线 df['ma3'] = df['close'].rolling(3).mean() # 计算昨天的收盘价 df['pr
阅读全文
摘要:一元线性回归的斜率公式是: 由于斜率具有平移不变性,x通常取 0 到窗口大小减一。 def slope(df, close_col='close', slope_col='
阅读全文
摘要:双均线策略 假设你是个高级程序员和量化研究员,编写函数实现双均线策略。函数接受数据帧df,较短均线的列名称short_col和较长均线的列名称long_col,inplace参数控制是否原地更新df。买卖信号应保存在signal列中。最后返回df。 def dual_moving_average_s
阅读全文
摘要:.\pandas-ta\tests\__init__.py # 导入必要的模块 import numpy as np import matplotlib.pyplot as plt # 生成一组随机数据 x = np.random.randn(1000) # 创建一个频率直方图 plt.hist(x
阅读全文
摘要:.\pandas-ta\tests\test_strategy.py # 导入必要的模块 # 必须与其它测试分开运行,以确保成功运行 from multiprocessing import cpu_count # 导入获取 CPU 核心数量的函数 from time import perf_coun
阅读全文
摘要:.\pandas-ta\tests\test_indicator_performance.py # 导入所需的模块和函数 from .config import sample_data from .context import pandas_ta # 从 unittest 模块中导入 TestCas
阅读全文
摘要:.\pandas-ta\tests\test_indicator_cycles.py # 从config模块中导入error_analysis, sample_data, CORRELATION, CORRELATION_THRESHOLD, VERBOSE变量 # 从context模块中导入pan
阅读全文
摘要:.\pandas-ta\tests\test_ext_indicator_overlap_ext.py # 从当前包中导入 sample_data 和 pandas_ta 模块 from .config import sample_data from .context import pandas_t
阅读全文
摘要:.\pandas-ta\pandas_ta\volume\pvol.py # -*- coding: utf-8 -*- # 导入所需的库和函数 from pandas_ta.utils import get_offset, signed_series, verify_series # 定义函数 p
阅读全文
摘要:.\pandas-ta\pandas_ta\volume\adosc.py # -*- coding: utf-8 -*- # 导入 ad 模块 from .ad import ad # 从 pandas_ta 库中导入 Imports 模块 from pandas_ta import Import
阅读全文
摘要:.\pandas-ta\pandas_ta\volatility\kc.py # -*- coding: utf-8 -*- # 从 pandas 库中导入 DataFrame 类 from pandas import DataFrame # 从 .true_range 模块中导入 true_ran
阅读全文
摘要:.\pandas-ta\pandas_ta\utils\_signals.py # -*- coding: utf-8 -*- # 导入 DataFrame 和 Series 类 from pandas import DataFrame, Series # 导入自定义函数 from ._core i
阅读全文
摘要:.\pandas-ta\pandas_ta\trend\xsignals.py # -*- coding: utf-8 -*- # 从 numpy 中导入 nan 并重命名为 npNaN from numpy import nan as npNaN # 从 pandas 中导入 DataFrame
阅读全文
摘要:.\pandas-ta\pandas_ta\trend\decreasing.py # -*- coding: utf-8 -*- # 从 pandas_ta.utils 模块中导入所需函数和类 from pandas_ta.utils import get_drift, get_offset, i
阅读全文
摘要:.\pandas-ta\pandas_ta\statistics\stdev.py # -*- coding: utf-8 -*- # 从 numpy 导入 sqrt 函数,并将其命名为 npsqrt from numpy import sqrt as npsqrt # 从 variance 模块导
阅读全文
摘要:.\pandas-ta\pandas_ta\overlap\wcp.py # -*- coding: utf-8 -*- # 从 pandas_ta 库中导入 Imports 模块 from pandas_ta import Imports # 从 pandas_ta.utils 中导入 get_o
阅读全文
摘要:.\pandas-ta\pandas_ta\overlap\sma.py # -*- coding: utf-8 -*- # 从 pandas_ta 库中导入 Imports 对象 from pandas_ta import Imports # 从 pandas_ta.utils 模块中导入 get
阅读全文
摘要:.\pandas-ta\pandas_ta\overlap\jma.py # -*- coding: utf-8 -*- # 从 numpy 库中导入 average 函数并重命名为 npAverage # 从 numpy 库中导入 nan 函数并重命名为 npNaN # 从 numpy 库中导入
阅读全文
摘要:.\pandas-ta\pandas_ta\momentum\__init__.py # 设置文件编码为 UTF-8 # 导入 ao 指标 from .ao import ao # 导入 apo 指标 from .apo import apo # 导入 bias 指标 from .bias impo
阅读全文
摘要:.\pandas-ta\pandas_ta\momentum\stc.py # -*- coding: utf-8 -*- 从 pandas 库中导入 DataFrame 和 Series 类 从 pandas_ta.overlap 模块中导入 ema 函数 从 pandas_ta.utils 模块
阅读全文