예제 #1
0
def cli(args=None):
    if not args:
        args = sys.argv[1:]
    _prepare_logger()

    parser = argparse.ArgumentParser(description='OctoBot-CLI')
    parser.add_argument('-v',
                        '--version',
                        help='Show OctoBot-CLI current version.',
                        action='store_true')
    parser.add_argument('-u',
                        '--update',
                        help='Update OctoBot-CLI.',
                        action='store_true')
    parser.add_argument('-vv',
                        '--verbose',
                        help='Activate verbose mode.',
                        action='store_true')

    parser.set_defaults(func=manage_cli)

    # octobot management commands
    octobot_management_parser = parser.add_subparsers(
        title="OctoBot Management")

    # install
    install_parser = octobot_management_parser.add_parser(
        "install", help='Install Octobot')
    install_cli(install_parser)
    install_parser.set_defaults(func=install_octobot)

    # update
    update_parser = octobot_management_parser.add_parser(
        "update", help='Update the installed Octobot')
    update_cli(update_parser)
    update_parser.set_defaults(func=update_octobot)

    # start
    start_parser = octobot_management_parser.add_parser(
        "start",
        help='Start the installed OctoBot, any '
        'argument after this will be given to OctoBot')
    start_cli(start_parser)
    start_parser.set_defaults(func=start_octobot)

    # tentacles manager
    try:
        from octobot_tentacles_manager.api.loader import load_tentacles
        from octobot_tentacles_manager.cli import register_tentacles_manager_arguments
        from octobot.commands import call_tentacles_manager
        tentacles_parser = octobot_management_parser.add_parser(
            "tentacles",
            help='Calls OctoBot tentacles manager.\n'
            'Use "tentacles --help" to get the '
            'tentacles manager help.')
        register_tentacles_manager_arguments(tentacles_parser)
        tentacles_parser.set_defaults(func=call_tentacles_manager)
    except ImportError:
        pass

    to_process_args = copy(args)
    parsers_handling_special_args = ["start", "tentacles"]
    special_args = ["-h", "--help"]
    to_restore_args = []
    # remove special args from default parser to avoid parsing collisions
    if any(parser_handling_special_args in to_process_args
           for parser_handling_special_args in parsers_handling_special_args):
        for special_arg in special_args:
            if special_arg in to_process_args:
                to_process_args.remove(special_arg)
                to_restore_args.append(special_arg)
    args, octobot_args = parser.parse_known_args(to_process_args)
    # call the appropriate command entry point
    try:
        # call with restored special args if any
        args.func(args, octobot_args + to_restore_args)
    except TypeError:
        # used in tentacles_parser
        args.func(args)
예제 #2
0
파일: cli.py 프로젝트: aplodismenty/Crybot
def octobot_parser(parser):
    parser.add_argument('-v',
                        '--version',
                        help='Show OctoBot current version.',
                        action='store_true')
    parser.add_argument(
        '-s',
        '--simulate',
        help='Force OctoBot to start with the trader simulator only.',
        action='store_true')
    parser.add_argument('-u',
                        '--update',
                        help='Update OctoBot to latest version.',
                        action='store_true')
    parser.add_argument(
        '-rts',
        '--reset-trading-history',
        help='Force the traders to reset their history. They will '
        'now take the next portfolio as a reference for '
        'profitability and trading simulators will use a '
        'fresh new portfolio.',
        action='store_true')
    parser.add_argument(
        '-b',
        '--backtesting',
        help='Start OctoBot in backesting mode using the backtesting '
        'config stored in config.json.',
        action='store_true')
    parser.add_argument(
        '-bf',
        '--backtesting-files',
        type=str,
        nargs='+',
        help=
        'Backtesting files to use (should be provided with -b or --backtesting).',
        required=False)
    parser.add_argument(
        '-wdr',
        '--whole-data-range',
        help=
        'On multiple files backtesting: run on the whole available data instead of the '
        'common part only (default behavior).',
        action='store_true')
    parser.add_argument(
        '-ebt',
        '--enable-backtesting-timeout',
        help='When enabled, the watcher is limiting backtesting time to 30min.'
        'When disabled, the backtesting run will not be interrupted during execution',
        action='store_true')
    parser.add_argument(
        '-r',
        '--risk',
        type=float,
        help='Force a specific risk configuration (between 0 and 1).')
    parser.add_argument('-nw',
                        '--no_web',
                        help="Don't start OctoBot web interface.",
                        action='store_true')
    parser.add_argument(
        '-nt',
        '--no-telegram',
        help='Start OctoBot without telegram interface, even if telegram '
        'credentials are in config. With this parameter, your Octobot '
        'won`t reply to any telegram command but is still able to listen '
        'to telegram feed and send telegram notifications',
        action='store_true')
    parser.add_argument(
        '--encrypter',
        help=
        "Start the exchange api keys encrypter. This tool is useful to manually add"
        " exchanges configuration in your config.json without using any interface "
        "(ie the web interface that handle encryption automatically).",
        action='store_true')
    parser.add_argument('--identifier',
                        help="OctoBot community identifier.",
                        type=str,
                        nargs=1)
    parser.add_argument(
        '-o',
        '--strategy_optimizer',
        help='Start Octobot strategy optimizer. This mode will make '
        'octobot play backtesting scenarii located in '
        'abstract_strategy_test.py with different timeframes, '
        'evaluators and risk using the trading mode set in '
        'config.json. This tool is useful to quickly test a '
        'strategy and automatically find the best compatible '
        'settings. Param is the name of the strategy class to '
        'test. Example: -o TechnicalAnalysisStrategyEvaluator'
        ' Warning: this process may take a long time.',
        nargs='+')
    parser.set_defaults(func=start_octobot)

    # add sub commands
    subparsers = parser.add_subparsers(title="Other commands")

    # tentacles manager
    tentacles_parser = subparsers.add_parser(
        "tentacles",
        help='Calls OctoBot tentacles manager.\n'
        'Use "tentacles --help" to get the '
        'tentacles manager help.')
    tentacles_manager_cli.register_tentacles_manager_arguments(
        tentacles_parser)
    tentacles_parser.set_defaults(func=commands.call_tentacles_manager)