Skip to main content

Rule-based event classification and impact scoring for Indian equity markets

Project description

AION Taxonomy

Rule-based event classification and impact scoring for Indian equity markets

AION Taxonomy provides deterministic event classification and sector-aware impact scoring for Indian financial news. It uses a comprehensive YAML taxonomy of market events, economic indicators, and policy changes to classify headlines and compute sentiment signals.

Features

  • Event Classification: Keyword-based matching against 100+ predefined market events
  • Macro Signal Computation: Compute market-wide sentiment signals from classified events
  • Sector-Specific Impacts: Sector-level signal computation with bias and multiplier support
  • Confidence Blending: Combine taxonomy match, model probability, and agreement scores
  • Optional Integration: Works standalone or integrates with aion-sentiment-in and aion-sectormap

Installation

# Install from source
cd aion_taxonomy
pip install -e .

# Install with optional dependencies
pip install -e ".[sectormap]"  # For ticker-to-sector mapping
pip install -e ".[sentiment]"  # For sentiment model integration
pip install -e ".[dev]"        # For development tools

Quick Start

from aion_taxonomy import TaxonomyPipeline

# Initialize pipeline with taxonomy file
pipeline = TaxonomyPipeline(taxonomy_path="taxonomy_india_v2.yaml")

# Process a headline
result = pipeline.process("RBI hikes repo rate by 25 bps")

print(f"Event: {result['event']['event_id']}")
print(f"Macro Signal: {result['macro_signal']:.3f}")
print(f"Confidence: {result['confidence']:.2%}")

With Sector Mapping

from aion_taxonomy import TaxonomyPipeline
from aion_sectormap import SectorMapper

# Initialize sector mapper
sector_mapper = SectorMapper()

# Initialize pipeline with sector mapper
pipeline = TaxonomyPipeline(
    taxonomy_path="taxonomy_india_v2.yaml",
    sector_mapper=sector_mapper
)

# Process headline with ticker
result = pipeline.process(
    headline="RBI hikes repo rate by 25 bps",
    ticker="HDFCBANK"
)

print(f"Active Sector: {result['active_sector_id']}")
print(f"Sector Signal: {result['active_sector_signal']:.3f}")

With Sentiment Model Agreement

from aion_taxonomy import TaxonomyPipeline
from aion_sentiment import SentimentAnalyzer

# Initialize components
pipeline = TaxonomyPipeline(taxonomy_path="taxonomy_india_v2.yaml")
sentiment_model = SentimentAnalyzer()

# Get model prediction
headline = "RBI hikes repo rate by 25 bps"
model_output = sentiment_model.predict([headline])[0]

# Process with model agreement
result = pipeline.process(
    headline=headline,
    model_output={
        'label': model_output['label'],
        'confidence': model_output['score']
    }
)

print(f"Taxonomy Signal: {result['macro_signal']:.3f}")
print(f"Model Label: {model_output['label']}")
print(f"Agreement Score: {result['confidence_components']['agreement_score']:.2f}")
print(f"Final Confidence: {result['confidence']:.2%}")

Package Structure

aion_taxonomy/
├── src/aion_taxonomy/
│   ├── __init__.py       # Package exports
│   ├── loader.py         # YAML loading and validation
│   ├── classifier.py     # Keyword-based event classification
│   ├── impact.py         # Macro and sector signal computation
│   ├── confidence.py     # Confidence blending
│   ├── pipeline.py       # Main entry point
│   └── utils.py          # Helper functions
├── tests/
├── data/
├── README.md
├── setup.py
├── pyproject.toml
└── requirements.txt

API Reference

TaxonomyPipeline

Main class for processing headlines.

pipeline = TaxonomyPipeline(taxonomy_path, sector_mapper=None)

Methods:

  • process(headline, ticker=None, date=None, model_output=None) → Process single headline
  • process_batch(headlines) → Process multiple headlines
  • get_event_details(event_id) → Get event by ID
  • list_events() → List all events in taxonomy

