mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-19 11:22:06 +08:00
fix for click.echo
added sys.stdout to click.echo to prevent errors on jupyter
This commit is contained in:
committed by
Victor Grau Serrat
parent
2ec9aa2ca9
commit
940f625ec1
+13
-11
@@ -3,6 +3,7 @@ import os
|
||||
from functools import wraps
|
||||
|
||||
import click
|
||||
import sys
|
||||
import logbook
|
||||
import pandas as pd
|
||||
from catalyst.marketplace.marketplace import Marketplace
|
||||
@@ -258,7 +259,7 @@ def run(ctx,
|
||||
if capital_base is None:
|
||||
ctx.fail("must specify a capital base with '--capital-base'")
|
||||
|
||||
click.echo('Running in backtesting mode.')
|
||||
click.echo('Running in backtesting mode.', sys.stdout)
|
||||
|
||||
perf = _run(
|
||||
initialize=None,
|
||||
@@ -290,7 +291,7 @@ def run(ctx,
|
||||
)
|
||||
|
||||
if output == '-':
|
||||
click.echo(str(perf))
|
||||
click.echo(str(perf), sys.stdout)
|
||||
elif output != os.devnull: # make the catalyst magic not write any data
|
||||
perf.to_pickle(output)
|
||||
|
||||
@@ -443,10 +444,10 @@ def live(ctx,
|
||||
ctx.fail("must specify a capital base with '--capital-base'")
|
||||
|
||||
if simulate_orders:
|
||||
click.echo('Running in paper trading mode.')
|
||||
click.echo('Running in paper trading mode.', sys.stdout)
|
||||
|
||||
else:
|
||||
click.echo('Running in live trading mode.')
|
||||
click.echo('Running in live trading mode.', sys.stdout)
|
||||
|
||||
perf = _run(
|
||||
initialize=None,
|
||||
@@ -478,7 +479,7 @@ def live(ctx,
|
||||
)
|
||||
|
||||
if output == '-':
|
||||
click.echo(str(perf))
|
||||
click.echo(str(perf), sys.stdout)
|
||||
elif output != os.devnull: # make the catalyst magic not write any data
|
||||
perf.to_pickle(output)
|
||||
|
||||
@@ -560,7 +561,7 @@ def ingest_exchange(ctx, exchange_name, data_frequency, start, end,
|
||||
|
||||
exchange_bundle = ExchangeBundle(exchange_name)
|
||||
|
||||
click.echo('Ingesting exchange bundle {}...'.format(exchange_name))
|
||||
click.echo('Ingesting exchange bundle {}...'.format(exchange_name), sys.stdout)
|
||||
exchange_bundle.ingest(
|
||||
data_frequency=data_frequency,
|
||||
include_symbols=include_symbols,
|
||||
@@ -583,10 +584,11 @@ def ingest_exchange(ctx, exchange_name, data_frequency, start, end,
|
||||
@click.pass_context
|
||||
def clean_algo(ctx, algo_namespace):
|
||||
click.echo(
|
||||
'Cleaning algo state: {}'.format(algo_namespace)
|
||||
'Cleaning algo state: {}'.format(algo_namespace),
|
||||
sys.stdout
|
||||
)
|
||||
delete_algo_folder(algo_namespace)
|
||||
click.echo('Done')
|
||||
click.echo('Done', sys.stdout)
|
||||
|
||||
|
||||
@main.command(name='clean-exchange')
|
||||
@@ -613,11 +615,11 @@ def clean_exchange(ctx, exchange_name, data_frequency):
|
||||
|
||||
exchange_bundle = ExchangeBundle(exchange_name)
|
||||
|
||||
click.echo('Cleaning exchange bundle {}...'.format(exchange_name))
|
||||
click.echo('Cleaning exchange bundle {}...'.format(exchange_name), sys.stdout)
|
||||
exchange_bundle.clean(
|
||||
data_frequency=data_frequency,
|
||||
)
|
||||
click.echo('Done')
|
||||
click.echo('Done', sys.stdout)
|
||||
|
||||
|
||||
@main.command()
|
||||
@@ -738,7 +740,7 @@ def bundles():
|
||||
# because there were no entries, print a single message indicating that
|
||||
# no ingestions have yet been made.
|
||||
for timestamp in ingestions or ["<no ingestions>"]:
|
||||
click.echo("%s %s" % (bundle, timestamp))
|
||||
click.echo("%s %s" % (bundle, timestamp), sys.stdout)
|
||||
|
||||
|
||||
@main.group()
|
||||
|
||||
Reference in New Issue
Block a user