def generate_dataframe(self, symbols=None, date_index=None, price_type="<STR_LIT>"):
<EOL>if symbols is None:<EOL><INDENT>symbols = list(Currency.objects.all().values_list('<STR_LIT>', flat=True))<EOL><DEDENT>try:<EOL><INDENT>start_date = date_index[<NUM_LIT:0>]<EOL>end_date = date_index[-<NUM_LIT:1>]<EOL><DEDENT>except:<EOL><INDENT>start_date = DATEFRAME_START_DATE<EOL>end_date = date.today()<EOL><DEDENT>date_index = date_range(start_date, end_date)<EOL>currency_price_data = CurrencyPrice.objects.filter(currency__symbol__in=symbols,<EOL>date__gte=date_index[<NUM_LIT:0>],<EOL>date__lte=date_index[-<NUM_LIT:1>]).values_list('<STR_LIT:date>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>')<EOL>try:<EOL><INDENT>forex_data_array = np.core.records.fromrecords(currency_price_data, names=['<STR_LIT:date>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'])<EOL><DEDENT>except IndexError:<EOL><INDENT>forex_data_array = np.core.records.fromrecords([(date(<NUM_LIT>, <NUM_LIT:1>, <NUM_LIT:1>), "<STR_LIT>", <NUM_LIT:0>, <NUM_LIT:0>)], names=['<STR_LIT:date>', '<STR_LIT>', '<STR_LIT>', '<STR_LIT>'])<EOL><DEDENT>df = DataFrame.from_records(forex_data_array, index='<STR_LIT:date>')<EOL>df['<STR_LIT:date>'] = df.index<EOL>if price_type == "<STR_LIT>":<EOL><INDENT>df['<STR_LIT>'] = (df['<STR_LIT>'] + df['<STR_LIT>']) / <NUM_LIT:2><EOL><DEDENT>elif price_type == "<STR_LIT>":<EOL><INDENT>df['<STR_LIT>'] = df['<STR_LIT>']<EOL><DEDENT>elif price_type == "<STR_LIT>":<EOL><INDENT>df['<STR_LIT>'] = df['<STR_LIT>']<EOL><DEDENT>else:<EOL><INDENT>raise ValueError("<STR_LIT>" % str(price_type))<EOL><DEDENT>df = df.pivot(index='<STR_LIT:date>', columns='<STR_LIT>', values='<STR_LIT>')<EOL>df = df.reindex(date_index)<EOL>df = df.fillna(method="<STR_LIT>")<EOL>unlisted_symbols = list(set(symbols) - set(df.columns))<EOL>for unlisted_symbol in unlisted_symbols:<EOL><INDENT>df[unlisted_symbol] = np.nan<EOL><DEDENT>df = df[symbols]<EOL>return df<EOL>
Generate a dataframe consisting of the currency prices (specified by symbols)
from the start to end date