Skip to content

Commit

Permalink
updated attributes to protected
Browse files Browse the repository at this point in the history
  • Loading branch information
alvarob96 committed Oct 9, 2019
1 parent 06726f7 commit f6e008f
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions investpy_portfolio/StockPortfolio.py
Expand Up @@ -36,8 +36,8 @@ def __init__(self):
they are filled once the class is instanced.
"""
self.stocks = list()
self.stock_objs = list()
self._stocks = list()
self._stock_objs = list()
self.data = None

def add_stock(self, stock_name, stock_country, purchase_date, num_of_shares, cost_per_share):
Expand All @@ -61,12 +61,12 @@ def add_stock(self, stock_name, stock_country, purchase_date, num_of_shares, cos
stock.validate()

if stock.valid is True:
self.stock_objs.append(stock)
self._stock_objs.append(stock)

info = self.__get_stock_info(stock=stock)

self.stocks.append(info)
self.data = pd.DataFrame(self.stocks)
self._stocks.append(info)
self.data = pd.DataFrame(self._stocks)
else:
raise ValueError("ERROR [0001]: The introduced Stock is not valid.")

Expand Down Expand Up @@ -94,6 +94,9 @@ def __get_stock_info(self, stock):

curr_price = self.current_price(data=data)

""" dividends = investpy.get_stock_dividends(stock=stock.stock_symbol,
country=stock.stock_country) """

info = {
'stock_name': stock.stock_name,
'stock_country': stock.stock_country,
Expand All @@ -114,12 +117,12 @@ def refresh(self):
from every Stock listed in the StockPortfolio.
"""
if len(self.stock_objs) > 0:
self.stocks = list()
for stock_obj in self.stock_objs:
if len(self._stock_objs) > 0:
self._stocks = list()
for stock_obj in self._stock_objs:
info = self.__get_stock_info(stock=stock_obj)
self.stocks.append(info)
self.data = pd.DataFrame(self.stocks)
self._stocks.append(info)
self.data = pd.DataFrame(self._stocks)


@staticmethod
Expand Down

0 comments on commit f6e008f

Please sign in to comment.