stockdaq.data.data.Data¶
-
class
stockdaq.data.data.Data(datetime_column=None, open_=None, high=None, low=None, close=None, volume=None, dataframe=None, load_path=None)¶ Bases:
objectData class for saving and loading stockdaq format stock data.
- Parameters
datetime_column (pandas.core.indexes.datetimes.DatetimeIndex) – Date and time
open (array) – open price data
high (array) – high price data
low (array) – low price data
close (array) – close price data
volume (array) – volume data
Attritubes –
---------- –
datetime_column – Date and time
open – open price data
high – high price data
low – low price data
close – close price data
volume – volume data
dataframe (pandas.core.frame.DataFrame) – The data frame.
-
__init__(datetime_column=None, open_=None, high=None, low=None, close=None, volume=None, dataframe=None, load_path=None)¶ Initization with data array or dataframe.
- Parameters
datetime_column (pandas.core.indexes.datetimes.DatetimeIndex) – Date and time
open (array) – open price data
high (array) – high price data
low (array) – low price data
close (array) – close price data
volume (array) – volume data
dataframe (pandas.core.frame.DataFrame) – dataframe
load_path (str) – file name of a stockdaq data file.
Note
Only specify data in stockdaq standardized format.
Methods
__init__([datetime_column, open_, high, …])Initization with data array or dataframe.
load(path[, format])Load a single stockdaq data file.
merge(path[, mergehow])Merge self.dataframe with an exist datafile.
save(path[, format, conflict, mergehow])Save the dataframe
-
load(path, format='hdf5')¶ Load a single stockdaq data file.
- Parameters
path (str) – The path of the file to be read.
format (str, optional) – The format of the file to be saved. Defaults to “hdf5”. Options are [“hdf5”, “csv”]
-
merge(path, mergehow='keep old')¶ Merge self.dataframe with an exist datafile.
- Parameters
path (str) – The path of the file to be merged.
mergehow (str, optional) – “keep old”: If there are duplicated indexes, keep old data. “update”: If there are duplicated indexes, keep new data.
-
save(path, format='hdf5', conflict='merge', mergehow='keep old', **kwargs)¶ Save the dataframe
- Parameters
path (str) – The path to be saved to.
format (str, optional) – The format of the file to be saved. Defaults to “hdf5”. Options are [“hdf5”, “csv”]
conflict (str, optional) – How to resolve conflicts. options are [“merge”, “overwrite”, “ignore”]. “merge”: append non-duplicating data to the existing datafile. “overwrite”: replace the existing file. “ignore”: don’t do anything.
mergehow (str, optional) – Only effective when conflict == “merge”. “keep old”: If there are duplicated indexes, keep old data. “update”: If there are duplicated indexes, keep new data.
**kwargs – Keyword arguments passed to the pandas methods