1 unstable release
new 0.0.1 | Mar 16, 2025 |
---|
#5 in #okx
59 downloads per month
6KB
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:
git clone https://github.com/jackson211/tuff.git cd tuff
-
Build the project:
cargo build
-
Run the project:
cargo run
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:
cargo run --example binance -- -n 5
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
-p
option to specify a proxy:
cargo run --example binance -- -p http://your-proxy-address:port
For SOCKS5 proxies:
cargo run --example binance -- -p socks5://your-proxy-address:port
- Environment variables: The example will automatically use system proxy environment variables if set:
export https_proxy=http://127.0.0.1:7890
export http_proxy=http://127.0.0.1:7890
export all_proxy=socks5://127.0.0.1:7890
cargo run --example binance
-
Default fallback: If no proxy is specified and no environment variables are found, the example defaults to using:
http://127.0.0.1:7890
for HTTP/HTTPS connectionssocks5://127.0.0.1:7890
for other connections
-
Disable proxies: To explicitly disable all proxies and connect directly:
cargo run --example binance -- --no-proxy
Using the Echo Server (for testing)
If you want to test with a simple echo server instead of Binance:
cargo run --example binance -- -u wss://echo.websocket.org
Command Line Options
For a full list of options:
cargo run --example binance -- --help