Fetch a csv from a remote url and register the data so that it is queryable from the ``data`` object. Parameters ---------- url : str The url of the csv file to load. pre_func : callable[pd.DataFrame -> pd.DataFrame], optional A callba
(self,
url,
pre_func=None,
post_func=None,
date_column='date',
date_format=None,
timezone=pytz.utc.zone,
symbol=None,
mask=True,
symbol_column=None,
special_params_checker=None,
country_code=None,
**kwargs)
| 787 | |
| 788 | @api_method |
| 789 | def fetch_csv(self, |
| 790 | url, |
| 791 | pre_func=None, |
| 792 | post_func=None, |
| 793 | date_column='date', |
| 794 | date_format=None, |
| 795 | timezone=pytz.utc.zone, |
| 796 | symbol=None, |
| 797 | mask=True, |
| 798 | symbol_column=None, |
| 799 | special_params_checker=None, |
| 800 | country_code=None, |
| 801 | **kwargs): |
| 802 | """Fetch a csv from a remote url and register the data so that it is |
| 803 | queryable from the ``data`` object. |
| 804 | |
| 805 | Parameters |
| 806 | ---------- |
| 807 | url : str |
| 808 | The url of the csv file to load. |
| 809 | pre_func : callable[pd.DataFrame -> pd.DataFrame], optional |
| 810 | A callback to allow preprocessing the raw data returned from |
| 811 | fetch_csv before dates are paresed or symbols are mapped. |
| 812 | post_func : callable[pd.DataFrame -> pd.DataFrame], optional |
| 813 | A callback to allow postprocessing of the data after dates and |
| 814 | symbols have been mapped. |
| 815 | date_column : str, optional |
| 816 | The name of the column in the preprocessed dataframe containing |
| 817 | datetime information to map the data. |
| 818 | date_format : str, optional |
| 819 | The format of the dates in the ``date_column``. If not provided |
| 820 | ``fetch_csv`` will attempt to infer the format. For information |
| 821 | about the format of this string, see :func:`pandas.read_csv`. |
| 822 | timezone : tzinfo or str, optional |
| 823 | The timezone for the datetime in the ``date_column``. |
| 824 | symbol : str, optional |
| 825 | If the data is about a new asset or index then this string will |
| 826 | be the name used to identify the values in ``data``. For example, |
| 827 | one may use ``fetch_csv`` to load data for VIX, then this field |
| 828 | could be the string ``'VIX'``. |
| 829 | mask : bool, optional |
| 830 | Drop any rows which cannot be symbol mapped. |
| 831 | symbol_column : str |
| 832 | If the data is attaching some new attribute to each asset then this |
| 833 | argument is the name of the column in the preprocessed dataframe |
| 834 | containing the symbols. This will be used along with the date |
| 835 | information to map the sids in the asset finder. |
| 836 | country_code : str, optional |
| 837 | Country code to use to disambiguate symbol lookups. |
| 838 | **kwargs |
| 839 | Forwarded to :func:`pandas.read_csv`. |
| 840 | |
| 841 | Returns |
| 842 | ------- |
| 843 | csv_data_source : zipline.sources.requests_csv.PandasRequestsCSV |
| 844 | A requests source that will pull data from the url specified. |
| 845 | """ |
| 846 | if country_code is None: |
nothing calls this directly
no test coverage detected