docs: restructure README, add Chinese translation, Notion template and Docker Compose deployment

- Add README_CN.md as a full Chinese translation of README.md
- Add a Notion Template & Preview section with the database template link,
  collapsible preview screenshots, and a note on the companion TradeSnap
  service that provides the TradingView screenshots
- Add a Deployment section documenting Docker Compose (recommended) and local build
- Use relative links so they resolve on GitHub
- Drop the Code Example and Requirements sections and renumber

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
0xcathiefish
2026-06-10 06:53:47 +00:00
parent e82da57136
commit bba06206ab
2 changed files with 231 additions and 33 deletions
+69 -33
View File
@@ -2,6 +2,8 @@
An efficient, decoupled Hyperliquid wallet position monitor and Notion database logger.
> 中文版:[README_CN.md](./README_CN.md)
## 1. Introduction
`tradesync` is a real-time wallet position monitoring and analysis tool built with Rust. It subscribes to a specified Hyperliquid wallet address via WebSockets, captures position-opening trades in real-time, aggregates multi-tick partial fills of a single order (using a 500ms debounce aggregation mechanism), and automatically synchronizes the formatted trade data to a Notion database.
@@ -13,7 +15,33 @@ An efficient, decoupled Hyperliquid wallet position monitor and Notion database
* **Robust Reconnection**: Implements a robust connection loop that automatically reconnects after network glitches or WebSocket drops.
* **Notion Integration**: Integrates `notion-client` API to write structured rows (`Symbol`, `Quantity`, `Filled Price`, `Direction`, `Exchange`, `DataTime`, `Order ID`, `Order Type`, `Check`) directly to a target Notion database.
## 3. Architecture & Modules
## 3. Notion Template & Preview
This project writes data into a Notion database, so you first need a database whose schema matches the expected fields. You can duplicate the official template directly (click **Duplicate** in the top-right corner to copy it into your own workspace):
> 📋 **Notion database template**: <https://annafish.notion.site/2026-2e08f81ac37080c6a474f00373d13287>
After duplicating, put the database ID into `NOTION_DATABASE_ID` in your `.env`, and connect your Notion integration to that page.
<details>
<summary>🗂️ Notion database example (click to expand)</summary>
<img src="https://img.cathiefish.art/github/tradesync/tradesync1.png" width="720" alt="tradesync database example" />
</details>
<details>
<summary>📜 Full long screenshot of a single record page (click to expand)</summary>
<img src="https://img.cathiefish.art/github/tradesync/tradesync2.png" width="420" alt="tradesync record page example" />
</details>
> 🖼️ **About the real-time TradingView screenshots on the record page**
> The multi-timeframe (15m / 1h / 4h / 1D) real-time TradingView screenshots on each record page are **not** generated by `tradesync` itself, but by a companion service called **TradeSnap** (separate repo: <https://github.com/exchanges-lab/tradesnap>). After writing to Notion, `tradesync` calls TradeSnap via `TRADESNAP_URL` to fetch the screenshots and appends them to the corresponding page.
> This is optional and controlled by `ENABLE_SCREENSHOT`; when disabled, `tradesync` only writes trade data rows and does not depend on TradeSnap.
## 4. Architecture & Modules
The directory structure and modules are as follows:
```
@@ -29,6 +57,8 @@ tradesync/
├── tests/ # Integration and unit tests
│ └── monitor_test.rs # Monitor connectivity and reconnection loop tests
├── references/ # Local reference submodules
├── docker-compose.yml # Docker Compose deployment orchestration
├── Dockerfile # Container image build file
├── .env # Local environment variables configuration (ignored by git)
├── .env.example # Environment configuration template
├── Cargo.toml # Cargo package file with remote Git dependencies
@@ -39,11 +69,41 @@ tradesync/
* **NotionWriter** (`src/notion.rs`): Formats and writes the captured row data to the Notion database.
* **structs** (`src/structs.rs`): Defines data models like `PositionTradeEvent` and `NotionRowData`.
## 4. Requirements
* **Rust**: `1.85.0` or higher (supports the 2024 edition)
* **OS**: Linux, macOS, Windows
## 5. Deployment
### Option 1: Docker Compose (Recommended)
The project ships a `docker-compose.yml` that pulls the prebuilt image `ghcr.io/exchanges-lab/tradesync:latest` and runs it directly — no local Rust toolchain required.
```bash
# Clone the repository
git clone https://github.com/cathiefish/tradesync.git
cd tradesync
# Copy and configure environment variables
cp .env.example .env
# Edit .env with your WALLET_ADDRESS, NOTION_API_KEY, NOTION_DATABASE_ID, etc.
# The compose file uses an external network named "cycle"; create it on first deploy
docker network create cycle
# Pull the latest image and start in the background
docker compose pull
docker compose up -d
# Follow live logs
docker compose logs -f
# Stop and remove the container
docker compose down
```
> **Notes**
> - The service in `docker-compose.yml` joins the external network `cycle` so it can communicate with other services on the same network (e.g., the screenshot service `tradesnap`). If you enable screenshots, set `TRADESNAP_URL` to an address reachable within that network (default `http://tradesnap:8003`).
> - The container is configured with `restart: unless-stopped`, so it comes back up automatically after a host reboot.
### Option 2: Local Build & Run
Suitable for development, debugging, or building your own binary:
## 5. Getting Started
```bash
# Clone the repository
git clone https://github.com/cathiefish/tradesync.git
@@ -63,31 +123,7 @@ cargo run
cargo run --example demo
```
## 6. Code Example
A minimal running example for the monitor is located at [examples/demo.rs](file:///home/cathiefish/App/tradesync/examples/demo.rs):
```rust
use alloy::primitives::address;
use tradesync::HyperliquidMonitor;
use tokio::sync::mpsc;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let wallet = address!("0xc64cc00b46101bd40aa1c3121195e85c0b0918d8");
let monitor = HyperliquidMonitor::new(wallet, true); // true for Testnet
let (tx, mut rx) = mpsc::unbounded_channel();
tokio::spawn(async move {
let _ = monitor.run(tx).await;
});
while let Some(event) = rx.recv().await {
println!("Captured Position Opening Event: {:?}", event);
}
Ok(())
}
```
## 7. Environment Variables
## 6. Environment Variables
| Variable | Description | Required | Default / Example Value |
| :--- | :--- | :--- | :--- |
| `WALLET_ADDRESS` | The Ethereum/Hyperliquid wallet address to monitor | **Yes** | `0xc64cc00b46101bd40aa1c3121195e85c0b0918d8` |
@@ -104,7 +140,7 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
| `SYMBOL_1D_SNAPSHOT` | Capture and insert 1D interval screenshot (`true`/`false`) | No | `false` |
## 8. Development & Testing
## 7. Development & Testing
### Git Branching Strategy
* `dev`: Active development branch. New features and fixes are merged here first.
* `main`: Stable production-ready branch.
@@ -122,5 +158,5 @@ cargo clippy --all-targets --all-features -- -D warnings
cargo test
```
## 9. Changelog
For a detailed log of project updates, please refer to [CHANGELOG.md](file:///home/cathiefish/App/tradesync/CHANGELOG.md).
## 8. Changelog
For a detailed log of project updates, please refer to [CHANGELOG.md](./CHANGELOG.md).