Custom Database#
- morningstar_data.direct.my_database.save_historical_values(
- values: DataFrame,
- key_column: str = 'SecId',
- date_column: str = 'Date',
- blank: Blank | str = Blank.warning,
Saves historical time series values for data points in the user’s or firm’s database in Morningstar Direct.
- Parameters:
values (
DataFrame
) –A DataFrame object with the time series values to be saved in the user’s or firm’s database. The DataFrame columns should include:
SecId - Column containing investment ID values. If a column named SecId is not present, the column name specified in the key_column argument will be used.
DataPointName - Data point name which will be updated. Multiple data points can be updated in one request.
Date - Column containing date values. If a column named Date is not present, the column name specified in the date_column argument will be used.
For example:
==================== ======== =============== =============== =============== SecId Date DataPointName1 DataPointName2 DataPointName3 ==================== ======== =============== =============== =============== <InvestmentId> <date> <value> <value> <value> <InvestmentId> <date> <value> <value> <value> ==================== ======== =============== =============== ===============
key_column (
str
) – Name of the column containing investment ID values. If not specified, the column SecId will be used.date_column (
str
) – Name of the column containing date values. If not specified, the column Date will be used.blank (
md.direct.data_type.Blank
) –Argument specifying how blank values in the DataFrame should be handled. Valid enum values for this argument are:
warning - Raises an error if the DataFrame contains at least one null or empty (str) value.
ignore - Saves all DataFrame values except for null or empty (str) values.
update - Replaces/updates all existing values with the provided values. Deletes any value that is sent as null, None or empty (str) values.
- Returns:
DataFrame:
- Examples:
import morningstar_data as md from pandas import DataFrame df = DataFrame({"SecId": ["FOUSA00C3M", "F000010NJ5"], "Date": ["2022-02-10","2022-04-2"], "DataPointNameText": ["2","9"], "DataPointNameNumber": [12.2178, 78514]}) md.direct.my_database.save_historical_values(values=df, key_column="SecId", blank=md.direct.data_type.Blank.warning)
import morningstar_data as md from pandas import DataFrame df = DataFrame({"SecId": ["FOUSA00C3M", "F000010NJ5"], "Date": ["2022-02-10","2022-04-2"], "DataPointNameText": ["2","9"], "DataPointNameNumber": [12.2178, 78514]}) md.direct.firm_database.save_historical_values(values=df, key_column="SecId", blank=md.direct.data_type.Blank.warning)
- Errors:
AccessDeniedError: Raised when the user is not authenticated.
ForbiddenError: Raised when the user does not have permission to access the requested resource.
InternalServerError: Raised when the server encounters an unhandled error.
NetworkExceptionError: Raised when the request fails to reach the server due to a network error.
ResourceNotFoundError: Raised when the requested resource does not exist in Direct.
- morningstar_data.direct.my_database.save_values(
- values: DataFrame,
- key_column: str = 'SecId',
- blank: Blank | str = Blank.warning,
Saves values for data points in the user’s or firm’s database.
- Parameters:
values (
DataFrame
) –A DataFrame object with the values to be saved in the user’s or firm’s database. The DataFrame columns should include:
SecId - Column containing investment ID values. If a column named SecId is not present, the column name specified in the key_column argument will be used.
DataPointName - Data point name which will be updated. Multiple data points can be updated in one request.
For example:
==================== =============== =============== =============== SecId DataPointName1 DataPointName2 DataPointName3 ==================== =============== =============== =============== <InvestmentId> <value> <value> <value> <InvestmentId> <value> <value> <value> ==================== =============== =============== ===============
key_column (
str
) – Name of the column containing investment ID values. If not specified, the column SecId will be used.blank (
md.direct.data_type.Blank
) –Argument specifying how blank values in the DataFrame should be handled. Valid enum values for this argument are:
warning - Raises an error if the DataFrame contains at least one null or empty (str) value.
ignore - Saves all DataFrame values except for null or empty (str) values.
update - Replaces/updates all existing values with the provided values. Deletes any value that is sent as null, None or empty (str) values.
- Returns:
DataFrame:
- Examples:
import morningstar_data as md from pandas import DataFrame df = DataFrame({"SecId": ["FOUSA00C3M", "F000010NJ5"], "DataPointNameText": ["2","9"], "DataPointNameDate": ["2022-02-10","2022-04-2"], "DataPointNameNumber": [12.2178, 78514]}) md.direct.my_database.save_values(values=df, key_column="SecId", blank=md.direct.data_type.Blank.warning)
import morningstar_data as md from pandas import DataFrame df = DataFrame({"SecId": ["FOUSA00C3M", "F000010NJ5"], "DataPointNameText": ["2","9"], "DataPointNameDate": ["2021-05-31","2021-02-01"], "DataPointNameNumber": [12.2178, 78514]}) md.direct.firm_database.save_values(values=df, key_column="SecId", blank=md.direct.data_type.Blank.warning)
- Errors:
AccessDeniedError: Raised when the user is not authenticated.
ForbiddenError: Raised when the user does not have permission to access the requested resource.
InternalServerError: Raised when the server encounters an unhandled error.
NetworkExceptionError: Raised when the request fails to reach the server due to a network error.
ResourceNotFoundError: Raised when the requested resource does not exist in Direct.