def paper(debug: bool, dev: bool) -> None: """ trades in real-time on exchange with PAPER money """ validate_cwd() # set trading mode from jesse.config import config config['app']['trading_mode'] = 'papertrade' register_custom_exception_handler() # debug flag config['app']['debug_mode'] = debug from jesse_live import init from jesse.services.selectors import get_exchange live_config = locate('live-config.config') # validate that the "live-config.py" file exists if live_config is None: jh.error( 'You\'re either missing the live-config.py file or haven\'t logged in. Run "jesse login" to fix it.', True) jh.terminate_app() # inject live config init(config, live_config) # execute live session from jesse_live.live_mode import run run(dev)
def initiate_ws(exchange_name: str) -> None: exchange_class = jh.get_config( f'app.live_drivers.{exchange_name}') try: self.drivers[exchange_name] = exchange_class() except TypeError: from jesse_live.info import SUPPORTED_EXCHANGES exchange_names = '' for se in SUPPORTED_EXCHANGES: exchange_names += '\n' + '"' + se['name'] + '"' error_msg = f'Driver for "{exchange_name}" is not supported yet. Supported exchanges are: {exchange_names}' jh.error(error_msg, force_print=True) jh.terminate_app()
def initiate_ws(exchange_name: str) -> None: from jesse_live.info import SUPPORTED_EXCHANGES, SUPPORTED_EXCHANGES_NAMES exchange_class = jh.get_config( f'app.live_drivers.{exchange_name}') if exchange_name not in SUPPORTED_EXCHANGES_NAMES: exchange_names = '' for se in SUPPORTED_EXCHANGES: exchange_names += f'\n "{se["name"]}"' error_msg = f'Driver for "{exchange_name}" is not supported yet. Supported exchanges are: {exchange_names}' jh.error(error_msg, force_print=True) jh.terminate_app() self.drivers[exchange_name] = exchange_class()
# create and expose ENV_VALUES ENV_VALUES = dotenv_values('.env') if jh.is_unit_testing(): ENV_VALUES['POSTGRES_HOST'] = '127.0.0.1' ENV_VALUES['POSTGRES_NAME'] = 'jesse_db' ENV_VALUES['POSTGRES_PORT'] = '5432' ENV_VALUES['POSTGRES_USERNAME'] = '******' ENV_VALUES['POSTGRES_PASSWORD'] = '******' ENV_VALUES['REDIS_HOST'] = 'localhost' ENV_VALUES['REDIS_PORT'] = '6379' ENV_VALUES['REDIS_DB'] = 0 ENV_VALUES['REDIS_PASSWORD'] = '' # validation for existence of .env file if len(list(ENV_VALUES.keys())) == 0: jh.error( '.env file is missing from within your local project. ' 'This usually happens when you\'re in the wrong directory. ' '\n\nIf you haven\'t created a Jesse project yet, do that by running: \n' 'jesse make-project {name}\n' 'And then go into that project, and run the same command.', force_print=True) os._exit(1) jh.terminate_app() # raise FileNotFoundError('.env file is missing from within your local project. This usually happens when you\'re in the wrong directory. You can create one by running "cp .env.example .env"') if not jh.is_unit_testing() and ENV_VALUES['PASSWORD'] == '': raise EnvironmentError( 'You forgot to set the PASSWORD in your .env file')