繁簡切換您正在訪問的是FX168財經網,本網站所提供的內容及信息均遵守中華人民共和國香港特別行政區當地法律法規。

FX168财经网>人物频道>帖子

6月做多豆粕,至少能赶上一波

作者/萨达撒撒 2019-08-24 20:54 0 来源: FX168财经网人物频道
import statsmodels.api as sm
from mpl_toolkits.axisartist.axislines import SubplotZero

#from pandas.stats.api import ols
from jqfactor import get_factor_values
from jqdata import *
import pandas as pd
import talib as ta
import copy
from datetime import datetime,timedelta
from dateutil.relativedelta import relativedelta
import time
# fields=['time', 'current', 'high', 'low', 'volume', 'money']
today = (datetime.now() - timedelta(days=0)).strftime('%Y-%m-%d')
#today = (datetime.now() - timedelta(days=1)).strftime('%Y-%m-%d')
today_end = datetime.strptime(today,'%Y-%m-%d')+timedelta(hours=15)
#固定日期
fix_date = '2019-05-07'
fix_date_end = datetime.strptime(fix_date,'%Y-%m-%d')+timedelta(hours=15)
#是否使用今天
use_today = 0
#测试股票代码
stock = '000815.XSHE'
if use_today ==1:
    date = today
    date_end = today_end
elif use_today == 0:
    date = fix_date
    date_end = fix_date_end
#df = get_ticks(stock,start_dt=date, end_dt=date_end,fields=['time', 'current', 'volume', 'money'])
nearCode = 'M1409.XDCE'
farCode = 'M1501.XDCE'
edate='2015-2-1'
df = get_price(nearCode,count=200,end_date=edate,frequency='1d',fields=['close','high','low']);
df2 = get_price(farCode,count=200,end_date=edate,frequency='1d',fields=['close','high','low']);
df2['diff']=df2['close']-df['close'];
#print(df)
#df = get_ticks("000001.XSHG",start_dt="2019-03-26", end_dt="2019-03-26 15:00:00")
#print(df);
import matplotlib.pyplot as plt
fig=plt.figure(figsize=(15,3))
ax=SubplotZero(fig,1,1,1)
ax.grid(True, linestyle='-.')
fig.add_subplot(ax)
plt.plot(df['close'])
plt.plot(df2['close'])
plt.show()
#plt.figure(figsize=(10,3))
#plt.plot(df2['diff'])
#plt.show()
write_file('技术面/near91_df.csv', pd.DataFrame(df).to_csv(), append=False);
write_file('技术面/far91_df.csv', pd.DataFrame(df2).to_csv(), append=False);

nearCode = 'M1505.XDCE'
farCode = 'M1509.XDCE'
edate='2015-10-1'
df = get_price(nearCode,count=200,end_date=edate,frequency='1d',fields=['close','high','low']);
df2 = get_price(farCode,count=200,end_date=edate,frequency='1d',fields=['close','high','low']);
df2['diff']=df2['close']-df['close'];
#print(df)
#df = get_ticks("000001.XSHG",start_dt="2019-03-26", end_dt="2019-03-26 15:00:00")
#print(df);
import matplotlib.pyplot as plt
fig=plt.figure(figsize=(15,3))
ax=SubplotZero(fig,1,1,1)
ax.grid(True, linestyle='-.')
fig.add_subplot(ax)
plt.plot(df['close'])
plt.plot(df2['close'])
#plt.show()
#plt.figure()
#plt.plot(df2['diff'])
plt.show()
write_file('技术面/near59_df.csv', pd.DataFrame(df).to_csv(), append=False)
write_file('技术面/far59_df.csv', pd.DataFrame(df2).to_csv(), append=False)
6910
#df = get_ticks(stock,start_dt=date, end_dt=date_end,fields=['time', 'current', 'volume', 'money'])
nearCode = 'M1509.XDCE'
farCode = 'M1601.XDCE'
edate='2016-2-1'
df = get_price(nearCode,count=200,end_date=edate,frequency='1d',fields=['close','high','low']);
df2 = get_price(farCode,count=200,end_date=edate,frequency='1d',fields=['close','high','low']);
df2['diff']=df2['close']-df['close'];
#print(df)
#df = get_ticks("000001.XSHG",start_dt="2019-03-26", end_dt="2019-03-26 15:00:00")
#print(df);
import matplotlib.pyplot as plt
fig=plt.figure(figsize=(15,3))
ax=SubplotZero(fig,1,1,1)
ax.grid(True, linestyle='-.')
fig.add_subplot(ax)
plt.plot(df['close'])
plt.plot(df2['close'])
plt.show()
#plt.figure(figsize=(10,3))
#plt.plot(df2['diff'])
#plt.show()
write_file('技术面/near91_df.csv', pd.DataFrame(df).to_csv(), append=False);
write_file('技术面/far91_df.csv', pd.DataFrame(df2).to_csv(), append=False);

