I'm using python with pandas to deal with stock tick data and I would like to compress it down to the total volume for the day, the high, the low, the average, 25% of trade volume, 75% of trade volume. I am unsure of how to find where the 25% and 75% levels would lie.
#Refrences
from time import *
import urllib.request as web
import pandas as pd
import os
dateToday = "2014-10-31"
def pullData(exchange,stock,date):
baseUrl='http://netfonds.no/quotes/tradedump.php?csv_format=csv'
fullUrl=baseUrl+'&date='+date.replace("-","")+'&paper='+stock+'.'+exchange
fileName=('netfonds/trades/'+stock+'.txt')
try:
if not os.path.isdir(os.path.dirname(fileName)):
os.makedirs(os.path.dirname(fileName))
except OSError:
print("Directory Error")
#print(fullUrl)
webBuffer=web.urlopen(fullUrl)
webData=pd.read_csv(webBuffer,usecols=['price','quantity'])
low = webData['price'].min()
high = webData['price'].max()
print(low,high)
def getList(fileName):
stockList = []
file = open(fileName+'.txt', 'r').read()
fileByLines = file.split('\n')
for eachLine in fileByLines:
if '#' not in eachLine:
lineByValues = eachLine.split('.')
stockList.append(lineByValues)
return stockList
def fromList():
print("Parsing stock tickers...")
stockList = getList('stocks')
print("Found "+str(len(stockList))+" stocks")
for eachEntry in stockList:
start_time = time()
try:
print("Attempting to pull data for "+eachEntry[1])
pullData(eachEntry[0],eachEntry[1],dateToday)
print("Pulled succcessfully in "+str(round(time()-start_time))+" seconds")
except Exception:
print("Unable to pull data... "+eachEntry[1])
first_time = time()
fromList()
print("Program Finished! Took "+str(round((time()-first_time)/60))+' minutes')