def __init__(self, startingBalance: float, data: list, lossStrategy: int, lossPercentage: float, takeProfitType: int, takeProfitPercentage: float, strategies: list, strategyInterval: Union[str, None] = None, symbol: str = None, marginEnabled: bool = True, startDate: datetime = None, endDate: datetime = None, precision: int = 4, outputTrades: bool = True): self.startingBalance = startingBalance self.symbol = symbol self.balance = startingBalance self.coin = 0 self.coinOwed = 0 self.commissionsPaid = 0 self.transactionFeePercentage = 0.001 self.trades = [] self.marginEnabled = marginEnabled self.precision = precision self.lossStrategy = lossStrategy self.lossPercentageDecimal = lossPercentage / 100 self.outputTrades: bool = outputTrades # Boolean that'll determine whether trades are outputted to file or not. convert_all_dates_to_datetime(data) self.data = data self.check_data() self.interval = self.get_interval() self.intervalMinutes = get_interval_minutes(self.interval) self.previousStopLoss = None self.initialStopLossCounter = 0 self.stopLossCounter = 0 self.stopLossExit = False self.takeProfitType = takeProfitType self.takeProfitPercentageDecimal = takeProfitPercentage / 100 self.currentPrice = None self.buyLongPrice = None self.sellShortPrice = None self.longTrailingPrice = None self.shortTrailingPrice = None self.profit = 0 self.startTime = None self.endTime = None self.inLongPosition = False self.inShortPosition = False self.previousPosition = None self.currentPeriod = None self.minPeriod = 0 self.pastActivity = [ ] # We'll add previous data here when hovering through graph in GUI. if len(strategyInterval.split()) == 1: strategyInterval = convert_small_interval(strategyInterval) self.strategyInterval = self.interval if strategyInterval is None else strategyInterval self.strategyIntervalMinutes = get_interval_minutes( self.strategyInterval) self.intervalGapMinutes = self.strategyIntervalMinutes - self.intervalMinutes self.intervalGapMultiplier = self.strategyIntervalMinutes // self.intervalMinutes if self.intervalMinutes > self.strategyIntervalMinutes: raise RuntimeError( "Your strategy interval can't be smaller than the data interval." ) self.ema_dict = {} self.rsi_dictionary = {} self.strategies: Dict[str, Strategy] = {} set_up_strategies(self, strategies) self.startDateIndex = self.get_start_index(startDate) self.endDateIndex = self.get_end_index(endDate)
def setup_strategies(self, strategies: list): """ Sets up strategies from list of strategies provided. :param strategies: List of strategies to set up and apply to bot. """ set_up_strategies(self, strategies)