Skip to content

AI-driven expert advisor that analyzes Pakistan Stock Exchange (PSX) data and generates trading signals with explainable logic.

Notifications You must be signed in to change notification settings

ajawad06/PSX-ExpertAdvisor

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🤖 PSX-ExpertAdvisor: An Intelligent Trading System

Python Version Framework Market

PSX ExpertAdvisor is a rule-based AI expert system that provides transparent, logic-driven trading signals for the Pakistan Stock Exchange. It encodes financial heuristics to transform market data into actionable Buy, Sell, and Hold recommendations.

Course: Artificial Intelligence


🧠 AI Methodology

This project implements a Knowledge-Based System (KBS); a branch of Artificial Intelligence that mimics the decision-making ability of a human expert. The AI logic is divided into:

  1. Fact Base: Current market price, trading volume, and calculated technical indicators.
  2. Rule Base: A collection of "IF-THEN" statements derived from technical analysis strategies.
  3. Inference Engine: The core logic that matches current market "Facts" against the "Rules" to generate actionable insights.

🚀 Key Features

  • Real-time & historical PSX data via yfinance
  • Market scanner to identify trading opportunities
  • Technical stock analysis (MA crossovers, RSI, volume)
  • Rule-based Buy/Sell/Hold signal generation
  • Portfolio builder for risk-aware investment tracking
  • Interactive Dashboard
  • Explainable AI with transparent, rule-backed decisions

📊 How it works

  1. Input: User enters a PSX Ticker symbol (e.g., SYS, LUCK, ENGRO).
  2. Fetch: The system pulls the latest historical data for that specific ticker.
  3. Analyze: The Rule-Engine calculates technical heuristics (RSI, MAs, etc.).
  4. Decision: The Inference Engine checks which rules are met.
  5. Output: The dashboard displays the final signal (Buy/Sell/Hold) along with the reasoning.

🛠️ Tech Stack

Backend

  • Language: Python
  • Framework: Flask
  • Data Analysis: pandas, numpy
  • Market Data: yfinance (Yahoo Finance API)
  • Web Scraping & Feeds: feedparser, requests

Frontend

  • Core: Vanilla JavaScript (ES6+), HTML5, CSS3
  • Data Visualization: Chart.js with chartjs-chart-financial for candlestick charts
  • Networking: Axios for API communication

💻 Installation & Setup

Prerequisites

  • Python >= 3.10.
  • Git installed.

1. Clone the Repository

git clone https://github.com/ajawad06/PSX-IntelliTrade.git
cd PSX-IntelliTrade

2. Create a Virtual Environment

python -m venv venv
# Activate on Windows:
.\venv\Scripts\activate
# Activate on Mac/Linux:
source venv/bin/activate

3. Install Dependencies

pip install -r requirements.txt

4. Run the Application

streamlit run app.py

About

AI-driven expert advisor that analyzes Pakistan Stock Exchange (PSX) data and generates trading signals with explainable logic.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published