From 998a887736e987a3203a007a30fa843fb3f93381 Mon Sep 17 00:00:00 2001 From: gcarq Date: Thu, 28 Sep 2017 23:47:51 +0200 Subject: [PATCH] add command line script --- bin/freqtrade | 4 ++++ freqtrade/__init__.py | 2 ++ freqtrade/main.py | 13 +++++++++++-- setup.py | 1 + 4 files changed, 18 insertions(+), 2 deletions(-) create mode 100644 bin/freqtrade diff --git a/bin/freqtrade b/bin/freqtrade new file mode 100644 index 000000000..fc085a11d --- /dev/null +++ b/bin/freqtrade @@ -0,0 +1,4 @@ +#!/usr/bin/env python + +import freqtrade +freqtrade.main() \ No newline at end of file diff --git a/freqtrade/__init__.py b/freqtrade/__init__.py index 9d1bb721b..c905819a2 100644 --- a/freqtrade/__init__.py +++ b/freqtrade/__init__.py @@ -1 +1,3 @@ __version__ = '0.10.0' + +from .main import main diff --git a/freqtrade/main.py b/freqtrade/main.py index 4c0fb1401..c2a26ea38 100755 --- a/freqtrade/main.py +++ b/freqtrade/main.py @@ -232,7 +232,7 @@ def init(config: dict, db_url: Optional[str] = None) -> None: def app(config: dict) -> None: """ - Main function which handles the application state + Main loop which handles the application state :param config: config as dict :return: None """ @@ -263,8 +263,17 @@ def app(config: dict) -> None: telegram.send_msg('*Status:* `Trader has stopped`') -if __name__ == '__main__': +def main(): + """ + Loads and validates the config and starts the main loop + :return: None + """ + global _CONF with open('config.json') as file: _CONF = json.load(file) validate(_CONF, CONF_SCHEMA) app(_CONF) + + +if __name__ == '__main__': + main() diff --git a/setup.py b/setup.py index 79aacb7f9..0d8675d96 100644 --- a/setup.py +++ b/setup.py @@ -11,4 +11,5 @@ setup(name='freqtrade', author_email='michael.egger@tsn.at', license='GPLv3', packages=['freqtrade'], + scripts=['bin/freqtrade'], zip_safe=False)