```python # fetch_data.py import requests import json # Set the User-Agent as per SEC guidance headers = { 'User-Agent': 'MyApp/1.0 (https://myapp.example.com)' } # Fetch data from the SEC API response = requests.get("https://data.sec.gov/api/xbrl/companyconcept/CIK0000820027/dei/EntityCommonStockSharesOutstanding.json", headers=headers) data = response.json() # Extract entity name entity_name = data['entityName'] # Filter units for entries with fy > "2020" and numeric val filtered_units = [ unit for unit in data['units']['shares'] if unit['fy'] > "2020" and isinstance(unit['val'], (int, float)) ] # Determine max and min values max_entry = max(filtered_units, key=lambda x: x['val']) min_entry = min(filtered_units, key=lambda x: x['val']) # Prepare the output structure output_data = { "entityName": entity_name, "max": { "val": max_entry['val'], "fy": max_entry['fy'] }, "min": { "val": min_entry['val'], "fy": min_entry['fy'] } } # Save to data.json with open('data.json', 'w') as f: json.dump(output_data, f, indent=4) ``` ```html