EventClassifier

Keyword-based event classification.

classifier = EventClassifier(taxonomy)
result = classifier.classify(headline)

Returns:

{
    'event_id': 'macro_rbi_repo_hike',
    'event_name': 'RBI Repo Rate Hike',
    'category_id': 'macro_economy',
    'subcategory_id': 'monetary_policy',
    'match_score': 0.85,
    'matched_keywords': ['repo rate hike', 'rbi hikes'],
    'base_impact': {'mild': -0.25, 'normal': -0.55, 'severe': -0.85},
    'default_impact': 'normal',
    'market_weight': 0.9,
    'sector_impacts': {...}
}

Signal Computation

from aion_taxonomy import get_macro_signal, get_sector_signal

# Compute macro signal
macro_signal, impact_level = get_macro_signal(event, headline)

# Compute sector signal
sector_result = get_sector_signal(macro_signal, event, 'Banks')

Confidence Computation

from aion_taxonomy import compute_confidence, compute_agreement_score

# Compute agreement between taxonomy and model
agreement = compute_agreement_score(
    taxonomy_signal=0.5,
    model_label='positive',
    model_confidence=0.85
)

# Compute overall confidence
confidence = compute_confidence(
    taxonomy_match=0.8,
    data_quality=0.9,
    model_probability=0.85,
    agreement_score=1.0
)

Taxonomy Format

The taxonomy is defined in YAML format with the following structure:

metadata:
  version: 2.0.0
  market: INDIA_EQUITY
  
config:
  impact_scale:
    POSITIVE: 1.0
    NEUTRAL: 0.0
    NEGATIVE: -1.0
  confidence_weights:
    model_probability: 0.4
    taxonomy_match: 0.3
    data_quality: 0.2
    agreement_score: 0.1

sectors:
- id: Financial Services
  beta_default: 1.1
- id: Banks
  beta_default: 1.15

categories:
- id: macro_economy
  subcategories:
  - id: monetary_policy
    events:
    - id: macro_rbi_repo_hike
      name: RBI Repo Rate Hike
      keywords:
      - repo rate hike
      - rbi hikes repo
      base_impact:
        mild: -0.25
        normal: -0.55
        severe: -0.85
      market_weight: 0.9
      sector_impacts:
        Banks:
          multiplier: 1.15
          bias: inverse
          rationale: Funding costs rise

License

Apache License 2.0

Contributing

See the main AION repository for contribution guidelines.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

aion_taxonomy-1.0.0.tar.gz (18.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

aion_taxonomy-1.0.0-py3-none-any.whl (19.5 kB view details)

Uploaded Python 3

File details

Details for the file aion_taxonomy-1.0.0.tar.gz.

File metadata

  • Download URL: aion_taxonomy-1.0.0.tar.gz
  • Upload date:
  • Size: 18.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for aion_taxonomy-1.0.0.tar.gz
Algorithm Hash digest
SHA256 0b4e9730c139f1127ed3bc8be358ea2a80e451d7fa43826fc575dbf4f87ca582
MD5 8b74a60b5d586949e7a0081bc93e52d4
BLAKE2b-256 9ceb9d0621c4acc62d9ecc6e4f6a8e2e1dbcb19f8661c2dd2667df5a391409e6

See more details on using hashes here.

File details

Details for the file aion_taxonomy-1.0.0-py3-none-any.whl.

File metadata

  • Download URL: aion_taxonomy-1.0.0-py3-none-any.whl
  • Upload date:
  • Size: 19.5 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for aion_taxonomy-1.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 29745e7b107ccebe8632e24f53ce2918ff7911dcffdec9ec249f2a9fe74aa97b
MD5 fea50789248b2a9daab509d9dadee69b
BLAKE2b-256 b1c92c6aaa91cd3b4e7f198ff049b18c86f0facc4dd9ca212bbffe64098208e2

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page