Clean up unused files, organize structure, update docs
- Delete obsolete files: data_fetcher_old.py, market_old.py, base_strategy.py (root), strategy_sma_cross.py, and old architecture remnants (address_monitor.py, position_monitor.py, trade_log.py, wallet_data.py, whale_tracker.py) - Delete zero-byte Docker artifacts and runtime files (clp_hedger.log, clp_hedger/hedge_status.json) - Move one-off utility scripts to scripts/ directory - Move example/template files to .temp/ directory - Update .gitignore: add entries for clp_hedger.log, clp_hedger/hedge_status.json, Docker layer hash files, Using, Running, and backups/ - Update .dockerignore: add clp_hedger.log, clp_hedger/hedge_status.json, backups/ - Create example config files: _data/strategies.json.example, _data/backtesting_conf.json.example, _data/coin_precision.json.example - Update GEMINI.md: remove outdated session summaries and duplicate review section - Update review.md: add cleanup status section, update remaining recommendations - Update MIGRATION_PLAN.md: mark completed phases, update file references - Update DOCKER_MIGRATION_GUIDE.md: update import_csv.py path reference
This commit is contained in:
61
scripts/list_coins.py
Normal file
61
scripts/list_coins.py
Normal file
@ -0,0 +1,61 @@
|
||||
import json
|
||||
import logging
|
||||
from hyperliquid.info import Info
|
||||
from hyperliquid.utils import constants
|
||||
|
||||
# Import the setup function from our new logging module
|
||||
from logging_utils import setup_logging
|
||||
|
||||
def save_coin_precision_data():
|
||||
"""
|
||||
Connects to the Hyperliquid API, gets a list of all listed coins
|
||||
and their trade size precision, and saves it to a JSON file.
|
||||
"""
|
||||
logging.info("Fetching asset information from Hyperliquid...")
|
||||
|
||||
try:
|
||||
info = Info(constants.MAINNET_API_URL, skip_ws=True)
|
||||
meta_data = info.meta_and_asset_ctxs()[0]
|
||||
all_assets = meta_data.get("universe", [])
|
||||
|
||||
if not all_assets:
|
||||
logging.error("Could not retrieve asset information from the meta object.")
|
||||
return
|
||||
|
||||
# Create a dictionary mapping the coin name to its precision
|
||||
coin_precision_map = {}
|
||||
for asset in all_assets:
|
||||
name = asset.get("name")
|
||||
precision = asset.get("szDecimals")
|
||||
|
||||
if name is not None and precision is not None:
|
||||
coin_precision_map[name] = precision
|
||||
|
||||
# Save the dictionary to a JSON file
|
||||
file_name = "_data/coin_precision.json"
|
||||
with open(file_name, 'w', encoding='utf-8') as f:
|
||||
# indent=4 makes the file readable; sort_keys keeps it organized
|
||||
json.dump(coin_precision_map, f, indent=4, sort_keys=True)
|
||||
|
||||
logging.info(f"Successfully saved coin precision data to '{file_name}'")
|
||||
|
||||
# Provide an example of how to use the generated file
|
||||
# print("\n--- Example Usage in another script ---")
|
||||
# print("import json")
|
||||
# print("\n# Load the data from the file")
|
||||
# print("with open('coin_precision.json', 'r') as f:")
|
||||
# print(" precision_data = json.load(f)")
|
||||
# print("\n# Access the precision for a specific coin")
|
||||
# print("eth_precision = precision_data.get('ETH')")
|
||||
# print("print(f'The size precision for ETH is: {eth_precision}')")
|
||||
|
||||
|
||||
except Exception as e:
|
||||
logging.error(f"An error occurred: {e}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
# Setup logging with a specified level and process name
|
||||
setup_logging('off', 'CoinLister')
|
||||
save_coin_precision_data()
|
||||
|
||||
Reference in New Issue
Block a user