You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

44 lines
1.3 KiB

One script to rule them all, One script to find them,
One script to bring them all and in the darkness bind them
import logging
from tqdm import tqdm # type: ignore
from typing import Dict
from pandas import DataFrame # type: ignore
from .interfaces import DataBroker, Strategy, PTF
class Bot:
"""The class that wrap all the classes together.
For more information, read /documentation/Diagramme.svg
def __init__(self, ptf: PTF, strategy: Strategy, broker: DataBroker):
"""Initialize the bot."""
self.logger = logging.getLogger(self.__class__.__name__)
self.ptf = ptf
self.strategy = strategy = broker
def run(self):
"""run the bot"""
for data in tqdm(
def run_once(self, data: DataFrame):
"""run the bot once"""
orders =, self.ptf.state)
self.logger.debug("Get %d orders to execute", len(orders))
def balance(self):
return self.ptf.balance
def total_balance(self, conversion_rate: Dict[str, float]) -> float:
"""Return the current total balance."""
return self.ptf.total_balance(conversion_rate)