Browse Source

fix: tqdm working

pull/15/head
QuentinN42 1 year ago
parent
commit
70b2b2dcea
Signed by: number42 GPG Key ID: 2CD7D563712B3A50
  1. 5
      auto_trading/bot.py
  2. 3
      auto_trading/broker/backtest.py
  3. 4
      auto_trading/interfaces.py
  4. 2
      main.py

5
auto_trading/bot.py

@ -26,10 +26,7 @@ class Bot:
def run(self):
"""run the bot"""
iterator = (
tqdm(self.broker) if self.logger.level >= logging.DEBUG else self.broker
)
for data in iterator:
for data in tqdm(self.broker):
self.run_once(data)
def run_once(self, data: DataFrame):

3
auto_trading/broker/backtest.py

@ -71,3 +71,6 @@ class Backtest(DataBroker):
except IndexError:
self._cursor -= 1
raise StopIteration
def __len__(self) -> int:
return len(self.dates) - self.start

4
auto_trading/interfaces.py

@ -69,6 +69,10 @@ class DataBroker(ABC):
For each time and each stock give (high, low, open, close).
"""
@abstractmethod
def __len__(self) -> int:
"""Total number of values"""
class Indicator(ABC):
"""Somethink that give you an insight of the market."""

2
main.py

@ -10,7 +10,7 @@ pd.options.plotting.backend = "plotly"
if __name__ == "__main__":
bt = Backtest("./data/NYSE_smallest.csv")
bt = Backtest("./data/NYSE.csv")
ptf = InMemoryPortfolio(
base_balance=100, change_rate_getter=lambda: bt.current_change
)

Loading…
Cancel
Save