deribit
This commit is contained in:
@@ -17,17 +17,17 @@ import time
|
||||
logger = logging.getLogger(__name__)
|
||||
|
||||
class ConfigSynchronizer:
|
||||
"""Handles automatic synchronization of config parameters with MEXC API"""
|
||||
"""Handles automatic synchronization of config parameters with exchange APIs"""
|
||||
|
||||
def __init__(self, config_path: str = "config.yaml", mexc_interface=None):
|
||||
"""Initialize the config synchronizer
|
||||
|
||||
Args:
|
||||
config_path: Path to the main config file
|
||||
mexc_interface: MEXCInterface instance for API calls
|
||||
mexc_interface: Exchange interface instance for API calls (maintains compatibility)
|
||||
"""
|
||||
self.config_path = config_path
|
||||
self.mexc_interface = mexc_interface
|
||||
self.exchange_interface = mexc_interface # Generic exchange interface
|
||||
self.last_sync_time = None
|
||||
self.sync_interval = 3600 # Sync every hour by default
|
||||
self.backup_enabled = True
|
||||
@@ -130,15 +130,15 @@ class ConfigSynchronizer:
|
||||
logger.info(f"CONFIG SYNC: Skipping sync, last sync was recent")
|
||||
return sync_record
|
||||
|
||||
if not self.mexc_interface:
|
||||
if not self.exchange_interface:
|
||||
sync_record['status'] = 'error'
|
||||
sync_record['errors'].append('No MEXC interface available')
|
||||
logger.error("CONFIG SYNC: No MEXC interface available for fee sync")
|
||||
sync_record['errors'].append('No exchange interface available')
|
||||
logger.error("CONFIG SYNC: No exchange interface available for fee sync")
|
||||
return sync_record
|
||||
|
||||
# Get current fees from MEXC API
|
||||
logger.info("CONFIG SYNC: Fetching trading fees from MEXC API")
|
||||
api_fees = self.mexc_interface.get_trading_fees()
|
||||
logger.info("CONFIG SYNC: Fetching trading fees from exchange API")
|
||||
api_fees = self.exchange_interface.get_trading_fees()
|
||||
sync_record['api_response'] = api_fees
|
||||
|
||||
if api_fees.get('source') == 'fallback':
|
||||
@@ -205,7 +205,7 @@ class ConfigSynchronizer:
|
||||
|
||||
config['trading']['fee_sync_metadata'] = {
|
||||
'last_sync': datetime.now().isoformat(),
|
||||
'api_source': 'mexc',
|
||||
'api_source': 'exchange', # Changed from 'mexc' to 'exchange'
|
||||
'sync_enabled': True,
|
||||
'api_commission_rates': {
|
||||
'maker': api_fees.get('maker_commission', 0),
|
||||
@@ -288,7 +288,7 @@ class ConfigSynchronizer:
|
||||
'sync_interval_seconds': self.sync_interval,
|
||||
'latest_sync_result': latest_sync,
|
||||
'total_syncs': len(self.sync_history),
|
||||
'mexc_interface_available': self.mexc_interface is not None
|
||||
'mexc_interface_available': self.exchange_interface is not None # Changed from mexc_interface to exchange_interface
|
||||
}
|
||||
|
||||
except Exception as e:
|
||||
|
||||
Reference in New Issue
Block a user