def backtest(start_date: str, finish_date: str, debug: bool, csv: bool, json: bool, fee: bool, chart: bool, tradingview: bool, full_reports: bool) -> None: """ backtest mode. Enter in "YYYY-MM-DD" "YYYY-MM-DD" """ validate_cwd() from jesse.config import config config['app']['trading_mode'] = 'backtest' register_custom_exception_handler() from jesse.services import db from jesse.modes import backtest_mode from jesse.services.selectors import get_exchange # debug flag config['app']['debug_mode'] = debug # fee flag if not fee: for e in config['app']['trading_exchanges']: config['env']['exchanges'][e]['fee'] = 0 get_exchange(e).fee = 0 backtest_mode.run(start_date, finish_date, chart=chart, tradingview=tradingview, csv=csv, json=json, full_reports=full_reports) db.close_connection()
def terminate_app(): """ """ # close the database from jesse.services.db import close_connection close_connection() # disconnect python from the OS os._exit(1)
def generate_signal(start_date, finish_date, reports_folder, debug, csv, json, fee, chart, tradingview): """ backtest mode. Enter in "YYYY-MM-DD" "YYYY-MM-DD" """ validate_cwd() from jesse.config import config config['app']['trading_mode'] = 'backtest' register_custom_exception_handler() from jesse.services import db from jesse.modes import backtest_mode from jesse.services.selectors import get_exchange # debug flag config['app']['debug_mode'] = debug # fee flag if not fee: for e in config['app']['trading_exchanges']: config['env']['exchanges'][e]['fee'] = 0 get_exchange(e).fee = 0 print(f"Generating report for {finish_date}") todays_signal_report = backtest_mode.generate_signal( start_date, finish_date, chart=chart, tradingview=tradingview, csv=csv, json=json) previous_report_file = Path( reports_folder) / f"{jh.get_previous_reports_file_name()}.json" print(f"Loading {previous_report_file} for comparison") previous_signal_report = jh.load_report( previous_report_file) if os.path.exists(previous_report_file) else None is_report_different = jh.are_reports_different(previous_signal_report, todays_signal_report) if is_report_different: print("Posting to slack") slack_report = jh.construct_slack_report(previous_signal_report, todays_signal_report) print(slack_report) jh.post_slack_notification(slack_report) current_report_file_name = Path( reports_folder) / f"{jh.get_current_report_file_name()}.json" print(f"Dumping to {current_report_file_name}") jh.dump_report(todays_signal_report, current_report_file_name) db.close_connection()
def import_candles(exchange, symbol, start_date): """ imports historical candles from exchange """ validate_cwd() from jesse.config import config config['app']['trading_mode'] = 'import-candles' register_custom_exception_handler() from jesse.services import db from jesse.modes import import_candles_mode import_candles_mode.run(exchange, symbol, start_date) db.close_connection()
from jesse.config import config from jesse.services import db from jesse.modes import import_candles_mode config['app']['trading_mode'] = 'import-candles' exchange = 'Binance' start_date = '2019-01-01' pairs = ['BTC-USDT', 'LTC-USDT', 'XMR-USDT', 'ETC-USDT'] for pair in pairs: import_candles_mode.run(exchange, pair, start_date, skip_confirmation=True) db.close_connection()