Skip to main content

SQL models for day trading

Project description

Day Trading Models

Unit Test

This repository contains a collection of SQLAlchemy models for day trading analysis and data management. These models are designed to be used in various projects related to stock market analysis, particularly focusing on the Chinese A-share market.

Features

  • Comprehensive set of models covering various aspects of day trading:
    • Opening dates
    • Fund flows
    • Limit up (涨停) and limit down (跌停) stocks
    • Large orders (龙虎榜)
    • Quotations
    • Strong stocks
    • Sub-new stocks
    • And more...
  • SQLAlchemy ORM for easy database integration
  • Designed for flexibility and reusability across different projects

Installation

You can install this package using pip:

pip install day_trading_models

Usage

Here's a basic example of how to use these models:

from sqlalchemy import create_engine
from sqlalchemy.orm import sessionmaker
from day_trading_models import OpeningDate, Dt, Zt, Lhb, Fund

# Create an engine and session
engine = create_engine('your_database_url')
Session = sessionmaker(bind=engine)
session = Session()

# Create tables
OpeningDate.__table__.create(engine, checkfirst=True)
Dt.__table__.create(engine, checkfirst=True)
Zt.__table__.create(engine, checkfirst=True)
Lhb.__table__.create(engine, checkfirst=True)
Fund.__table__.create(engine, checkfirst=True)

# Example: Add an opening date
new_date = OpeningDate(date='2023-05-01')
session.add(new_date)

# Example: Query Zt (limit up) stocks
zt_stocks = session.query(Zt).filter(Zt.date == '2023-05-01').all()

# Example: Add a new fund flow record
new_fund = Fund(
    date='2023-05-01',
    sse_close_price=3000.0,
    sse_change=0.02,
    # ... other fields ...
)
session.add(new_fund)

session.commit()

Models

  • OpeningDate: Trading calendar dates
  • Dt: Stocks hitting lower price limits
  • Fund: Fund flow information
  • Lhb: Large order ("龙虎榜") data
  • LhbHyyyb: Active brokerage branches in large orders
  • LhbPlayer: Individual players in large orders
  • Quotation: Stock quotations
  • Strong: Strong performing stocks
  • Subnew: Newly listed stocks
  • Zb: Stocks that hit the upper price limit but failed to maintain it until market close (炸板股)
  • Zt: Stocks hitting upper price limits

Development

To set up the development environment:

  1. Clone the repository
  2. Install development dependencies:
    pip install -r requirements-dev.txt
    
  3. Run tests:
    pytest
    

Contributing

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

License

This project is licensed under the MIT License.

Project details


Download files

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

Source Distribution

day_trading_models-0.1.0.tar.gz (7.5 kB view details)

Uploaded Source

Built Distribution

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

day_trading_models-0.1.0-py3-none-any.whl (11.2 kB view details)

Uploaded Python 3

File details

Details for the file day_trading_models-0.1.0.tar.gz.

File metadata

  • Download URL: day_trading_models-0.1.0.tar.gz
  • Upload date:
  • Size: 7.5 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.12.7

File hashes

Hashes for day_trading_models-0.1.0.tar.gz
Algorithm Hash digest
SHA256 dff467c82d0249e146c66725a395766e887b06af4452f00167f12366e01c4d59
MD5 adb8a9293225d9f1185849cf24e719de
BLAKE2b-256 aa44b45281b5462eafc15efa9dfe1d05b5896d9e4244f20f0a70036cc5bb2ff0

See more details on using hashes here.

File details

Details for the file day_trading_models-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for day_trading_models-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 36d084f99aa24ca20ba8477a1eb373e642aec409be316a61fc4f98deb74ce28e
MD5 a3dc226c026c82e178f1b30cffc3477a
BLAKE2b-256 4176fe09f3530127f40fe3df0da2615694ac39be97d81399499cca43f4b31c2d

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