COL_NAMES = ["Date", "Open Price","High Price","Low Price","Close Price", "No.of Shares", "Deliverable Quantity"]
import pandas as pd

#
infy = pd.read_csv(csv_filename, index_col='Date', usecols=COL_NAMES, parse_dates=True)
infy.columns =  list('OHLCVD')

infy = infy[::-1] # BSE scrip files are reverse latest first

print infy[:10]

hdf_filename = 'infy.h5'

from corp_actions_nse import get_corp_action_csv, CorpAction

c = get_corp_action_csv('infy')

corp_actions = {'corp_actions': c}

h5store = pd.HDFStore(hdf_filename)

h5store['infy'] = infy
h5store.get_storer('infy').attrs.corp_actions = c

h5store.close()

# open again for reading
h5store = pd.HDFStore(hdf_filename)

infy = h5store['infy']
corp_actions = h5store.get_storer('infy').attrs.corp_actions
# A sanity test for all nse download scrips.
# Sanity test should ensure that following downloads are still working
#
#pylint: disable-msg=wrong-import-position,ungrouped-imports
import random

# 1. Get a list of all nse symbols
from tickerplot.nse.nse_utils import nse_get_all_stocks_list
nse_get_all_stocks_list(start=random.randint(1, 10), count=2)
del nse_get_all_stocks_list

# 2. Get Corporate actions for a symbol ('infy')
from corp_actions_nse import get_corp_action_csv
get_corp_action_csv('INFY')
del get_corp_action_csv

# 3. Get a list of symbol name changes
from tickerplot.nse.nse_utils import nse_get_name_change_tuples
nse_get_name_change_tuples()
del nse_get_name_change_tuples
csv_filename = '500209.csv'

COL_NAMES = ["Date", "Open Price", "High Price", "Low Price", "Close Price", "No.of Shares", "Deliverable Quantity"]

#
infy = pd.read_csv(csv_filename, index_col='Date', usecols=COL_NAMES, parse_dates=True)
infy.columns = list('OHLCVD')

infy = infy[::-1] # BSE scrip files are reverse latest first

print(infy[:10])

hdf_filename = 'infy.h5'


c = get_corp_action_csv('infy')

corp_actions = {'corp_actions': c}

h5store = pd.HDFStore(hdf_filename)

h5store['infy'] = infy
h5store.get_storer('infy').attrs.corp_actions = c

h5store.close()

# open again for reading
h5store = pd.HDFStore(hdf_filename)

infy = h5store['infy']
corp_actions = h5store.get_storer('infy').attrs.corp_actions
# A sanity test for all nse download scrips.
# Sanity test should ensure that following downloads are still working
import random

# 1. Get a list of all nse symbols
from nse_utils import get_all_stocks_list
get_all_stocks_list(start=random.randint(1,10), count=2)
del get_all_stocks_list

# 2. Get Corporate actions for a symbol ('infy')
from corp_actions_nse import get_corp_action_csv
get_corp_action_csv('INFY')
del get_corp_action_csv

# 3. Get a list of symbol name changes
from nse_utils import nse_get_name_change_tuples
get_name_change_tuples()
del get_name_change_tuples

# 4. Get NSE indices for an index
from get_indices_nse import get_index
get_index('NIfTy'.upper())
del get_index