Tuff Trading Framework
Tuff is a powerful and flexible trading framework built in Rust, designed for both novice and experienced traders. It provides a simple syntax for defining trading strategies, a comprehensive library of technical indicators, and robust risk management features, all while prioritizing user privacy.
Features
- ๐ Simple Syntax: Define both simple and advanced trading strategies with the simplest syntax in the fastest time.
- ๐ Comprehensive Indicator Library: Access a complete library of technical indicators with easy-to-use syntax.
- ๐ Smart Ordering: Supports market, limit, and stop orders, automatically choosing the best one for you.
- โฐ Multiple Timeframes and Symbols: Backtest and live trade multiple timeframes and symbols simultaneously without look-ahead bias.
- ๐ Self-Hosted and Privacy-First: Fully self-hosted to ensure your trading strategies and data remain secure.
- ๐ก๏ธ Risk Management: Built-in helper functions for robust risk management.
- ๐ Metrics System: A comprehensive metrics system to evaluate your trading strategy's performance.
- ๐ Debug Mode: Observe your strategy in action with a detailed debug mode.
- ๐ง Optimize Mode: Fine-tune your strategies using AI, without needing a technical background.
- ๐ Leveraged and Short-Selling: First-class support for leveraged trading and short-selling.
- ๐ Partial Fills: Supports entering and exiting positions in multiple orders, allowing for greater flexibility.
- ๐ Advanced Alerts: Create real-time alerts within your strategies for effective monitoring.
- ๐ Auto-Generated Charts: View your portfolio's performance with automatically generated charts.
- ๐งน Data Cleaning: Automatic handling of importing candles and cleaning data.
- ๐ First-Class Support for Trading Futures and Spot: Specialized support for both futures and spot markets.
- ๐ Support for Decentralized Exchanges (DEX): Maintain full custody of your assets while trading.
Getting Started
-
Clone the repository:
-
Build the project:
-
Run the project:
Contributing
Contributions are welcome! Please open an issue or submit a pull request for any enhancements or bug fixes.
License
This project is licensed under the MIT License.
WebSocket Example
The repository includes a WebSocket example that demonstrates how to connect to Binance's WebSocket API with proxy support.
Running the WebSocket Example
By default, the example connects to Binance's WebSocket API:
This will connect to Binance's WebSocket API and process 5 messages.
Using a Proxy
There are several ways to use a proxy (which is recommended for connecting to Binance):
- Command-line option: Use the
-poption to specify a proxy:
For SOCKS5 proxies:
- Environment variables: The example will automatically use system proxy environment variables if set:
-
Default fallback: If no proxy is specified and no environment variables are found, the example defaults to using:
http://127.0.0.1:7890for HTTP/HTTPS connectionssocks5://127.0.0.1:7890for other connections
-
Disable proxies: To explicitly disable all proxies and connect directly:
Using the Echo Server (for testing)
If you want to test with a simple echo server instead of Binance:
Command Line Options
For a full list of options: