Skip to main content

No project description provided

Project description

twse

A Python package for querying real-time stock information from Taiwan Stock Exchange (TWSE).

Features

  • Real-time stock data querying from TWSE
  • Support for single or multiple stock symbols
  • Comprehensive stock information including:
    • Current price, volume, and price changes
    • Open, high, low prices
    • Best bid/ask prices
    • Company information
  • Formatted output suitable for display (including Telegram MarkdownV2 format)

Installation

Requires Python 3.11 or higher.

pip install twse

Usage

Basic Usage

from twse.stock_info import query_stock_info

# Query single stock (TSMC - 2330)
response = query_stock_info("2330")
print(response.pretty_repr())

# Query multiple stocks (TSMC - 2330 and Hon Hai - 2317)
response = query_stock_info(["2330", "2317"])
print(response.pretty_repr())

Example Output

The pretty_repr() method formats the output in Telegram MarkdownV2 format:

⏰ 2024-03-21 14:30:00

📊 台積電 (2330)
Open: 735.00
High: 738.00
Low: 732.00
Last: 735.00
Change: 🔺 +0.68%
Volume: 15,234,567

Stock Information Fields

The StockInfo class provides access to various fields:

  • symbol: Stock symbol
  • name: Stock name
  • full_name: Full company name
  • last_price: Current trading price
  • open_price: Opening price
  • high_price: High price
  • low_price: Low price
  • accumulated_volume: Trading volume
  • best_ask_price: Best ask price
  • best_bid_price: Best bid price
  • And more...

Development

Setup

  1. Clone the repository
  2. Install dependencies using uv:
    uv pip install -r requirements.txt
    

Commands

  • Run tests:
    make test
    
  • Run linter:
    make lint
    

Pre-commit Hooks

The project uses pre-commit hooks for code quality. Install them with:

pre-commit install

License

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

Project details


Download files

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

Source Distributions

No source distribution files available for this release.See tutorial on generating distribution archives.

Built Distribution

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

twse-0.2.0-py3-none-any.whl (5.4 kB view details)

Uploaded Python 3

File details

Details for the file twse-0.2.0-py3-none-any.whl.

File metadata

  • Download URL: twse-0.2.0-py3-none-any.whl
  • Upload date:
  • Size: 5.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: uv/0.5.9

File hashes

Hashes for twse-0.2.0-py3-none-any.whl
Algorithm Hash digest
SHA256 cee9b12cebea168051ce7ff9c2de30af101913b791cb0a0974add896a32217b3
MD5 d7552793d3f8c8a8c558dce35edc0c43
BLAKE2b-256 f30bf232a9378da3f646335b4fd196c3f66ed7a84ef1516688ea0531a0ce4337

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