nearCode = 'M1605.XDCE'
farCode = 'M1609.XDCE'
edate='2016-10-1'
df = get_price(nearCode,count=200,end_date=edate,frequency='1d',fields=['close','high','low']);
df2 = get_price(farCode,count=200,end_date=edate,frequency='1d',fields=['close','high','low']);
df2['diff']=df2['close']-df['close'];
#print(df)
#df = get_ticks("000001.XSHG",start_dt="2019-03-26", end_dt="2019-03-26 15:00:00")
#print(df);
import matplotlib.pyplot as plt
fig=plt.figure(figsize=(15,3))
ax=SubplotZero(fig,1,1,1)
ax.grid(True, linestyle='-.')
fig.add_subplot(ax)
plt.plot(df['close'])
plt.plot(df2['close'])
#plt.show()
#plt.figure()
#plt.plot(df2['diff'])
plt.show()
write_file('技术面/near59_df.csv', pd.DataFrame(df).to_csv(), append=False)
write_file('技术面/far59_df.csv', pd.DataFrame(df2).to_csv(), append=False)
6895
#df = get_ticks(stock,start_dt=date, end_dt=date_end,fields=['time', 'current', 'volume', 'money'])
nearCode = 'M1609.XDCE'
farCode = 'M1701.XDCE'
edate='2017-2-1'
df = get_price(nearCode,count=200,end_date=edate,frequency='1d',fields=['close','high','low']);
df2 = get_price(farCode,count=200,end_date=edate,frequency='1d',fields=['close','high','low']);
df2['diff']=df2['close']-df['close'];
#print(df)
#df = get_ticks("000001.XSHG",start_dt="2019-03-26", end_dt="2019-03-26 15:00:00")
#print(df);
import matplotlib.pyplot as plt
fig=plt.figure(figsize=(15,3))
ax=SubplotZero(fig,1,1,1)
ax.grid(True, linestyle='-.')
fig.add_subplot(ax)
plt.plot(df['close'])
plt.plot(df2['close'])
plt.show()
#plt.figure(figsize=(10,3))
#plt.plot(df2['diff'])
#plt.show()
write_file('技术面/near91_df.csv', pd.DataFrame(df).to_csv(), append=False);
write_file('技术面/far91_df.csv', pd.DataFrame(df2).to_csv(), append=False);

nearCode = 'M1705.XDCE'
farCode = 'M1709.XDCE'
edate='2017-10-1'
df = get_price(nearCode,count=200,end_date=edate,frequency='1d',fields=['close','high','low']);
df2 = get_price(farCode,count=200,end_date=edate,frequency='1d',fields=['close','high','low']);
df2['diff']=df2['close']-df['close'];
#print(df)
#df = get_ticks("000001.XSHG",start_dt="2019-03-26", end_dt="2019-03-26 15:00:00")
#print(df);
import matplotlib.pyplot as plt
fig=plt.figure(figsize=(15,3))
ax=SubplotZero(fig,1,1,1)
ax.grid(True, linestyle='-.')
fig.add_subplot(ax)
plt.plot(df['close'])
plt.plot(df2['close'])
#plt.show()
#plt.figure()
#plt.plot(df2['diff'])
plt.show()
write_file('技术面/near59_df.csv', pd.DataFrame(df).to_csv(), append=False)
write_file('技术面/far59_df.csv', pd.DataFrame(df2).to_csv(), append=False)
6842
#df = get_ticks(stock,start_dt=date, end_dt=date_end,fields=['time', 'current', 'volume', 'money'])
nearCode = 'M1709.XDCE'
farCode = 'M1801.XDCE'
edate='2018-2-1'
df = get_price(nearCode,count=200,end_date=edate,frequency='1d',fields=['close','high','low']);
df2 = get_price(farCode,count=200,end_date=edate,frequency='1d',fields=['close','high','low']);
df2['diff']=df2['close']-df['close'];
#print(df)
#df = get_ticks("000001.XSHG",start_dt="2019-03-26", end_dt="2019-03-26 15:00:00")
#print(df);
import matplotlib.pyplot as plt
fig=plt.figure(figsize=(15,3))
ax=SubplotZero(fig,1,1,1)
ax.grid(True, linestyle='-.')
fig.add_subplot(ax)
plt.plot(df['close'])
plt.plot(df2['close'])
plt.show()
#plt.figure(figsize=(10,3))
#plt.plot(df2['diff'])
#plt.show()
write_file('技术面/near91_df.csv', pd.DataFrame(df).to_csv(), append=False);
write_file('技术面/far91_df.csv', pd.DataFrame(df2).to_csv(), append=False);

