Skip to content

yashzanwar/OFSTrader

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

OFS Trader - Optimal Bid Price Algorithm

An intelligent algorithm that automatically calculates the optimal bid price for OFS (Offer for Sale) by analyzing live market data from BSE India. Get real-time recommendations via Telegram notifications.

🎯 Features

  • Live Market Analysis: Scrapes real-time OFS bidding data from BSE India
  • Intelligent Price Discovery: Finds the cut-off price where demand meets supply
  • Optimal Bid Calculation: Recommends the next available price above cut-off for guaranteed full allocation
  • Dual Scenario Analysis: Analyzes both base offering and green shoe option scenarios
  • Telegram Notifications: Get instant updates when market conditions change
  • Change Detection: Only notifies when subscription, bid price, quantity, or cost changes

📊 How It Works

Algorithm Logic

  1. Fetch Live Data: Scrapes current bid data from BSE website every second
  2. Calculate Subscription Ratio: Total Demand / Total Offered
    • < 1.0: Under-subscribed (everyone gets full allocation)
    • 1.0: Over-subscribed (price-based allocation)

  3. Find Cut-off Price: The price where cumulative demand crosses total shares offered
    • Bids above cut-off: 100% allocation
    • Bids at cut-off: Partial allocation
    • Bids below cut-off: No allocation
  4. Recommend Optimal Bid: Next available price from actual bid table above cut-off
  5. Monitor & Notify: Continuously monitors and sends Telegram updates on changes

Example

Total Shares Offered: 40,58,325
Total Current Demand: 80,00,000 shares
Subscription Ratio: 1.97x (over-subscribed)

Cut-off Price: ₹280.00
  - Demand above ₹280: 30,55,789 shares (gets full allocation)
  - Demand at ₹280: 14,02,530 shares (partial allocation)
  
Recommended Bid: ₹280.05 (next price in bid table)
  - Ensures full allocation
  - Minimizes premium paid

🚀 Installation

Prerequisites

  • Python 3.8+
  • curl command (pre-installed on macOS/Linux)

Setup

  1. Clone the repository:
git clone https://github.com/yourusername/ofsTrader.git
cd ofsTrader
  1. Create virtual environment:
python3 -m venv venv
source venv/bin/activate  # On Windows: venv\Scripts\activate
  1. Install dependencies:
pip install beautifulsoup4 requests
  1. Configure settings:
cp config.example.json config.json
  1. Edit config.json with your details:
{
  "telegram": {
    "bot_token": "YOUR_BOT_TOKEN",
    "chat_id": "YOUR_CHAT_ID"
  },
  "default_values": {
    "investment_amount": 1900000,
    "scrip_code": "500414",
    "base_shares_offered": 4058325
  }
}

Getting Telegram Bot Token & Chat ID

  1. Create Bot:

    • Message @BotFather on Telegram
    • Send /newbot and follow instructions
    • Copy the bot token
  2. Get Chat ID:

    • Start a chat with your bot
    • Send any message
    • Visit: https://api.telegram.org/bot<YOUR_BOT_TOKEN>/getUpdates
    • Find your chat.id in the response

💻 Usage

Basic Usage

source venv/bin/activate
python ofs_pricing_algorithm.py

The script will prompt you for:

  1. Investment amount (₹)
  2. BSE Scrip Code
  3. Base shares offered
  4. Telegram Chat ID

Interactive Example

============================================================
OFS PRICING ALGORITHM - SETUP
============================================================

1. Enter investment amount (₹) [1900000]: 2000000
2. Enter SCRIP CODE [500414]: 500414
3. Enter base shares offered [4058325]: 4058325
4. Enter Telegram Chat ID [718712561]: 

✓ Configuration:
  Investment: ₹20,00,000
  Scrip Code: 500414
  Base Shares: 40,58,325
  Green Shoe Shares: 81,16,650
  Telegram Chat ID: 718712561

🔄 Starting live monitoring | Updates when changes detected | Press Ctrl+C to stop

[14:12:45]
  Base (40.58L):  Subscription: 2.07x | Bid: ₹280.05 | Qty: 7,141 | Cost: ₹1,999,837
  Green (81.17L): Subscription: 1.03x | Bid: ₹275.05 | Qty: 7,272 | Cost: ₹1,999,964

📱 Telegram Notifications

Receive formatted updates like this:

📊 OFS Update [14:12:45]

Base (40.58L shares)
Subscription: 2.07x
Bid: ₹280.05
Qty: 7,141
Cost: ₹1,999,837

Green Shoe (81.17L shares)
Subscription: 1.03x
Bid: ₹275.05
Qty: 7,272
Cost: ₹1,999,964

📁 Project Structure

ofsTrader/
├── src/
│   └── data/
│       └── bse_ofs_scraper.py     # BSE website scraper
├── ofs_pricing_algorithm.py       # Main algorithm
├── config.json                     # Your configuration (gitignored)
├── config.example.json            # Configuration template
├── .gitignore                     # Git ignore rules
└── README.md                      # This file

🔧 Configuration

config.json Structure

{
  "telegram": {
    "bot_token": "YOUR_TELEGRAM_BOT_TOKEN",
    "chat_id": "YOUR_TELEGRAM_CHAT_ID"
  },
  "default_values": {
    "investment_amount": 1900000,
    "scrip_code": "500414",
    "base_shares_offered": 4058325
  }
}
  • telegram.bot_token: Your Telegram bot token from @BotFather
  • telegram.chat_id: Your Telegram chat ID (numeric)
  • default_values: Pre-filled values for quick setup (optional)

⚙️ How to Find OFS Details

  1. Visit BSE OFS Page
  2. Find your company's OFS
  3. Note the Scrip Code (e.g., 500414)
  4. Check Total Shares Offered in the announcement

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request.

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/AmazingFeature)
  3. Commit your changes (git commit -m 'Add some AmazingFeature')
  4. Push to the branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

⚠️ Disclaimer

This tool is for educational and informational purposes only. It does not constitute financial advice. Always do your own research and consult with a qualified financial advisor before making investment decisions.

📝 License

This project is licensed under the MIT License - see the LICENSE file for details.

🙏 Acknowledgments

  • BSE India for providing publicly accessible OFS data
  • BeautifulSoup4 for HTML parsing capabilities
  • Telegram Bot API for notification delivery

📧 Support

If you have any questions or run into issues, please open an issue on GitHub.


Made with ❤️ for smarter OFS bidding

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages