text
stringlengths
0
828
fnum)
elif isinstance(feedlike, Feed):
fed = feedlike
else:
raise Exception(""Invalid Feed {}"".format(repr(feedlike)))
self.feeds.append(fed)
objs = object_session(self)
objs.add(fed)
objs.commit()"
1867,"def add_alias(self, alias):
"""""" Add an alias to a Symbol
Parameters
----------
alias : str
The alias
""""""
objs = object_session(self)
if isinstance(alias, list):
raise NotImplementedError
elif isinstanceofany(alias, (str, unicode)):
a = SymbolAlias(self, alias)
self.aliases.append(a)
objs.add(a)"
1868,"def _final_data(self):
""""""
Returns
-------
A list of tuples representing rows from the datatable's index
and final column, sorted accordingly.
""""""
dtbl = self.datatable
objs = object_session(self)
if isinstance(dtbl, Table):
return objs.query(dtbl.c.indx, dtbl.c.final).all()
else:
raise Exception(""Symbol has no datatable, likely need to cache first."")"
1869,"def _max_min(self):
""""""
Returns
-------
A tuple consisting of (max, min) of the index.
""""""
dtbl = self.datatable
objs = object_session(self)
if isinstance(dtbl, Table):
return objs.query(func.max(dtbl.c.indx).label(""max_indx""),
func.min(dtbl.c.indx).label(""min_indx"")).one()
else:
raise Exception(""Symbol has no datatable"")"
1870,"def _all_datatable_data(self):
""""""
Returns
-------
A list of tuples representing rows from all columns of the datatable,
sorted accordingly.
""""""
dtbl = self.datatable
objs = object_session(self)
imcols = [dtbl.c.indx, dtbl.c.final, dtbl.c.override_feed000, dtbl.c.failsafe_feed999]
cols = imcols[:3] + [c for c in dtbl.c if c not in (imcols)] + [imcols[3]]
if isinstance(dtbl, Table):
return objs.query(*cols).order_by(dtbl.c.indx).all()
else:
raise Exception(""Symbol has no datatable"")"
1871,"def df(self):
""""""
Note: this accessor is read-only. It should be copied, if accessed in
an application, more than once.
Returns
-------
Dataframe of the symbol's final data.
""""""
data = self._final_data()
if len(data) == 0:
adf = pd.DataFrame(columns = [self.index.name, self.name])
return adf.set_index(self.index.name)
adf = pd.DataFrame(data)
if len(adf.columns) != 2:
msg = ""Symbol ({}) needs to be cached prior to building a Dataframe""
msg = msg.format(self.name)
raise Exception(msg)
adf.columns = [self.index.name, self.name]
return self._finish_df(adf, 'FINAL')"
1872,"def datatable_df(self):
"""""" returns the dataframe representation of the symbol's final data """"""
data = self._all_datatable_data()
adf = pd.DataFrame(data)
adf.columns = self.dt_all_cols
return self._finish_df(adf, 'ALL')"
1873,"def _init_datatable(self):