Pharos
TAStatistics

TA.LINEARREG_INTERCEPT() - 线性回归截距

Linear Regression Intercept,计算线性回归线的Y轴截距。

返回统计函数目录


语法

python
TA.LINEARREG_INTERCEPT(data)
TA.LINEARREG_INTERCEPT(data, timeperiod=14)

参数

参数类型说明默认值
dataarray价格数据-
timeperiodint回归周期14

返回值

返回线性回归截距数组(回归线在Y轴的起始值)。


计算方法

plaintext
y = a + b×x
intercept = a = mean(y) - slope × mean(x)

基础示例

python
def main():
    records = exchange.GetRecords()
    closes = [r['Close'] for r in records]
    
    intercept = TA.LINEARREG_INTERCEPT(closes, 14)
    slope = TA.LINEARREG_SLOPE(closes, 14)
    
    # 预测未来价格
    future_price = intercept[-1] + slope[-1] * 15
    Log(f"预测下一周期价格: {future_price:.2f}")

返回统计函数目录 | 返回 TA 指标总目录