使用基于LSTM的变分自编码器对股票序列数据进行降噪并重构

考虑到针对股票市场的噪音特性,我们尝试使用变分自编码器(VAE)对价格数据进行重构,并且考虑到股票数据的时序性,我们在自编码器网络中加入LSTM网络提升表现。

第一步:获取数据:

pip  install tushare
#获取使用接口
def get_token():
    ts.set_token("xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx")
    pro=ts.pro_api()
    return pro


##获取数据列表
def get_data_list(cursor,sql,conn):
    cursor.execute(sql)
    res=cursor.fetchall()
    conn.commit()
    ts_codes_list=list(res)
    ts_codes_list=[",".join(list(x)) for x in ts_codes_list]
    return ts_codes_list
##获取数据
def get_data(ts_codes_list,pro):
    daily=pd.DataFrame(columns=["ts_code","trade_date","open","close","high","low","volume"]) ##获取相应的列信息
    for i in range(0,len(ts_codes_list),100):  
        j=i+100
        if(j>=len(ts_codes_list)):
            j=len(ts_codes_list)
        name=",".join(ts_codes_list[i:j])
        part= pro.daily(ts_code=name, trade_date=get_date())[["ts_code","trade_date","open","close","high","low","volume"]]
        daily=pd.concat([daily,part],ignore_index=True) 
    daily["trade_date"]=daily["trade_date"].apply(get_date_format)
    return daily

使用stockstats库进行对OHCLV的转换。
```python
from stoc
  • 4
    点赞
  • 22
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值