financialdatapy.date module

This module parses and converts objects to date format objects

financialdatapy.date.validate_date(period: str, start: bool = False) pandas._libs.tslibs.timestamps.Timestamp[source]

Validate the format of date passed as a string.

Parameters
  • period (str) – Date in string. If None, date of today is assigned.

  • start (bool, optional) – Whether argument passed is a starting date or an ending date, defaults to False.

Raises

IntegerDateInputError – If integer type object is passed.

Returns

Date with format YYYY-MM-DD or YY-MM-DD.

Return type

pandas.Timestamp

financialdatapy.date.string_to_date(period: Union[str, datetime.datetime], date_format: str) pandas._libs.tslibs.timestamps.Timestamp[source]

Convert date in string format or datetime object to pandas.Timestamp.

Parameters
  • period (Union[str, datetime]) – Date object either string or datetime.datetime.

  • date_format (str) – Date format to convert to.

Returns

Date in Pandas.Timestamp.

Return type

pd.Timestamp

financialdatapy.date.date_to_timestamp(period: pandas._libs.tslibs.timestamps.Timestamp) int[source]

Parse date passed in into a timestamp.

Parameters

period (pandas.Timestamp) – Date object.

Returns

The timestamp value equivalent to the date passed.

Return type

int

financialdatapy.date.convert_date_format(period: pandas._libs.tslibs.timestamps.Timestamp, format: str) str[source]

Convert date object to desired date format.

Parameters
  • period (pandas.Timestamp) – Date object.

  • format (str) – Desired date format to convert to.

Returns

Converted date in string.

Return type

str