Skip to content

Commit f2f31f0

Browse files
committed
Added docstrings
1 parent 7496535 commit f2f31f0

File tree

3 files changed

+41
-5
lines changed

3 files changed

+41
-5
lines changed

src/main.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
""" Main module """
2+
13
import views
24
from models import Compound, Simple
35

src/models.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
""" Models module """
2+
13
from typing import Callable, List, TypedDict
24

35

@@ -99,18 +101,28 @@ def __init__(self, cap: float, days: int, cycles: int):
99101
self.days = days
100102
self.cycles = cycles
101103
self.spent_gas: float
102-
self._yield: float
104+
self.yield_: float
103105
self.profit: float
104106
self.roi: float
105107
self.dif_profit: float
106108
self.dif_gas: float
107109

108110
def set_gas(self, gas: float) -> None:
111+
"""
112+
Set gas fee.
113+
:param gas: Gas fee.
114+
:return: None.
115+
"""
109116
self.spent_gas = self.cycles * gas
110117

111118
def set_interest(self, interest: float) -> None:
112-
self._yield = (self.cap * (1 + interest) ** self.cycles) - self.cap
113-
self.profit = self._yield - self.spent_gas
119+
"""
120+
Set interest rate.
121+
:param gas: Float with interest rate.
122+
:return: None.
123+
"""
124+
self.yield_ = (self.cap * (1 + interest) ** self.cycles) - self.cap
125+
self.profit = self.yield_ - self.spent_gas
114126
self.roi = (self.profit / self.cap) * 100
115127

116128

src/views.py

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
1-
from typing import List, TypedDict
1+
""" Views module """
2+
3+
from typing import List
24

35
from rich import box
46
from rich.console import Console
@@ -29,11 +31,21 @@
2931

3032

3133
def print_markdown(text: str) -> None:
34+
"""
35+
Print the text in markwdown format.
36+
:params text: String with the text.
37+
:return: None.
38+
"""
3239
markdown_formatted_text: Markdown = Markdown(text)
3340
CONSOLE.print(markdown_formatted_text)
3441

3542

3643
def simple_interest(simple: Simple) -> None:
44+
"""
45+
Print the simple interest table.
46+
:params simple: Simple interest object.
47+
:return: None.
48+
"""
3749
print_markdown("***")
3850
table: Table = Table(title="Interes Simple", box=box.SIMPLE)
3951
header: List[str] = ["Period", "Income ($)", "ROI (%)"]
@@ -53,6 +65,11 @@ def simple_interest(simple: Simple) -> None:
5365

5466

5567
def compound_interest(comp: Compound) -> None:
68+
"""
69+
Print the compound interest table.
70+
:params comp: Compound interest object.
71+
:return: None.
72+
"""
5673
print_markdown("---")
5774
title = f"Interes Compuesto por {comp.periods[0].days} días"
5875
table = Table(title=title, box=box.SIMPLE)
@@ -62,7 +79,7 @@ def compound_interest(comp: Compound) -> None:
6279
for row in comp.periods:
6380
table.add_row(
6481
str(row.days),
65-
str(round(row._yield, 4)),
82+
str(round(row.yield_, 4)),
6683
str(round(row.spent_gas, 4)),
6784
str(round(row.profit, 4)),
6885
str(round(row.dif_profit, 4)),
@@ -80,6 +97,11 @@ def compound_interest(comp: Compound) -> None:
8097

8198

8299
def best_comp(best_pds: List[Period]) -> None:
100+
"""
101+
Print a table with the best periods to do compund.
102+
:params best_pds: List of Period object.
103+
:return: None.
104+
"""
83105
print_markdown("___")
84106
table = Table(title="Frecuencias Óptimas", box=box.SIMPLE)
85107
header = ["Period", "ROI ($)", "Profit (%)"]

0 commit comments

Comments
 (0)