From 1278b6f5dbc255d99d00a47edaebcbbf39b3072a Mon Sep 17 00:00:00 2001 From: Mark Date: Tue, 20 Sep 2022 17:59:24 +0300 Subject: [PATCH] created get_shares_stats.py simple algorithm, opens files, checks which is larger for every figi, boom, produces statistical file to use to determine which figi is maximumu liquiditiy --- tools/get_shares_stats.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 tools/get_shares_stats.py diff --git a/tools/get_shares_stats.py b/tools/get_shares_stats.py new file mode 100644 index 0000000..b88e618 --- /dev/null +++ b/tools/get_shares_stats.py @@ -0,0 +1,23 @@ +import pathlib +import market_trade.constants + +if __name__ == '__main__': + shares_maxsize_by_figi = {} + + for figi_dir in market_trade.constants.SHARES_TRADES_PATH.iterdir(): + + # we check if the path is dir, because there are unwanted files present + if figi_dir.is_dir(): + + # compiling all the shares files to list + shares_filepaths = list(figi_dir.iterdir()) + + #TODO: REDO WITH LINES COUNTING + + # getting maximum file by file size + maxsize_shares_filepath = max(shares_filepaths, key=lambda path: path.stat().st_size) + + shares_maxsize_by_figi[figi_dir.name] = maxsize_shares_filepath.stat().st_size + shares_sorted_by_liquidity = sorted(shares_maxsize_by_figi.items(), + key=lambda dict_item: dict_item[1], + reverse=True)