本文整理汇总了Python中pandas.io.data.DataReader.diff方法的典型用法代码示例。如果您正苦于以下问题:Python DataReader.diff方法的具体用法?Python DataReader.diff怎么用?Python DataReader.diff使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类pandas.io.data.DataReader
的用法示例。
在下文中一共展示了DataReader.diff方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: getPayOff
# 需要导入模块: from pandas.io.data import DataReader [as 别名]
# 或者: from pandas.io.data.DataReader import diff [as 别名]
def getPayOff(year,month):
nifty = DataReader("^NSEI","yahoo",datetime(year,month,1),datetime(year,month,25))
bn=DataReader("^NSEBANK","yahoo",datetime(year,month,1),datetime(year,month,25))
nifty_daily=nifty.diff()['Close']
bn_daily=bn.diff()['Close']
nifty_daily_return =50*(nifty_daily)
bn_daily_return =25*(bn_daily)
return -nifty_daily_return.sum()+bn_daily_return.sum()
示例2: getLongShortPayOff
# 需要导入模块: from pandas.io.data import DataReader [as 别名]
# 或者: from pandas.io.data.DataReader import diff [as 别名]
def getLongShortPayOff(year,month,longSymbol,longQty,shortSymbol,shortQty):
shortStk = DataReader(shortSymbol,"yahoo",datetime(year,month,1),datetime(year,month,25))
longStk=DataReader(longSymbol,"yahoo",datetime(year,month,1),datetime(year,month,25))
short_daily=shortStk.diff()['Close']
long_daily=longStk.diff()['Close']
short_daily_return =shortQty*(short_daily)
long_daily_return =longQty*(long_daily)
#print abs(long_daily_return.sum())-abs(short_daily_return.sum())
return abs(long_daily_return.sum())-abs(short_daily_return.sum())
示例3: DataReader
# 需要导入模块: from pandas.io.data import DataReader [as 别名]
# 或者: from pandas.io.data.DataReader import diff [as 别名]
#TECHM.NS,HCLTECH.NS
#axis = DataReader("AXISBANK.NS","yahoo",datetime(2013,3,1),datetime(2014,3,31))
nifty = DataReader("^NSEI","yahoo",datetime(2013,5,1),datetime(2013,5,25))
bn=DataReader("^NSEBANK","yahoo",datetime(2013,5,1),datetime(2013,5,25))
#print spx.head()
#print ss0.head()
#print axis.tail()
print nifty.tail()['Close'],bn.tail()['Close']
print nifty.head()['Close'],bn.head()['Close']
#axis_daily= axis.tail().diff()['Close']
#nifty_daily=nifty.tail().diff()['Close']
#axis_daily= axis.diff()['Close']
nifty_daily=nifty.diff()['Close']
bn_daily=bn.diff()['Close']
#daily_return = (axis_daily*250 ) - (50*nifty_daily)
daily_return = (bn_daily*25)- (50*nifty_daily)
nifty_daily_return =50*(nifty_daily)
bn_daily_return =25*(bn_daily)
print -nifty_daily_return.sum()+bn_daily_return.sum()
both = pd.DataFrame(data = {'nifty': 50*nifty.diff()['Adj Close'], 'bn': 25*bn.diff()['Adj Close']})
print both.plot()
current = datetime.datetime.now
print current
current =+datetime.timedelta(days=1)
print current