# Atabet-Data Sample Scripts

This folder contains sample scripts demonstrating how to use the Atabet-Data library for financial data retrieval.

## Prerequisites

1. **Install atabet-data with authentication support:**
   ```bash
   pip install atabet-data[auth]
   ```

2. **Install data source dependencies** (as needed for your use case):
   ```bash
   pip install atabet-data[bql]      # Bloomberg BQL (requires Bloomberg Terminal)
   pip install atabet-data[blpapi]  # Bloomberg BLP API
   pip install atabet-data[tushare] # Tushare
   pip install atabet-data[xtdata]  # XtQuant (XTP)
   ```

3. **Obtain an authentication token** from your administrator. Atabet-Data requires token authentication for all API calls.

## Using the Samples

**Important:** Never hardcode your authentication token in scripts. Use environment variables instead:

```bash
export ATABET_DATA_TOKEN="your_token_here"
python basic_usage.py
```

Or in your script:
```python
import os
token = os.environ.get("ATABET_DATA_TOKEN", "your_token_here")
client = AtabetData(token=token)
```

## Sample Scripts

- **basic_usage.py** - Minimal example: snapshot and historical data via BQL
- **get_historical_data_example.py** - Historical data with different data sources
- **localcsv_example.py** - Reading from local CSV files (no external data source required)
- **ta_example.py** - Technical analysis indicators via the `.ta` accessor (works with demo data, no token required)

## Finding Samples After Installation

When atabet-data is installed via pip, the samples are placed in the share directory. To locate them:

```python
import sys
import os
samples_path = os.path.join(sys.prefix, "share", "atabet-data", "samples")
if os.path.exists(samples_path):
    print(f"Samples location: {samples_path}")
```
