TradingView Data Source
Introduction
This is a data source library for algorithmic trading written in Rust inspired by TradingView-API. It provides programmatic access to TradingView's data and features through a robust, async-first API.
⚠️ Alpha Stage: This library is currently in alpha stage and not ready for production use. Breaking changes may occur between versions.
Features
- Async Support - Built with Tokio for high-performance async operations
- Multi-Threading - Handle large amounts of data efficiently
- Session Management - Shared sessions between threads to respect TradingView's rate limits
- TradingView Premium Features - Access premium data and indicators
- Real-time Data - WebSocket-based live market data
- Historical Data - Fetch OHLCV data with batch operations
- Custom Indicators - Work with Pine Script indicators
- Chart Drawings - Retrieve your chart drawings and annotations
- Replay Mode - Historical market replay functionality
- News Integration - Access TradingView news and headlines
- Fundamental data
- Technical analysis signals
- Invite-only indicators support
- Public chat interactions
- Screener integration
- Economic calendar
- Vectorized data conversion
Installation
Add this to your Cargo.toml:
[]
= { = "https://github.com/bitbytelabio/tradingview-rs.git", = "main" }
Quick Start
Basic Historical Data
use ;
async
User Authentication
use UserCookies;
async
Real-time Data
use ;
async
Examples
The examples/ directory contains comprehensive examples:
historical_data.rs- Fetch historical OHLCV datafetch_historical_data_batch.rs- Batch historical data operationsuser.rs- User authentication and session managementindicator.rs- Working with Pine Script indicatorsmisc.rs- Miscellaneous utility functions
Run an example:
Prerequisites
- Rust 1.70+ - This library uses modern Rust features
- TradingView Account - Required for authenticated features
- Network Access - Connects to TradingView's servers
Environment Variables
For examples requiring authentication, create a .env file:
TV_USERNAME=your_username
TV_PASSWORD=your_password
TV_TOTP_SECRET=your_2fa_secret # Optional, for 2FA
Use Cases
- VNQuant Datafeed - Event-driven data engine with RedPanda (Kafka)
- Algorithmic Trading Bots - Real-time market data for trading strategies
- Market Research - Historical data analysis and backtesting
- Portfolio Management - Track and analyze investment performance
Documentation
Since this library is in alpha stage, documentation is actively being developed.
Before Opening an Issue
- Check existing issues - Your problem might already be reported
- Update to latest version - Bug fixes are released regularly
- Review examples - Make sure you're using the API correctly
- Provide minimal reproduction - Include code that demonstrates the issue
- Include error messages - Full error output helps with debugging
Known Issues & Limitations
- Rate Limiting - TradingView enforces rate limits; respect them to avoid bans
- Session Expiry - User sessions expire and need renewal
- Alpha Quality - Breaking changes may occur between versions
- Premium Features - Some features require TradingView Pro/Premium subscription
Contributing
Contributions are welcome! Please read our Code of Conduct first.
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Security
If you discover a security vulnerability, please see our Security Policy for reporting instructions.
License
This project is licensed under the MIT License - see the LICENSE file for details.
Disclaimer
This library is not affiliated with TradingView. Use at your own risk and ensure compliance with TradingView's Terms of Service.