mirror of
https://github.com/wassname/catalyst.git
synced 2026-07-29 11:18:20 +08:00
BLD: implemented issue #79, using the capital_base parameter to override the amount of base currency available for trading
This commit is contained in:
@@ -177,7 +177,7 @@ def ipython_only(option):
|
||||
default='-',
|
||||
metavar='FILENAME',
|
||||
show_default=True,
|
||||
help="The location to write the perf data. If this is '-' the perf"
|
||||
help="The location to write the perf data. If this is '-' the perf"
|
||||
" will be written to stdout.",
|
||||
)
|
||||
@click.option(
|
||||
@@ -549,9 +549,10 @@ def ingest_exchange(exchange_name, data_frequency, start, end,
|
||||
@click.pass_context
|
||||
def clean_algo(ctx, algo_namespace):
|
||||
click.echo(
|
||||
'Deleting the state folder of algo: {}...'.format(algo_namespace)
|
||||
'Cleaning algo state: {}'.format(algo_namespace)
|
||||
)
|
||||
delete_algo_folder(algo_namespace)
|
||||
click.echo('Done')
|
||||
|
||||
|
||||
@main.command(name='clean-exchange')
|
||||
|
||||
@@ -170,8 +170,8 @@ def _run(handle_data,
|
||||
# This corresponds to the json file containing api token info
|
||||
exchange_auth = get_exchange_auth(exchange_name)
|
||||
|
||||
if live and (
|
||||
exchange_auth['key'] == '' or exchange_auth['secret'] == ''):
|
||||
if live and (exchange_auth['key'] == '' \
|
||||
or exchange_auth['secret'] == ''):
|
||||
raise ExchangeAuthEmpty(
|
||||
exchange=exchange_name.title(),
|
||||
filename=os.path.join(
|
||||
@@ -263,17 +263,35 @@ def _run(handle_data,
|
||||
)
|
||||
|
||||
if base_currency in balances:
|
||||
return balances[base_currency]
|
||||
base_currency_available = balances[base_currency]
|
||||
log.info(
|
||||
'base currency available in the account: {} {}'.format(
|
||||
base_currency_available, base_currency
|
||||
)
|
||||
)
|
||||
|
||||
if capital_base is not None \
|
||||
and capital_base < base_currency_available:
|
||||
log.info(
|
||||
'using capital base limit: {} {}'.format(
|
||||
capital_base, base_currency
|
||||
)
|
||||
)
|
||||
amount = capital_base
|
||||
else:
|
||||
amount = base_currency_available
|
||||
|
||||
return amount
|
||||
else:
|
||||
raise BaseCurrencyNotFoundError(
|
||||
base_currency=base_currency,
|
||||
exchange=exchange_name
|
||||
)
|
||||
|
||||
capital_base = 0
|
||||
combined_capital_base = 0
|
||||
for exchange_name in exchanges:
|
||||
exchange = exchanges[exchange_name]
|
||||
capital_base += fetch_capital_base(exchange)
|
||||
combined_capital_base += fetch_capital_base(exchange)
|
||||
|
||||
sim_params = create_simulation_parameters(
|
||||
start=start,
|
||||
@@ -338,7 +356,7 @@ def _run(handle_data,
|
||||
raise ValueError(
|
||||
"invalid url %r, must begin with 'sqlite:///'" %
|
||||
str(bundle_data.asset_finder.engine.url),
|
||||
)
|
||||
)
|
||||
|
||||
env = TradingEnvironment(asset_db_path=connstr, environ=environ)
|
||||
first_trading_day = \
|
||||
|
||||
Reference in New Issue
Block a user