Price difference analysis of the Python Arbitrage series--python Learning notes 22

Source: Internet
Author: User
# # #套利分析
Import Pandas as PD
Import NumPy as NP
#读取数据
Caipo=pd.read_excel (' caipo.xlsx ')
Doupo=pd.read_excel (' doupo.xlsx ')
Caipo.head (5)
#整理数据
caipo_close=caipo.ix[::,6]
Caipo_close.head ()
doupo_close=doupo.ix[::,6]
Doupo_close.head ()
"#分析数据
Cc=caipo_close
Dc=doupo_close
Cc.mean ()
Dc.mean ()
I=dc.mean ()/cc.mean ()
I
E=cc*i-dc
E.head ()
#基于均值比例分析残差

E.plot () ""


#发现基于均值比例的模型随机性太强, we recalculate based on the correlation coefficient.
Cc=caipo_close
Dc=doupo_close
Cc.corr (dc,method= ' Pearson ')
#从相关系数来看, the correlation between the two is very high, 94%;
#菜粕和豆粕价格相差很大, we calculate in different proportions
Ccnew=cc*123
dcnew=dc*100
E= (ccnew-dcnew)/100
E.head (10)

E.plot ()


Later on, we will make a KDJ-MACD model to calculate whether the price difference can be profitable.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.