请 [注册] 或 [登录]  | 返回主站

量化交易吧 /  数理科学 帖子:3365785 新帖:17

应该星期几买股票?

技术性调整发表于:5 月 9 日 19:16回复(1)

话不多说,直接看下面研究作出的图。

import numpy as np
import matplotlib.pyplot as plt
from scipy.optimize import fmin_tnc
import random
import pandas as pd
from pandas import Series, DataFrame
import datetime
import itertools

end_date = datetime.datetime.today().strftime("%Y-%m-%d")
SP = get_price('000001.XSHG', start_date='2010-06-01', 
               end_date=end_date , frequency='daily', 
               fields=['close','open'], skip_paused=False, fq='pre')
r = (SP.close[1:]-SP.close[:-1].tolist())/SP.close[:-1].tolist()*100
w = [x.weekday()+1 for x in SP.index.tolist()[1:]]
x = DataFrame(r)
x.close.name = 'gains'
x.insert(0,'week', w)
import seaborn as sns
sns.set(style="whitegrid", color_codes=True)
plt.figure(figsize=(10,10))
sns.boxplot('week','close',data=x)
plt.ylim(-3,3.2)
plt.show()

全部回复

0/140

达人推荐

量化课程

    移动端课程