Skip to content

Commit

Permalink
FEAT: Begin work on FIndex class.
Browse files Browse the repository at this point in the history
  • Loading branch information
genedan committed Jan 9, 2025
1 parent 26c913a commit 5d13eaf
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions faslr/index/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,46 @@
from pandas import DataFrame


class FIndex:
def __init__(
self,
name: str,
description: str,
origin: list,
changes: list
):
self.name = name
self.description = description
self.origin = origin
self.changes = changes

@property
def df(self) -> DataFrame:

df_idx = pd.DataFrame(
data={
'Origin': self.origin,
'Change': self.changes,
'Factor': self.factors
}
)

return df_idx

@property
def factors(self) -> list:

row_count = len(self.origin)
factors = [1 for x in range(row_count)]
for i in range(row_count - 1, -1, -1):
if i == row_count - 1:
pass
else:
factors[i] = factors[i + 1] * (1 + self.changes[i + 1])

return factors


class IndexTableModel(FAbstractTableModel):
def __init__(
self,
Expand Down

0 comments on commit 5d13eaf

Please sign in to comment.