Dado este codigo:"""import requests
import pandas as pd
from xml.etree import ElementTree as ET
from datetime import datetime, timedelta
import os
import argparse

def get_month_code(month):
    month_codes = {
        1: 'F', 2: 'G', 3: 'H', 4: 'J', 5: 'K', 6: 'M',
        7: 'N', 8: 'Q', 9: 'U', 10: 'V', 11: 'X', 12: 'Z'
    }
    return month_codes[month]


def get_month_by_code(month_code):
    month_codes = {
        'F':1, 'G': 2, 'H':3, 'J':4, 'K':5, 'M': 6,
        'N':7, 'Q': 8, 'U':9, 'V':10, 'X':11, 'Z':12
    }
    month, year = month_codes[str(month_code)[-3]] , str(month_code)[-2:]
    return int(month), int(year)


def generate_symbols(partial_symbols, start_date, end_date):
    current_date = start_date
    symbols = []
    while current_date <= end_date:
        year = str(current_date.year)[-2:]
        month_code = get_month_code(current_date.month)
        symbols.append({
            product: f"{product}{month_code}{year}" for product in partial_symbols
        })
        current_date += timedelta(days=32)
        current_date = current_date.replace(day=1)
    return symbols

def fetch_data(symbol, limit):
    base_url = "https://pxweb.dtn.com/PXWebSvc/PXServiceWeb.svc/GetDailyHistory"
    params = {
        "UserID": "ws@istmoenergy.com",############
        "Password": "S5nqeZ",###########
        "Symbol": f"NYM:{symbol}",
        "Interval": "",
        "StartDate": "",#MM-DD-YYYY
        "EndDate": "",#MM-DD-YYYY
        "Limit": limit,
        "SymbolLimit": "",
        "PageToken": "",
        "Market": "",
        "Vendor": "",
        "Format": ""
    }
    
    response = requests.get(base_url, params=params)
    return response.text

def parse_xml_to_dataframe(xml_string):
    root = ET.fromstring(xml_string)
    history = root.find('History')
    
    data = []
    for day in history.findall('Day'):
        date = day.get('Date')
        open_price = day.get('Open')
        high = day.get('High')
        low = day.get('Low')
        close = day.get('Close')
        volume = day.get('Volume')
        oi = day.get('OI')
        
        data.append({
            'Date': date,
            'Open': open_price,
            'High': high,
            'Low': low,
            'Close': close,
            'Volume': volume,
            'OI': oi
        })
    
    df = pd.DataFrame(data)
    df['Date'] = pd.to_datetime(df['Date'])
    for col in ['Open', 'High', 'Low', 'Close']:
        df[col] = pd.to_numeric(df[col], errors='coerce')
    
    return df

def aggregate_data(df, frequency):
    if frequency == 'daily':
        return df
    elif frequency == 'weekly':
        return df.resample('W-MON', on='Date').agg({
            'Open': 'first',
            'High': 'max',
            'Low': 'min',
            'Close': 'last',
            'Volume': 'mean',
            'OI': 'last',
            'Symbol': 'first'
        }).reset_index()
    elif frequency == 'monthly':
        return df.resample('MS', on='Date').agg({
            'Open': 'first',
            'High': 'max',
            'Low': 'min',
            'Close': 'last',
            'Volume': 'mean',
            'OI': 'last',
            'Symbol': 'first'
        }).reset_index()

def get_futures_data(partial_symbols, start_date, end_date, frequency='daily', limit="1000"):
    symbols = generate_symbols(partial_symbols, start_date, end_date)
    dataframes = {product: [] for product in partial_symbols}
    
    for symbol_set in symbols:
        for product, symbol in symbol_set.items():
            xml_data = fetch_data(symbol, limit)
            df = parse_xml_to_dataframe(xml_data)
            df['Symbol'] = symbol
            df['delivery_month'], df['delivery_year'] = get_month_by_code(symbol)
            dataframes[product].append(df)
    
    # Concatenate DataFrames for each product
    for product in dataframes:
        dataframes[product] = pd.concat(dataframes[product], ignore_index=True)
        dataframes[product] = dataframes[product].sort_values('Date')
        dataframes[product] = aggregate_data(dataframes[product], frequency)
    
    return dataframes

def save_futures_data(futures_data, file_type, path):
    # Create the directory if it does not exist
    if not os.path.exists(path):
        os.makedirs(path)
    
    for product, df in futures_data.items():
        if file_type == 'csv':
            df.to_csv(f"{path}/{product}_futures_data.csv", index=False)
        elif file_type == 'json':
            df.to_json(f"{path}/{product}_futures_data.json", orient='records', date_format='iso')
        elif file_type == 'parquet':
            df.to_parquet(f"{path}/{product}_futures_data.parquet", index=False)
        else:
            print(f"Unsupported file type: {file_type}")

def main():
    # Setup argument parser
    parser = argparse.ArgumentParser(description='Fetch and save futures data.')
    parser.add_argument('--start_date', type=str, required=True, help='Start date in YYYY-MM-DD format.')
    parser.add_argument('--end_date', type=str, required=True, help='End date in YYYY-MM-DD format.')
    parser.add_argument('--partial_symbols', nargs='+',  default=['QLY', 'QHO', 'QCL'], help='List of partial symbols.')
    parser.add_argument('--file_type', type=str, default='parquet', help='Output file type (csv, parquet or json).')
    parser.add_argument('--path', type=str, default='./', help='Directory path to save the files.')
    parser.add_argument('--limit', type=str, default='180', help='Limit for data fetching (default: 1000).')

    # Parse arguments
    args = parser.parse_args()

    # Convert date strings to datetime objects
    start_date = datetime.strptime(args.start_date, '%Y-%m-%d')
    end_date = datetime.strptime(args.end_date, '%Y-%m-%d')

    # Fetch and save the data
    futures_data = get_futures_data(args.partial_symbols, start_date, end_date, frequency='daily', limit=args.limit)
    save_futures_data(futures_data, args.file_type, args.path)

if __name__ == '__main__':
    main()""" Debes ahcer las sigueintes modificaciones: 1. Debes empezar por identificar la fecha actual y al mes actual sumarle 6 para identificar el mes y año que sera el limite superioir de los symbols, el limite inferior sera por default el mismo mes de la fecha actual, si hoy es 09-20-2023 el limite superior va a ser marzo del 2024 = partial_symbol+G24 y el inferior sera partial_symbol+U23. para cada symbol el llamada a la api deja de usar el valor de limit y usa el valor de StartDate =del primer dia del de 6 meses atras del mes del delivery, es decir, para el symbol partial_symbol+U23 (septiembre del 2023) StartDate  debe ser 03-01-2023.