Files
hyper/scripts/check_wtioil.py
DiTus 1a95fe1caa 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
2026-08-05 09:50:36 +02:00

81 lines
3.2 KiB
Python

"""
Script to check if WTIOIL/CLUSD is available on Hyperliquid and add it to monitoring.
"""
import json
import logging
import requests
from hyperliquid.info import Info
from hyperliquid.utils import constants
from logging_utils import setup_logging
def check_and_add_wtioil():
"""Check if WTIOIL is available on Hyperliquid and add it to the precision file."""
setup_logging('normal', 'WTIOILChecker')
coin_name = "xyz:CLUSD" # Full HIP-3 format
alternative_names = ["WTIOIL", "CLUSD", "WTI"]
logging.info(f"Checking if {coin_name} is available on Hyperliquid...")
# Try direct HTTP API call for all mids
try:
url = 'https://api.hyperliquid.xyz/info'
payload = {"type": "allMids"}
response = requests.post(url, json=payload, timeout=10)
if response.status_code == 200:
result = response.json()
all_mids = result.get('mids', {})
print(f"\nTotal coins available: {len(all_mids)}")
# Look for oil-related coins
found = False
for name in all_mids.keys():
if 'oil' in name.lower() or 'wti' in name.lower() or 'cl' in name.lower() or 'xyz' in name.lower():
print(f"Found: {name} - Price: {all_mids[name]}")
found = True
if not found:
print("No oil-related coins found in all_mids.")
print("\nTrying alternative coin names...")
for alt_name in alternative_names:
try:
l2_payload = [{"type": "l2Book", "coin": alt_name}]
l2_response = requests.post(url, json=l2_payload, timeout=10)
if l2_response.status_code == 200:
l2_data = l2_response.json()
print(f"[OK] {alt_name} is available on Hyperliquid!")
print(f" L2 data: {l2_data}")
else:
print(f"[FAIL] {alt_name} not available (HTTP {l2_response.status_code})")
except Exception as e:
print(f"[ERROR] {alt_name}: {e}")
else:
print(f"Failed to get allMids: HTTP {response.status_code}")
print(f"Response: {response.text[:200]}")
except Exception as e:
logging.error(f"Error checking availability: {e}")
return
# Try to add to coin_precision.json
precision_file = "_data/coin_precision.json"
try:
with open(precision_file, 'r') as f:
precision_data = json.load(f)
# Add WTIOIL if not present
if coin_name not in precision_data:
precision_data[coin_name] = 2 # Default precision for commodities
with open(precision_file, 'w') as f:
json.dump(precision_data, f, indent=4, sort_keys=True)
logging.info(f"Added {coin_name} to {precision_file} with precision 2")
else:
logging.info(f"{coin_name} already exists in {precision_file}")
except Exception as e:
logging.error(f"Error updating precision file: {e}")
if __name__ == "__main__":
check_and_add_wtioil()