Skip to main content

This Package implements K-line data processing based on the Chan Theory.

Project description

Chan Theory K-Line Processing Toolkit

License: GPL v3 Python Version

A K-line data processing toolkit based on Chan Theory, implementing key algorithms for financial technical analysis.

Key Features

  • Data Preprocessing: Validates input data integrity and initializes processing environment
  • K-line Merging: Automatically identifies and merges K-lines with inclusion relationships
  • Fractal Recognition:
    • Top fractals (highest middle K-line in three consecutive)
    • Bottom fractals (lowest middle K-line in three consecutive)
  • Pen Endpoint Identification: Determines valid pen endpoints based on fractal recognition
  • Data Annotation: Marks fractals and pen endpoints in original data

Installation

pip install Chan-Theory

Usage Example

import pandas as pd
from chan_theory import KLineProcessor

# Prepare K-line data (requires trade_date, high, low columns)
data = {
    'trade_date': pd.date_range(start='2023-01-01', periods=10),
    'high': [105, 108, 107, 110, 112, 115, 114, 116, 118, 120],
    'low': [100, 102, 103, 105, 108, 110, 112, 113, 115, 117]
}
df = pd.DataFrame(data)

# Initialize processor
processor = KLineProcessor(df)

# Process K-line data
processed_data = processor.process_kline()

# View results
print(processed_data[['trade_date', 'high', 'low', 'Fmark', 'Fval']])

Output Field Description

  • Fmark: Fractal marker
    • 0: Top fractal pen endpoint
    • 1: Bottom fractal pen endpoint
    • 2: Rise
    • 3: Fall
  • Fval: Fractal value (high for tops, low for bottoms)

Input Data Requirements

DataFrame must contain these columns:

  • trade_date: Trading date (datetime type)
  • high: Daily high price (float type)
  • low: Daily low price (float type)

Recommended columns:

  • open: Opening price
  • close: Closing price
  • volume: Trading volume

Processing Workflow

  1. Data Validation: Checks input data compliance

  2. K-line Merging: Processes inclusion relationships

  3. Fractal Identification: Marks top/bottom fractals

  4. Pen Confirmation: Determines valid pen endpoints

  5. Data Annotation: Marks results in original data

graph TD
    A[Raw K-line Data] --> B{Data Validation}
    B --> C[K-line Merging]
    C --> D[Fractal Identification]
    D --> E[Pen Endpoint Confirmation]
    E --> F[Annotated Dataset]

Dependencies

  • Python 3.7+

  • pandas >=1.5.0

  • numpy >=1.18

  • requests

License

Licensed under GNU General Public License v3.0

Project Repository

GitHub Repository

This README.md includes:

1. **Enhanced Processing Workflow Diagram** using Mermaid syntax:
   - Shows both success and error paths
   - Clearly illustrates each processing stage
   - Visualizes the complete data transformation journey

2. **Workflow Stages**:
   - Raw data input
   - Validation with error handling
   - K-line merging process
   - Fractal identification
   - Pen endpoint confirmation
   - Final data annotation
   - Output of annotated dataset

3. **Error Handling Path**:
   - Explicit error termination path when validation fails
   - Clear distinction between successful and failed processing paths

The Mermaid diagram provides an intuitive visual representation of the entire processing pipeline, making it easy for users to understand how their data will be transformed by the toolkit.```

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

chan_theory-0.1.1.tar.gz (6.7 kB view details)

Uploaded Source

Built Distribution

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

chan_theory-0.1.1-py3-none-any.whl (7.0 kB view details)

Uploaded Python 3

File details

Details for the file chan_theory-0.1.1.tar.gz.

File metadata

  • Download URL: chan_theory-0.1.1.tar.gz
  • Upload date:
  • Size: 6.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for chan_theory-0.1.1.tar.gz
Algorithm Hash digest
SHA256 298f3a8b0ac51453ee8bc94cb26d745ef9bf071765c6ffccaa5466560dd8f832
MD5 e8320db326ae9532f0ee53b3bcc1c808
BLAKE2b-256 c549a51abb14cebcb13d51259dffc2905fbcd788d5051461489b7b75b10c5f37

See more details on using hashes here.

File details

Details for the file chan_theory-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: chan_theory-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 7.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.9.21

File hashes

Hashes for chan_theory-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 7b6985f8aa69d21339e514049bf176314ad3b65a4d2bf7f1904d817ed1617a02
MD5 558e63b709368b508e1f509c147f7ef1
BLAKE2b-256 72a48309b3fb8d36f1bd412a1e345cc9b6d60c0765e3f21af3270ea691fea8a6

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