vschart-python


Namevschart-python JSON
Version 1.0.0 PyPI version JSON
download
home_pagehttps://github.com/yourusername/vschart
SummaryPython client for VSChart extension
upload_time2025-08-15 08:31:17
maintainerNone
docs_urlNone
authoryiwan2
requires_python>=3.7
licenseNone
keywords vscode chart trading finance visualization tradingview
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # VSChart Python Client

A Python client for the VSChart extension, providing a Pythonic interface to create interactive financial charts in VSCode. This client communicates with the VSChart extension via WebSocket to render and manipulate financial charts directly in your VSCode environment.

[![PyPI version](https://img.shields.io/pypi/v/vschart-python.svg)](https://pypi.org/project/vschart-python/)
[![Python versions](https://img.shields.io/pypi/pyversions/vschart-python.svg)](https://pypi.org/project/vschart-python/)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)

## Installation

### From PyPI

```bash
pip install vschart-python
```

### From Source

```bash
git clone https://github.com/yourusername/vschart.git
cd vschart/vschart-python
pip install -e .
```

## Features

- **Interactive Financial Charts**: Create and manipulate charts directly in VSCode
- **Multiple Chart Types**: Support for candlestick, line, and histogram series
- **Technical Analysis Tools**: Add trend lines, Fibonacci retracements, and more
- **Multi-pane Support**: Create charts with multiple panes for different indicators
- **Rich Logging**: Colored output using the Rich library
- **Type Hints**: Comprehensive type annotations for better IDE support
- **Constants Library**: Predefined constants for styles, types, and colors

## Prerequisites

- VSCode with the VSChart extension installed
- Python 3.7 or higher
- Required Python packages (automatically installed): websocket-client, numpy, pandas, rich

## Usage

### Basic Example

```python
from vschart import Chart, CandlestickSeries, VolumeSeries
import pandas as pd
import numpy as np

# Sample data generation (replace with your actual data)
def generate_sample_data(n=100):
    dates = pd.date_range(start="2023-01-01", periods=n)
    timestamps = [int(d.timestamp()) for d in dates]
    
    # Generate OHLC data
    close = 100 + np.cumsum(np.random.normal(0, 1, n))
    high = close + np.random.uniform(0, 3, n)
    low = close - np.random.uniform(0, 3, n)
    open_price = close.copy()
    np.random.shuffle(open_price)
    
    # Generate volume data
    volume = np.random.uniform(1000, 5000, n)
    
    # Create candlestick data
    candlestick_data = [
        {"time": t, "open": o, "high": h, "low": l, "close": c}
        for t, o, h, l, c in zip(timestamps, open_price, high, low, close)
    ]
    
    # Create volume data
    volume_data = [
        {"time": t, "value": v} for t, v in zip(timestamps, volume)
    ]
    
    return candlestick_data, volume_data

# Generate sample data
candlestick_data, volume_data = generate_sample_data()

# Create chart instance
chart = Chart(host="localhost", port=8080)

# Connect to the server
if chart.connect():
    # Add candlestick series
    candlestick_series = chart.add_candlestick_series()
    
    # Add volume series in a separate pane
    volume_series = chart.add_histogram_series(pane_index=1)
    
    # Set data
    candlestick_series.set_data(candlestick_data)
    volume_series.set_data(volume_data)
    
```

### Using Constants

The library provides constants for line styles, line types, price line styles, and colors to make your code more readable and maintainable:

```python
from vschart import Chart, LineSeries
from vschart import LineStyle, LineType, PriceLineStyle, Color

# Create chart instance
chart = Chart("ws://localhost:8080")

# Connect to the server
if chart.connect():
    # Add line series with constants
    line_series = chart.add_line_series(
        color=Color.BLUE,
        lineWidth=2,
        lineStyle=LineStyle.DASHED,
        lineType=LineType.SIMPLE,
        priceLineStyle=PriceLineStyle.DOTTED
    )
    
    # Set data
    line_series.set_data(line_data)
```

## Available Constants

### Line Styles

```python
LineStyle.SOLID         # 0: Solid line
LineStyle.DOTTED        # 1: Dotted line
LineStyle.DASHED        # 2: Dashed line
LineStyle.LARGE_DASHED  # 3: Large dashed line
LineStyle.SPARSE_DOTTED # 4: Sparse dotted line
```

### Line Types

```python
LineType.SIMPLE  # 0: Simple line
LineType.STEP    # 1: Step line
```

### Price Line Styles

```python
PriceLineStyle.SOLID         # 0: Solid line
PriceLineStyle.DOTTED        # 1: Dotted line
PriceLineStyle.DASHED        # 2: Dashed line
PriceLineStyle.LARGE_DASHED  # 3: Large dashed line
PriceLineStyle.SPARSE_DOTTED # 4: Sparse dotted line
```

### Colors

```python
# Basic colors
Color.BLACK    # '#000000'
Color.WHITE    # '#FFFFFF'
Color.RED      # '#FF0000'
Color.GREEN    # '#00FF00'
Color.BLUE     # '#0000FF'
Color.YELLOW   # '#FFFF00'
Color.CYAN     # '#00FFFF'
Color.MAGENTA  # '#FF00FF'

# Chart specific colors
Color.UP_COLOR     # '#26a69a' (Green for up candles)
Color.DOWN_COLOR   # '#ef5350' (Red for down candles)
Color.WICK_COLOR   # '#737375' (Default wick color)
Color.LINE_COLOR   # '#2196F3' (Default line color)
Color.VOLUME_COLOR # '#26a69a' (Default volume color)
Color.BORDER_COLOR # '#378658' (Default border color)
Color.FILL_COLOR   # 'rgba(33, 150, 243, 0.1)' (Default fill color with transparency)
```

## Examples

Check the `examples` directory for more examples:

- `basic_example.py`: Basic usage of the library
- `constants_example.py`: Example using the constants
- `rich_logging_demo.py`: Demo of the rich logging features

## Documentation

For more information, see the documentation in the `docs` directory.

## Requirements

- Python 3.7 or higher
- websocket-client>=1.6.0
- numpy>=1.21.0
- pandas>=1.3.0
- rich>=10.0.0

## License

MIT

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/yourusername/vschart",
    "name": "vschart-python",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.7",
    "maintainer_email": null,
    "keywords": "vscode, chart, trading, finance, visualization, tradingview",
    "author": "yiwan2",
    "author_email": "your.email@example.com",
    "download_url": "https://files.pythonhosted.org/packages/cc/a4/aea3a5299e06bb447f2bce03e5f595f1da6538856f56ccc7a318cdf11944/vschart_python-1.0.0.tar.gz",
    "platform": null,
    "description": "# VSChart Python Client\n\nA Python client for the VSChart extension, providing a Pythonic interface to create interactive financial charts in VSCode. This client communicates with the VSChart extension via WebSocket to render and manipulate financial charts directly in your VSCode environment.\n\n[![PyPI version](https://img.shields.io/pypi/v/vschart-python.svg)](https://pypi.org/project/vschart-python/)\n[![Python versions](https://img.shields.io/pypi/pyversions/vschart-python.svg)](https://pypi.org/project/vschart-python/)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n\n## Installation\n\n### From PyPI\n\n```bash\npip install vschart-python\n```\n\n### From Source\n\n```bash\ngit clone https://github.com/yourusername/vschart.git\ncd vschart/vschart-python\npip install -e .\n```\n\n## Features\n\n- **Interactive Financial Charts**: Create and manipulate charts directly in VSCode\n- **Multiple Chart Types**: Support for candlestick, line, and histogram series\n- **Technical Analysis Tools**: Add trend lines, Fibonacci retracements, and more\n- **Multi-pane Support**: Create charts with multiple panes for different indicators\n- **Rich Logging**: Colored output using the Rich library\n- **Type Hints**: Comprehensive type annotations for better IDE support\n- **Constants Library**: Predefined constants for styles, types, and colors\n\n## Prerequisites\n\n- VSCode with the VSChart extension installed\n- Python 3.7 or higher\n- Required Python packages (automatically installed): websocket-client, numpy, pandas, rich\n\n## Usage\n\n### Basic Example\n\n```python\nfrom vschart import Chart, CandlestickSeries, VolumeSeries\nimport pandas as pd\nimport numpy as np\n\n# Sample data generation (replace with your actual data)\ndef generate_sample_data(n=100):\n    dates = pd.date_range(start=\"2023-01-01\", periods=n)\n    timestamps = [int(d.timestamp()) for d in dates]\n    \n    # Generate OHLC data\n    close = 100 + np.cumsum(np.random.normal(0, 1, n))\n    high = close + np.random.uniform(0, 3, n)\n    low = close - np.random.uniform(0, 3, n)\n    open_price = close.copy()\n    np.random.shuffle(open_price)\n    \n    # Generate volume data\n    volume = np.random.uniform(1000, 5000, n)\n    \n    # Create candlestick data\n    candlestick_data = [\n        {\"time\": t, \"open\": o, \"high\": h, \"low\": l, \"close\": c}\n        for t, o, h, l, c in zip(timestamps, open_price, high, low, close)\n    ]\n    \n    # Create volume data\n    volume_data = [\n        {\"time\": t, \"value\": v} for t, v in zip(timestamps, volume)\n    ]\n    \n    return candlestick_data, volume_data\n\n# Generate sample data\ncandlestick_data, volume_data = generate_sample_data()\n\n# Create chart instance\nchart = Chart(host=\"localhost\", port=8080)\n\n# Connect to the server\nif chart.connect():\n    # Add candlestick series\n    candlestick_series = chart.add_candlestick_series()\n    \n    # Add volume series in a separate pane\n    volume_series = chart.add_histogram_series(pane_index=1)\n    \n    # Set data\n    candlestick_series.set_data(candlestick_data)\n    volume_series.set_data(volume_data)\n    \n```\n\n### Using Constants\n\nThe library provides constants for line styles, line types, price line styles, and colors to make your code more readable and maintainable:\n\n```python\nfrom vschart import Chart, LineSeries\nfrom vschart import LineStyle, LineType, PriceLineStyle, Color\n\n# Create chart instance\nchart = Chart(\"ws://localhost:8080\")\n\n# Connect to the server\nif chart.connect():\n    # Add line series with constants\n    line_series = chart.add_line_series(\n        color=Color.BLUE,\n        lineWidth=2,\n        lineStyle=LineStyle.DASHED,\n        lineType=LineType.SIMPLE,\n        priceLineStyle=PriceLineStyle.DOTTED\n    )\n    \n    # Set data\n    line_series.set_data(line_data)\n```\n\n## Available Constants\n\n### Line Styles\n\n```python\nLineStyle.SOLID         # 0: Solid line\nLineStyle.DOTTED        # 1: Dotted line\nLineStyle.DASHED        # 2: Dashed line\nLineStyle.LARGE_DASHED  # 3: Large dashed line\nLineStyle.SPARSE_DOTTED # 4: Sparse dotted line\n```\n\n### Line Types\n\n```python\nLineType.SIMPLE  # 0: Simple line\nLineType.STEP    # 1: Step line\n```\n\n### Price Line Styles\n\n```python\nPriceLineStyle.SOLID         # 0: Solid line\nPriceLineStyle.DOTTED        # 1: Dotted line\nPriceLineStyle.DASHED        # 2: Dashed line\nPriceLineStyle.LARGE_DASHED  # 3: Large dashed line\nPriceLineStyle.SPARSE_DOTTED # 4: Sparse dotted line\n```\n\n### Colors\n\n```python\n# Basic colors\nColor.BLACK    # '#000000'\nColor.WHITE    # '#FFFFFF'\nColor.RED      # '#FF0000'\nColor.GREEN    # '#00FF00'\nColor.BLUE     # '#0000FF'\nColor.YELLOW   # '#FFFF00'\nColor.CYAN     # '#00FFFF'\nColor.MAGENTA  # '#FF00FF'\n\n# Chart specific colors\nColor.UP_COLOR     # '#26a69a' (Green for up candles)\nColor.DOWN_COLOR   # '#ef5350' (Red for down candles)\nColor.WICK_COLOR   # '#737375' (Default wick color)\nColor.LINE_COLOR   # '#2196F3' (Default line color)\nColor.VOLUME_COLOR # '#26a69a' (Default volume color)\nColor.BORDER_COLOR # '#378658' (Default border color)\nColor.FILL_COLOR   # 'rgba(33, 150, 243, 0.1)' (Default fill color with transparency)\n```\n\n## Examples\n\nCheck the `examples` directory for more examples:\n\n- `basic_example.py`: Basic usage of the library\n- `constants_example.py`: Example using the constants\n- `rich_logging_demo.py`: Demo of the rich logging features\n\n## Documentation\n\nFor more information, see the documentation in the `docs` directory.\n\n## Requirements\n\n- Python 3.7 or higher\n- websocket-client>=1.6.0\n- numpy>=1.21.0\n- pandas>=1.3.0\n- rich>=10.0.0\n\n## License\n\nMIT\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "Python client for VSChart extension",
    "version": "1.0.0",
    "project_urls": {
        "Bug Tracker": "https://github.com/yourusername/vschart/issues",
        "Documentation": "https://github.com/yourusername/vschart/tree/main/vschart-python/docs",
        "Homepage": "https://github.com/yourusername/vschart",
        "Source Code": "https://github.com/yourusername/vschart"
    },
    "split_keywords": [
        "vscode",
        " chart",
        " trading",
        " finance",
        " visualization",
        " tradingview"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "621d423a43b94b9c1ffa37e680217467c732de9dd821f5dce1d0c3b3044b876a",
                "md5": "bfe75754e54fe9e3e77c0aa814597a0e",
                "sha256": "ea2efe32bc4c34c205f03b50d7df9f1bbdeb064d6795237ec398d7a11ae089e1"
            },
            "downloads": -1,
            "filename": "vschart_python-1.0.0-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "bfe75754e54fe9e3e77c0aa814597a0e",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.7",
            "size": 28412,
            "upload_time": "2025-08-15T08:31:16",
            "upload_time_iso_8601": "2025-08-15T08:31:16.065520Z",
            "url": "https://files.pythonhosted.org/packages/62/1d/423a43b94b9c1ffa37e680217467c732de9dd821f5dce1d0c3b3044b876a/vschart_python-1.0.0-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "cca4aea3a5299e06bb447f2bce03e5f595f1da6538856f56ccc7a318cdf11944",
                "md5": "1950267069d716cf86c4b6454d2ea013",
                "sha256": "206ad44bccb4345e6323d4e6e1ad0f80cc37593d369d19b2a7eaca6a4dcb5ed7"
            },
            "downloads": -1,
            "filename": "vschart_python-1.0.0.tar.gz",
            "has_sig": false,
            "md5_digest": "1950267069d716cf86c4b6454d2ea013",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.7",
            "size": 38801,
            "upload_time": "2025-08-15T08:31:17",
            "upload_time_iso_8601": "2025-08-15T08:31:17.486222Z",
            "url": "https://files.pythonhosted.org/packages/cc/a4/aea3a5299e06bb447f2bce03e5f595f1da6538856f56ccc7a318cdf11944/vschart_python-1.0.0.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2025-08-15 08:31:17",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "yourusername",
    "github_project": "vschart",
    "github_not_found": true,
    "lcname": "vschart-python"
}
        
Elapsed time: 0.57390s