def run():
    # Load arguments then parse settings
    args = parse_args()
    mymodule = {}
    DEFAULT_CONFIG_FILE = 'config.yml'
    DEFAULT_CREDS_FILE = 'creds.yml'

    config_file = args.config if args.config else DEFAULT_CONFIG_FILE
    creds_file = args.creds if args.creds else DEFAULT_CREDS_FILE
    parsed_config = load_config(config_file)
    parsed_creds = load_config(creds_file)

    TEST_MODE = parsed_config['script_options']['TEST_MODE']
    SIGNALLING_MODULES = parsed_config['trading_options']['SIGNALLING_MODULES']

    print(f'loaded config below\n{json.dumps(parsed_config, indent=4)}')
    print(f'Your credentials have been loaded from {creds_file}')

    if not TEST_MODE:
        if not args.notimeout:  # if notimeout skip this (fast for dev tests)
            print(
                'WARNING: You are using the Mainnet and live funds. Waiting 30 seconds as a security measure'
            )
            time.sleep(30)

    # load signalling modules
    for module in SIGNALLING_MODULES:
        mymodule[module] = importlib.import_module(module)
        t = threading.Thread(target=mymodule[module].do_work, args=())
        t.start()

    # seed initial prices
    binance_client = binance_service.BinanceClient(parsed_config, parsed_creds)
    binance_client.get_price()
    should_sell = False
    while True:
        if redis_service.binance_detect_mooning_job_status():
            orders, last_price, volume = binance_client.buy()
            binance_client.update_portfolio(orders, last_price, volume)
            coins_sold = binance_client.sell_coins()
            binance_client.remove_from_portfolio(coins_sold)
            should_sell = True
        elif should_sell:
            coins_sold = binance_client.panic_sell_coins()
            binance_client.remove_from_portfolio(coins_sold)
            should_sell = False
        else:
            print(
                'Daemon is stopped, use the start endpoint if you want to become rich'
            )
コード例 #2
0
from datetime import datetime

# Load helper modules
from helpers.parameters import (parse_args, load_config)

# Load creds modules
from helpers.handle_creds import (load_correct_creds)

args = parse_args()

DEFAULT_CONFIG_FILE = '../config.yml'
DEFAULT_CREDS_FILE = '../creds.yml'

config_file = args.config if args.config else DEFAULT_CONFIG_FILE
creds_file = args.creds if args.creds else DEFAULT_CREDS_FILE
parsed_creds = load_config(creds_file)
parsed_config = load_config(config_file)

LOG_TRADES = parsed_config['script_options'].get('LOG_TRADES')
LOG_FILE = parsed_config['script_options'].get('LOG_FILE')
LOG_FILE_PATH = '../' + LOG_FILE

access_key, secret_key = load_correct_creds(parsed_creds)

client = Client(access_key, secret_key)


def write_log(logline):
    timestamp = datetime.now().strftime("%d/%m %H:%M:%S")
    with open(LOG_FILE_PATH, 'a+') as f:
        f.write(timestamp + ' ' + logline + '\n')