Exemplo n.º 1
0
	def prepare_t_frame(self):
		start_date, end_date = self.start_date, self.end_date
		while(start_date <= end_date):
			_file = get_exchange_file('nse', start_date)
			if is_file_exist(_file):
				self.add_to_t_frame_list(_file)
			start_date += datetime.timedelta(days=1)
		
		frame = pd.concat(self.t_frame_list)
		frame.reset_index()
		return frame
Exemplo n.º 2
0
	def prepare_q_frame_dict(self):
		result = {'date':self.end_date}
		date = self.end_date
		_file = get_exchange_file('nse', date)
		while(is_file_exist(_file) == False):
			date -= datetime.timedelta(days=1)	
			_file = get_exchange_file('nse', date)
			if date == self.start_date:
				break
				
		df = pd.read_csv( _file,index_col=None, header=0)		
		result['frame'] = df[self.q_frame_column]
		return result
Exemplo n.º 3
0
    def load(self):
        sw = StopWatch()
        start_date, end_date = self.start_date, self.end_date

        while (start_date <= end_date):
            url, fileName = self.prepare_url_and_file_name(start_date)
            weekday = calendar.day_abbr[start_date.weekday()]
            file_path_on_disk = self.data + "/%s" % (fileName)
            if weekday != 'Sat' and weekday != 'Sun' and not is_file_exist(
                    file_path_on_disk):
                result = self.pool.apply_async(request_and_extract,
                                               args=(url, self.data))
                if result.get() == True:
                    self.counter += 1
            start_date += datetime.timedelta(days=1)

        self.pool.close()
        self.pool.join()
        t1 = sw.done()
        print("Total File Loaded %s in %s seconds" % (self.counter, t1))
Exemplo n.º 4
0
def _start(exchange, date, max, range, **kwargs):
    print("<h4>Result for %s</h4>" % (exchange))
    _file = config.get(
        "%s_result" %
        (exchange.lower())) + "//" + date.strftime('%d_%b_%Y') + ".csv"
    if (util.is_file_exist(_file)):
        frame = pd.read_csv(_file, index_col=None, header=0)
        #frame.set_index('SYMBOL', inplace=True)
        for top in range:
            if (top == -1):
                break
            printAnalysis(frame, max, top)
        between = kwargs.get('between')
        if between is not None:
            printTopBetween(frame, max, between[0], between[1])

        symbol = kwargs.get('symbol')
        if symbol is not None:
            printSelected(frame, symbol)
    else:
        print('Not Have predition for data', date)
Exemplo n.º 5
0
def is_predicted(exchange, end_date):
    filename = config.get(
        "%s_result" %
        (exchange.lower())) + "\\" + end_date.strftime('%d_%b_%Y') + ".csv"
    return util.is_file_exist(filename)