Slightly improve memory-usage of kraken-convert
This commit is contained in:
@@ -41,7 +41,7 @@ def import_kraken_trades_from_csv(config: Config, convert_to: str):
|
|||||||
|
|
||||||
if pairs_raw := config.get('pairs'):
|
if pairs_raw := config.get('pairs'):
|
||||||
pairs = expand_pairlist(pairs_raw, [m[0] for m in markets])
|
pairs = expand_pairlist(pairs_raw, [m[0] for m in markets])
|
||||||
markets = [m for m in markets if m[0] in pairs]
|
markets = {m for m in markets if m[0] in pairs}
|
||||||
if not markets:
|
if not markets:
|
||||||
logger.info(f"No data found for pairs {', '.join(pairs_raw)}.")
|
logger.info(f"No data found for pairs {', '.join(pairs_raw)}.")
|
||||||
return
|
return
|
||||||
@@ -61,17 +61,18 @@ def import_kraken_trades_from_csv(config: Config, convert_to: str):
|
|||||||
continue
|
continue
|
||||||
|
|
||||||
trades = pd.concat(dfs, ignore_index=True)
|
trades = pd.concat(dfs, ignore_index=True)
|
||||||
|
del dfs
|
||||||
|
|
||||||
trades.loc[:, 'timestamp'] = trades['timestamp'] * 1e3
|
trades.loc[:, 'timestamp'] = trades['timestamp'] * 1e3
|
||||||
trades.loc[:, 'cost'] = trades['price'] * trades['amount']
|
trades.loc[:, 'cost'] = trades['price'] * trades['amount']
|
||||||
for col in DEFAULT_TRADES_COLUMNS:
|
for col in DEFAULT_TRADES_COLUMNS:
|
||||||
if col not in trades.columns:
|
if col not in trades.columns:
|
||||||
trades[col] = ''
|
trades.loc[:, col] = ''
|
||||||
|
|
||||||
trades = trades[DEFAULT_TRADES_COLUMNS]
|
trades = trades[DEFAULT_TRADES_COLUMNS]
|
||||||
trades = trades_convert_types(trades)
|
trades = trades_convert_types(trades)
|
||||||
|
|
||||||
trades_df = trades_df_remove_duplicates(trades)
|
trades_df = trades_df_remove_duplicates(trades)
|
||||||
|
del trades
|
||||||
logger.info(f"{pair}: {len(trades_df)} trades, from "
|
logger.info(f"{pair}: {len(trades_df)} trades, from "
|
||||||
f"{trades_df['date'].min():{DATETIME_PRINT_FORMAT}} to "
|
f"{trades_df['date'].min():{DATETIME_PRINT_FORMAT}} to "
|
||||||
f"{trades_df['date'].max():{DATETIME_PRINT_FORMAT}}")
|
f"{trades_df['date'].max():{DATETIME_PRINT_FORMAT}}")
|
||||||
|
|||||||
Reference in New Issue
Block a user