خرید بک لینک

Vote count: 0

I have tick data containing symbols, bid prices, and ask prices. I was able to find the average spread and standard deviation of each symbol.

I'd like to create a confidence interval for each symbol and have the final DataFrame output have the columns

  • ticker symbol
  • average spread
  • lower bound 95% confidence
  • upper bound 95% confidence

How can I do that? This is how far I've been able to get:

df = pd.read_csv('C:\Users\William\Desktop\tickdata.csv',
                 dtype={'ticker': str, 'bidPrice': np.float64, 'askPrice': np.float64, 'afterHours': str},
                 usecols=['ticker', 'bidPrice', 'askPrice', 'afterHours'],
                 nrows=3000000
                 )

df = df[df.afterHours == "False"]
df = df[df.bidPrice != 0]
df = df[df.askPrice != 0]
df['spread'] = (df.askPrice - df.bidPrice)

print(df.groupby(['ticker'])['spread'].mean())
print(df.groupby(['ticker'])['spread'].std(ddof=0) * 1.96)

asked 3 mins ago

1 Answer

Vote count: 0

just call pd.dataframe on it.

new_df = pd.dataframe(df.groupby(['ticker'])['spread'].mean()) http://pandas.pydata.org/pandas-docs/stable/generated/pandas.DataFrame.html

answered 2 mins ago

برچسب: نویسنده: استخدام کار تاريخ: جمعه 28 خرداد 1395 ساعت: 11:42

صفحه بندی