def __init__(self, db=False): self.loader = _DataLoader(db=db, ib=False) self.master_screener = pd.DataFrame() self.strategy = FabStrategy() self.tf_delay_match = { 235: 0, 145: 7, 210: 5, 165: 4, 130: 13, 220: 12 } self.list_of_enters = { ('Rule 1', 'Long'): self.strategy.rule_1_buy_enter, ('Rule 1', 'Short'): self.strategy.rule_1_short_enter, ('Rule 2', 'Long'): self.strategy.rule_2_buy_enter, ('Rule 2', 'Short'): self.strategy.rule_2_short_enter, ('Rule 3', 'Long'): self.strategy.rule_3_buy_enter, ('Rule 3', 'Short'): self.strategy.rule_3_short_enter } self.list_of_exits = { ('Rule 1', 'Long'): self.strategy.rule_1_buy_exit, ('Rule 1', 'Short'): self.strategy.rule_1_short_exit, ('Rule 2', 'Long'): self.strategy.rule_2_buy_stop_absolute, ('Rule 2', 'Short'): self.strategy.rule_2_short_stop_absolute, ('Rule 3', 'Long'): self.strategy.rule_1_buy_exit, ('Rule 3', 'Short'): self.strategy.rule_1_short_exit }
def __init__(self): self.start = False self.client = None self.capital = None self.leverage = 1 / 1000 self.tf = None self.symbol = None self.loader = _DataLoader() self.df = None
def __init__(self): self.end = datetime.today().strftime('%Y-%m-%d') self.loader = _DataLoader() self.range_data = None self.symbol_data = None self.start = None self.summary = "Nothing to Show Yet" self.tf = None self.trade_history = TradeHistory() self.tf_data = None
def optimal_sensitivity_calculator(self, symbol_list, sensitivity_list, tf, delay, rule, side): df = pd.DataFrame() for symbol in symbol_list: self.loader = _DataLoader(db=True) self.load_backtesting_data(symbol=symbol, all_data=True) for sensitivity in sensitivity_list: print(symbol, sensitivity) self.start_backtesting(tf=tf, delay=delay, sensitivity=sensitivity) row = self.generate_asset_metrics(self.detailed_th, f'Rule {rule}', side, sensitivity=sensitivity) df = df.append(row) return df
def __init__(self): self.live_trade_history = TradeHistory() self.trade_journal = pd.DataFrame() self.dic = {"BUY": "Long", "SELL": "Short"} self.inverse_dic = dict((y, x) for x, y in self.dic.items()) self.latest_trade_info = None self.latest_trade = None self.loader = _DataLoader(db=False) self.precisions = { symbol_dic['symbol']: symbol_dic['quantityPrecision'] for symbol_dic in self.loader.binance.futures_exchange_info() ['symbols'] }
def __init__(self, db=True): self.loader = _DataLoader(db=db) self.analyzer = Analyzer() self.date_range = None self.symbol_data = None self.start = None self.end = datetime.today().strftime('%Y-%m-%d') self.tf = None self.df = None self.df_th = None self.df_tf = None self.trade_history = TradeHistory() self.illustrator = Illustrator() self.strategy = FabStrategy() self.tf_data = None self.pnl = None self.trades = None self.summary = "Nothing to Show Yet"
def __init__(self, binance=True, qtrade=False, db=False, ib=False): if binance: self.binance = Client() # self.ftx = FtxClient() self.capital = None self.leverage = 1 self.tf = None self.executor = TradeExecutor() self.loader = _DataLoader(db=db, qtrade=qtrade, ib=ib) self.illustrator = Illustrator() self.strategy = FabStrategy() self.order_history = pd.DataFrame() self.trade_replay = [] self.precisions = { symbol_dic['symbol']: symbol_dic['quantityPrecision'] for symbol_dic in self.loader.binance.futures_exchange_info() ['symbols'] }
def optimal_tf_calculator(self, symbols_list, tf_list, delay_list): df = pd.DataFrame() for symbol in symbols_list: self.loader = _DataLoader(db=True) self.load_backtesting_data(symbol=symbol, all_data=True) if len(self.df) == 0: continue for tf in tf_list: for delay in delay_list: print(symbol, tf, delay) self.start_backtesting(tf, delay=delay) if len(self.trade_history) in [0,1,2]: continue for rule in [1, 2, 3]: for side in ['Long', 'Short']: df = pd.concat([df, self.generate_asset_metrics(self.detailed_th, f'Rule {rule}', side, delay=delay)]) print('saved', symbol) df.to_csv(f"Full TF Delay Backtest {symbols_list[0]} to {symbols_list[-1]}.csv") return df