FinancePy

FinancePy API Reference

Date

financepy.utils.date

Classes

Date

Date(d, m, y, hh=0, mm=0, ss=0)
A date class to manage dates that is simple to use and includes a number of useful date functions used frequently in Finance.

Methods

day_of_year

day_of_year(self) -> float
Day of the year which can be float for intraday

from_ymd_excel

from_ymd_excel(cls, d, m, y, excel_dt)

No description available.

from_excel

from_excel(excel_dt: float) -> 'Date'

No description available.

from_string

from_string(cls, date_string, format_string)
Create a Date from a date and format string. Example Input: start_dt = Date('1-1-2018', '%d-%m-%Y')

from_date

from_date(cls, value)

No description available.

is_weekend

is_weekend(self)
returns True if the date falls on a weekend.

is_eom

is_eom(self)
returns True if this date falls on a month end.

eom

eom(self)
returns last date of month of this date.

add_hours

add_hours(self, hours)

No description available.

add_minutes

add_minutes(self, minutes)

No description available.

add_seconds

add_seconds(self, seconds)

No description available.

add_days

add_days(self, num_days=1)

No description available.

add_weekdays

add_weekdays(self, num_days: int)
Returns a new date that is num_days working days after Date. Note that only weekends are taken into account. Other Holidays are not. If you want to include regional holidays then use add_business_days from the FinCalendar class.

add_months

add_months(self, mm: list | int) -> ForwardRef('Date') | list
Returns a new date that is mm months after the Date. If mm is an integer or float you get back a single date. If mm is a vector you get back a vector of dates.

add_years

add_years(self, yy: numpy.ndarray | float)
Returns a new date that is yy years after the Date. If yy is an integer or float you get back a single date. If yy is a list you get back a vector of dates.

next_cds_date

next_cds_date(self, mm: int = 0)
Returns a CDS date that is mm months after the Date. If no argument is supplied then the next CDS date after today is returned.

third_wednesday_of_month

third_wednesday_of_month(self, m: int, y: int)
For a specific month and year this returns the day number of the 3rd Wednesday by scanning through dates in the third week.

next_imm_date

next_imm_date(self)
This function returns the next IMM date after the current date This is a 3rd Wednesday of Jun, March, Sep or December. For an IMM contract the IMM date is the First Delivery Date of the futures contract.

add_tenor

add_tenor(self, tenor: list | financepy.utils.date.Date.str | financepy.utils.tenor.Tenor)
Return the date following the Date by a period given by the tenor which is a string consisting of a number and a letter, the letter being d, w, m , y for day, week, month or year. This is case independent. For example 10Y means 10 years while 120m also means 10 years. The date is NOT weekend or holiday calendar adjusted. This must be done AFTERWARDS.

datetime

datetime(self)
Returns a datetime of the date

str

str(self)
returns a formatted string of the date

Functions

daily_working_day_schedule

daily_working_day_schedule(start_dt: financepy.utils.date.Date, end_dt: financepy.utils.date.Date)
Returns a list of working dates between start_dt and end_dt. This function should be replaced by dateRange once add_tenor allows for working days.

date_range

date_range(start_dt: financepy.utils.date.Date, end_dt: financepy.utils.date.Date, tenor: str = '1D')
Returns a list of dates between start_dt (inclusive) and end_dt (inclusive). The tenor represents the distance between two consecutive dates and is set to daily by default.

datediff

datediff(d1: financepy.utils.date.Date, d2: financepy.utils.date.Date)
Calculate the number of days between two Findates.

days_in_month

days_in_month(m, y)
Get the number of days in the month (1-12) of a given year y.

from_datetime

from_datetime(dt: financepy.utils.date.Date)
Construct a Date from a datetime as this is often needed if we receive inputs from other Python objects such as Pandas dataframes.

is_leap_year

is_leap_year(y: int)
Test whether year y is a leap year - if so return True, else False

parse_dt

parse_dt(date_str, date_format)
Parse a date string into day, month, and year components.

vectorisation_helper

vectorisation_helper(func)
Decorator to allow a function to be vectorised over an iterable
Generated automatically from the FinancePy source code. Do not edit this file manually.