Metadata-Version: 2.4
Name: nepse-cli
Version: 3.1.24
Summary: Modern CLI tool for Meroshare IPO automation and NEPSE market data with interactive TUI
Home-page: https://github.com/menaceXnadin/nepse-cli
Author: MenaceXnadin
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: End Users/Desktop
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.7
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.7
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: playwright>=1.40.0
Requires-Dist: prompt_toolkit>=3.0.48
Requires-Dist: rich>=13.0.0
Requires-Dist: colorama>=0.4.6
Requires-Dist: requests>=2.25.0
Requires-Dist: beautifulsoup4>=4.9.0
Requires-Dist: cloudscraper>=1.2.0
Requires-Dist: tenacity>=9.0.0
Requires-Dist: lxml>=4.9.0
Requires-Dist: curl-cffi>=0.5.0
Dynamic: author
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-dist
Dynamic: requires-python
Dynamic: summary

# Nepse CLI - Meroshare IPO Automation & Market Data

[![PyPI version](https://badge.fury.io/py/nepse-cli.svg?cacheSeconds=1)](https://badge.fury.io/py/nepse-cli)
[![Python Version](https://img.shields.io/pypi/pyversions/nepse-cli.svg)](https://pypi.org/project/nepse-cli/)

![Nepse CLI](https://res.cloudinary.com/dzbc5mlm9/image/upload/v1768644603/nepse-cli-image_tcx7tx.png)

A professional command-line tool for NEPSE market analysis and automated Meroshare IPO applications.

**Key Features:**

- Comprehensive market data and technical analysis
- Automated IPO/FPO/Rights application (headless or GUI mode)
- Multi-member portfolio tracking and management
- Real-time stock information, signals, and announcements
- Interactive shell with command palette and autocompletion
- Fast API-based IPO application with concurrent processing

## Requirements

- Python 3.8 or higher
- Windows, Linux, or macOS
- Internet connection
- Playwright (auto-installed)
- Meroshare account for IPO features

## Installation

### PyPI (Recommended)

**Important:** Avoid Microsoft Store Python. Use [python.org](https://www.python.org/downloads/) for proper PATH configuration.

```bash
pip install nepse-cli
```

**Update:**

```bash
pip install --upgrade nepse-cli
```

**Run:**

```bash
nepse
```

If command not found, use: `python -m nepse_cli` or see [Troubleshooting](#troubleshooting).

---

### From Source

**Development Installation:**

```bash
cd "Nepse CLI"
pip install -e .
```

**Windows Quick Start:**
Double-click `start_nepse.bat` to auto-configure and launch.

**Browser Setup:**
Playwright browsers install automatically on first run. Manual installation:

```bash
playwright install chromium
```

## Usage

### Interactive Shell (Recommended)

```bash
nepse
```

Shell features include command palette (`/`), autocompletion, command history, and inline help.

### Command Categories

#### IPO Automation

```bash
nepse apply              # ⚡ Fast API-based application (single member)
nepse apply-all          # ⚡ Fast API-based apply for all members
nepse result             # Check IPO application results

# Legacy browser-based commands (deprecated)
nepse apply-legacy       # Browser-based application (will be removed)
nepse apply-all-legacy   # Browser-based apply all (will be removed)
```

#### Member Management

```bash
nepse add-member         # Add/update family member
nepse list-members       # View all members
nepse edit-member        # Edit member details
nepse delete-member      # Remove a member
nepse manage-members     # Interactive member management
```

#### Portfolio & Authentication

```bash
nepse get-portfolio      # View member portfolio
nepse test-login         # Test Meroshare login
nepse dplist             # List available depository participants
```

#### Market Data & Indices

```bash
nepse ipo                # Open IPOs/FPOs/Rights
nepse nepse              # NEPSE indices
nepse subidx BANKING     # Sector sub-indices
nepse mktsum             # Market summary
nepse topgl              # Top gainers/losers
nepse sectors            # All sector performance
```

#### Stock Analysis

```bash
nepse stonk NABIL        # Stock details and live price
nepse profile NABIL      # Company profile
nepse fundamental NABIL  # Fundamental analysis
nepse depth NABIL        # Market depth (order book)
nepse 52week             # 52-week high/low performers
nepse near52             # Stocks near 52-week marks
```

#### Trading Information

```bash
nepse floor              # Floor sheet (live trades)
nepse floor NABIL        # Filtered by symbol
nepse floor --buyer 58   # Filtered by buyer broker
nepse floor --seller 59  # Filtered by seller broker
nepse brokers            # List all NEPSE brokers (S.N., Broker No., Name)
nepse signals            # Trading signals (strong buy/sell)
nepse announce           # Latest market announcements
nepse holidays           # Upcoming market holidays
```

## Features

### IPO Automation Features

- Automated application for IPO, FPO, and Rights offerings
- Multi-member support for family-wide applications
- Browser-based (Playwright) and API-based (fast) modes
- Headless operation with optional GUI for debugging
- Automatic share quantity calculation and validation
- Result checking and status tracking

### Market Analysis

- Real-time indices (NEPSE, Sensitive, Float, Sector)
- Stock fundamentals, profiles, and technical indicators
- Market depth and order book analysis
- Trading signals and price alerts
- Floor sheet with live trade data
- 52-week performance tracking
- Broker rankings and analysis

### Portfolio Management

- Multi-member portfolio tracking
- Real-time P&L calculation with WACC
- Secure credential storage
- Interactive member management
- Login verification and session handling

### User Interface

- Modern TUI with Rich tables and panels
- Interactive shell with autocompletion
- Command palette for quick navigation
- Progress indicators for long operations
- Formatted output with color coding

## Configuration

Credential data is stored in: `C:\Users\%USERNAME%\Documents\merosharedata\`

**Files:**

- `family_members.json` - Member credentials
- `ipo_config.json` - Application settings
- `nepse_cli_history.txt` - Command history

**Member Data Structure:**

```json
{
  "members": [
    {
      "name": "identifier",
      "dp_value": "139",
      "username": "meroshare_username",
      "password": "meroshare_password",
      "transaction_pin": "1234",
      "applied_kitta": 10,
      "crn_number": "CRN_NUMBER"
    }
  ]
}
```

## Multi-Member Management

Manage credentials for multiple family members to streamline IPO applications.

### Setup

```bash
nepse add-member
```

Required information:

- Name identifier (e.g., "Dad", "Mom", "Self")
- DP number and account credentials
- Meroshare username and password
- Transaction PIN (4-digit)
- Default kitta amount
- CRN number

### Operations

```bash
nepse list-members           # View all members
nepse edit-member            # Modify member details
nepse delete-member          # Remove a member
nepse manage-members         # Interactive management menu
```

### Batch Operations

```bash
nepse apply-all              # Apply IPO for all members
nepse fast-apply-all         # Fast apply for all members
```

## Command Reference

### Most Used Commands

```bash
nepse apply                  # Apply for IPO
nepse fast-apply             # Fast API-based IPO apply
nepse result                 # Check IPO results
nepse stonk <SYMBOL>         # Stock information
nepse mktsum                 # Market overview
nepse ipo                    # Open offerings
nepse get-portfolio          # View portfolio
```

### Available Sector Indices

`BANKING`, `DEVBANK`, `FINANCE`, `HOTELS AND TOURISM`, `HYDROPOWER`, `INVESTMENT`, `LIFE INSURANCE`, `MANUFACTURING AND PROCESSING`, `MICROFINANCE`, `MUTUAL FUND`, `NONLIFE INSURANCE`, `OTHERS`, `TRADING`

### Command Flags

- `--gui`: Show browser window (for browser-based commands)
- `--verbose`: Show detailed output
- Type `help <command>` in shell for command-specific help

## Security

- Credentials stored locally in JSON format
- User-level file permissions (600 on Unix)
- Data stored in user's Documents directory
- Never commit credential files to version control
- Use environment variables for CI/CD if needed

## Troubleshooting

### Windows: 'nepse' Command Not Found

**Root Cause:** Windows searches for executables in directories listed in the PATH environment variable. When `pip install nepse-cli` completes successfully, it creates `nepse.exe` in a user Scripts folder that may not be in your PATH.

**Quickest Fix (60 seconds):**

Use the module syntax instead:
```bash
python -m nepse_cli
```

**Permanent Fix (Recommended):**

1. **Add user Scripts folder to PATH (version-safe):**

  **Why this happens:** pip can install `nepse.exe` in your user Scripts folder, which is not always in Windows PATH.

  **Steps:**
  1. Press `Win + R` → type `sysdm.cpl` → press **Enter**
  2. Click **Environment Variables** button (bottom right)
  3. Under **User variables**, click **Path** → **Edit**
  4. Find your actual user Scripts path dynamically:
    ```bash
    py -c "import site, os; print(os.path.join(site.USER_BASE, 'Scripts'))"
    ```
    If `py` is not available, use:
    ```bash
    python -c "import site, os; print(os.path.join(site.USER_BASE, 'Scripts'))"
    ```
  5. Copy the printed path (example only: `C:\Users\YourName\AppData\Roaming\Python\PythonXY\Scripts`)
  6. Add that path to **Path** and save all dialogs
  7. **Close and reopen Command Prompt/PowerShell**
  8. Run `nepse`

2. **Admin reinstall (alternative):**

  Open Command Prompt as Administrator and reinstall:
  ```bash
  pip uninstall nepse-cli
  pip install nepse-cli
  ```
  This places the executable in the system Python Scripts folder (usually already in PATH).

### Linux/Mac: Command Not Found

- Ensure `~/.local/bin` is in PATH
- Use `pip install --user nepse-cli`
- Restart terminal after installation

### Browser Installation

```bash
playwright install chromium
```

### Login Issues

```bash
nepse test-login         # Verify credentials
nepse list-members       # Check stored data
nepse edit-member        # Update credentials
```

### Common Errors

- **Timeout errors**: Check internet connection or use `--gui` to see what's happening
- **Element not found**: Update playwright browsers or report issue
- **API errors**: Service may be temporarily down, retry later

## Contributing

Contributions are welcome! Please feel free to submit issues, feature requests, or pull requests.

## License

This project is licensed under the MIT License. See [LICENSE](LICENSE) file for details.

## Disclaimer

This tool is for educational and personal use only. Users are responsible for complying with Meroshare's terms of service and applicable regulations. The developers are not liable for any misuse or issues arising from the use of this tool.
