talib 买卖信号_如何产生股票交易的买卖信号

talib 买卖信号

回归和分类生成买/卖信号(Regression & Classification to generate buy/sell signals)

Moving average rule says that, buy and sell signals are generated by two moving averages of the level of the index-a long-period average and a short-period average. This strategy is expressed as buying (or selling) in its simplest form; which means when the short-period moving average rises above (or falls below) the long-period moving average. The idea behind computing moving averages it to smooth out an otherwise volatile series. When the short-period moving average penetrates the long-period moving average, a trend is considered to be initiated.

中号oving平均规则认为,买卖信号是由指数长周期平均和短周期平均水平的两条移动均线产生。 这种策略以最简单的形式表示为购买(或出售)。 这意味着当短期移动平均线高于(或低于)长期移动平均线时。 计算移动平均线背后的想法是将其平滑以消除本来不稳定的序列。 当短期移动平均线穿入长期移动平均线时,就认为趋势已经开始。

Here, with a simple example, we have shown as how to generate report on buy/sell signals and visualize the chart.

在这里,通过一个简单的示例,我们展示了如何生成有关买/卖信号的报告并可视化图表。

print("....Data Loading...."); print();
print('\033[4mCrude Oil Spot Price\033[0m');
data = web.DataReader('CL=F', data_source = 'yahoo', start = '2000-01-01');
data;
Image for post

Let’s focus on closing price of daily stock.

让我们专注于每日股票的收盘价。

df = data[['Close']];
# Plot the closing price
df.Close.plot(figsize=(10, 5));
plt.ylabel("Prices (USD)"); plt.title("Crude Oil Price Series");
plt.show();
Image for post

解释变量 (Explanatory variables)

To find the price movement of a stock, we will use two EMAs of different time period. We have taken exponential moving average (ema); in simple moving average (sma), each value in the time period carries equal weight, and values outside of the time period are not included in the average. However, the ema is a cumulative calculation, including all data. Past values have a diminishing contribution to the average, while more recent values have a greater contribution. This method allows the moving average to be more responsive to changes in the data.

为了找到股票的价格走势,我们将使用两个不同时间段的EMA。 我们采用了指数移动平均线(ema); 在简单移动平均值(sma)中,时间段中的每个值都具有相等的权重,并且该时间段之外的值不包括在平均值中。 但是,ema是包括所有数据的累积计算。 过去的值对平均值的贡献减小,而最近的值对平均值的贡献更大。 这种方法使移动平均值对数据的变化更加敏感。

df['ema10'] = (df['Close'].ewm(span=10,adjust=True,ignore_na=True).mean());
df['ema20'] = (df['Close'].ewm(span=20,adjust=True,ignore_na=True).mean());
df['price_tomorrow'] = df['Close'].shift(-1);
df.dropna(inplace=True);
X = df[['ema10', 'ema20']]; y = df['price_tomorrow'];

用原始数据绘制EMA (Plot EMA with original data)

fig = go.Figure(data=[go.Candlestick(x=data.index[-10
  • 1
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值