def _init_traders_config(self, options): """ Get the profile configuration for a specific trader name. """ profile_name = options.get('profile', 'default') profile_config = utils.profiles(options.get('config-path')) or {} traders_profile = profile_config.get(profile_name, { 'traders': {} }).get('traders', {}) traders_config = utils.traders(options.get('config-path')) or {} # override from profile for k, trader_config in traders_config.items(): if k in traders_profile: override = traders_profile[k] if 'symbols' in override: trader_config['symbols'] = override['symbols'] if 'paper-mode' in override: trader_config['paper-mode'] = override['paper-mode'] return traders_config
def __init__(self, options): super().__init__("watcher", options) self._watchers = {} self._identity = options.get('identity', 'demo') self._backtesting = options.get('backtesting', False) # fetchers config self._fetchers_config = utils.fetchers(options.get('config-path')) or {} # watchers config self._watchers_config = utils.watchers(options.get('config-path')) or {} # user identities self._identities_config = utils.identities(options.get('config-path')) or {} self._profile = options.get('profile', 'default') self._profile_config = utils.profiles(options.get('config-path')) or {} # backtesting options self._backtesting = options.get('backtesting', False) self._start_timestamp = options['from'].timestamp() if options.get('from') else 0 self._end_timestamp = options['to'].timestamp() if options.get('to') else 0 # read-only, means to do not write to the market DB self._read_only = options.get('read-only', False)
def __init__(self, watcher_service, monitor_service, options): super().__init__("trader", options) self._traders = {} self._keys_map_to_trader = {} self._next_trader_key = 1 self._next_trader_uid = 1 self._keys_map_to_order = {} self._next_key = 1 self._next_order_uid = 1 self._policy = TraderService.POLICY_COPY_EVERYWHERE self._watcher_service = watcher_service self._monitor_service = monitor_service self._identity = options.get('identity', 'demo') self._report_path = options.get('reports-path', './') self._watcher_only = options.get('watcher-only', False) # user identities self._identities_config = utils.identities( options.get('config-path')) or {} self._profile = options.get('profile', 'default') self._profile_config = utils.profiles(options.get('config-path')) or {} # traders config self._traders_config = self._init_traders_config(options) # backtesting options self._backtesting = options.get('backtesting', False) self._start_timestamp = options['from'].timestamp() if options.get( 'from') else 0 self._end_timestamp = options['to'].timestamp() if options.get( 'to') else 0 # enable/disable execution of order/position (play/pause) self._activity = True # paper mode options self._paper_mode = options.get('paper-mode', False)
def __init__(self, watcher_service, trader_service, monitor_service, options): super().__init__("strategy", options) self._strategies = {} self._indicators = {} self._appliances = {} self._tradeops = {} self._regions = {} self._watcher_service = watcher_service self._trader_service = trader_service self._monitor_service = monitor_service self._identity = options.get('identity', 'demo') self._report_path = options.get('reports-path', './') self._watcher_only = options.get('watcher-only', False) self._profile = options.get('profile', 'default') self._indicators_config = config.INDICATORS or {} self._tradeops_config = config.TRADEOPS or {} self._regions_config = config.REGIONS or {} self._strategies_config = config.STRATEGIES or {} self._appliances_config = utils.appliances( options.get('config-path')) or {} self._profile_config = utils.profiles(options.get('config-path')) or {} # backtesting options self._backtesting = options.get('backtesting', False) self._from_date = options.get('from') # UTC tz self._to_date = options.get('to') # UTC tz self._timestep = options.get('timestep', 60.0) self._timestamp = 0 # in backtesting current processed timestamp # cannot be more recent than now from common.utils import UTC today = datetime.now().astimezone(UTC()) if self._from_date and self._from_date > today: self._from_date = today if self._to_date and self._to_date > today: self._to_date = today self._backtest = False self._start_ts = self._from_date.timestamp() if self._from_date else 0 self._end_ts = self._to_date.timestamp() if self._to_date else 0 self._timestep_thread = None self._time_factor = 0.0 if self._backtesting: # can use the time factor in backtesting only self._time_factor = options.get('time-factor', 0.0) # paper mode options self._paper_mode = options.get('paper-mode', False) self._next_key = 1 # worker pool of jobs for running data analysis self._worker_pool = WorkerPool()