margot.data.column.columns

class margot.data.column.columns.BaseColumn(time_series: str, *args, **kwargs)

A Column represents a single time series of a symbol.

This could be adjusted_close, open, volume - etc.

Example

volume = column.AlphaVantage(function=’historical_daily_adjusted’, field=’adjusted_close’)

Parameters
  • function (str) – the name of the function passed to the Alphavantage API

  • time_series (str) – the name of the time_series that will be returned

get_label()

Return the label for this column.

clone()

Return a new instance of oneself.

setup(symbol: str, env: dict = {})

Setup the column.

Called by the Symbol so that the symbol name can be passed.

clean(df)

Clean the data.

load_or_fetch_series(symbol: str)

Load of fetch the Dataframe, return the series.

In order to return the time-series, first determine if we have it and can return it, or if we need to fetch it.

TODO: Test for up-to-dateness (or maybe that happens in Symbol)?

Parameters

symbol (str) – the name of the symbol to fetch.

Returns

time-series of the column

Return type

pd.Series

refresh()

Refresh the data from the source.

Returns

the whole dataframe (cleaned)

Return type

pd.DataFrame

load(symbol: str)

Load it.

save(df, symbol)

Save it.

get_series()

Get the data series as a pandas series.

Returns

time series of the field

Return type

pd.Series

property latest

Return the latest value in this series.