nearCode = 'M1805.XDCE'
farCode = 'M1809.XDCE'
edate='2018-10-1'
df = get_price(nearCode,count=200,end_date=edate,frequency='1d',fields=['close','high','low']);
df2 = get_price(farCode,count=200,end_date=edate,frequency='1d',fields=['close','high','low']);
df2['diff']=df2['close']-df['close'];
#print(df)
#df = get_ticks("000001.XSHG",start_dt="2019-03-26", end_dt="2019-03-26 15:00:00")
#print(df);
import matplotlib.pyplot as plt
fig=plt.figure(figsize=(15,3))
ax=SubplotZero(fig,1,1,1)
ax.grid(True, linestyle='-.')
fig.add_subplot(ax)
plt.plot(df['close'])
plt.plot(df2['close'])
#plt.show()
#plt.figure()
#plt.plot(df2['diff'])
plt.show()
write_file('技术面/near59_df.csv', pd.DataFrame(df).to_csv(), append=False)
write_file('技术面/far59_df.csv', pd.DataFrame(df2).to_csv(), append=False)
6942
#df = get_ticks(stock,start_dt=date, end_dt=date_end,fields=['time', 'current', 'volume', 'money'])
nearCode = 'M1809.XDCE'
farCode = 'M1901.XDCE'
edate='2019-2-1'
df = get_price(nearCode,count=200,end_date=edate,frequency='1d',fields=['close','high','low']);
df2 = get_price(farCode,count=200,end_date=edate,frequency='1d',fields=['close','high','low']);
df2['diff']=df2['close']-df['close'];
#print(df)
#df = get_ticks("000001.XSHG",start_dt="2019-03-26", end_dt="2019-03-26 15:00:00")
#print(df);
import matplotlib.pyplot as plt
fig=plt.figure(figsize=(15,3))
ax=SubplotZero(fig,1,1,1)
ax.grid(True, linestyle='-.')
fig.add_subplot(ax)
plt.plot(df['close'])
plt.plot(df2['close'])
plt.show()
#plt.figure(figsize=(10,3))
#plt.plot(df2['diff'])
#plt.show()
write_file('技术面/near91_df.csv', pd.DataFrame(df).to_csv(), append=False);
write_file('技术面/far91_df.csv', pd.DataFrame(df2).to_csv(), append=False);

nearCode = 'M1905.XDCE'
farCode = 'M1909.XDCE'
edate='2019-10-1'
df = get_price(nearCode,count=200,end_date=edate,frequency='1d',fields=['close','high','low']);
df2 = get_price(farCode,count=200,end_date=edate,frequency='1d',fields=['close','high','low']);
df2['diff']=df2['close']-df['close'];
#print(df)
#df = get_ticks("000001.XSHG",start_dt="2019-03-26", end_dt="2019-03-26 15:00:00")
#print(df);
import matplotlib.pyplot as plt
fig=plt.figure(figsize=(15,3))
ax=SubplotZero(fig,1,1,1)
ax.grid(True, linestyle='-.')
fig.add_subplot(ax)
plt.plot(df['close'])
plt.plot(df2['close'])
#plt.show()
#plt.figure()
#plt.plot(df2['diff'])
plt.show()
write_file('技术面/near59_df.csv', pd.DataFrame(df).to_csv(), append=False)
write_file('技术面/far59_df.csv', pd.DataFrame(df2).to_csv(), append=False)
6866
 
分享到:
举报财经168客户端下载

全部回复

0/140

投稿 您想发表你的观点和看法?

更多人气分析师

  • 张亦巧

    人气2184文章4145粉丝45

    暂无个人简介信息

  • 梁孟梵

    人气2176文章3177粉丝39

    qq:2294906466 了解群指导添加微信mfmacd

  • 指导老师

    人气1864文章4423粉丝52

    暂无个人简介信息

  • 李冉晴

    人气2320文章3821粉丝34

    李冉晴,专业现贷实盘分析师。

  • 王启蒙现货黄金

    人气296文章3137粉丝8

    本人做分析师以来,并专注于贵金属投资市场,尤其是在现货黄金...

  • 张迎妤

    人气1896文章3305粉丝34

    个人专注于行情技术分析,消息面解读剖析,给予您第一时间方向...

  • 金泰铬J

    人气2328文章3925粉丝51

    投资问答解咨询金泰铬V/信tgtg67即可获取每日的实时资讯、行情...

  • 金算盘

    人气2696文章7761粉丝125

    高级分析师,混过名校,厮杀于股市和期货、证券市场多年,专注...

  • 金帝财神

    人气4760文章8329粉丝119

    本文由资深分析师金帝财神微信:934295330,指导黄金,白银,...

FX168财经

FX168财经学院

FX168财经

FX168北美