Update README.md
Browse files
README.md
CHANGED
|
@@ -1,5 +1,5 @@
|
|
| 1 |
---
|
| 2 |
-
title:
|
| 3 |
emoji: π
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: indigo
|
|
@@ -7,80 +7,3 @@ sdk: docker
|
|
| 7 |
app_port: 7860
|
| 8 |
pinned: false
|
| 9 |
---
|
| 10 |
-
|
| 11 |
-
# cTrader Webhook Bot for Hugging Face Spaces
|
| 12 |
-
|
| 13 |
-
This is a 100% cloud-based trading bot that runs on Hugging Face Spaces. It listens for webhooks from TradingView and routes trades to your Fusion Markets cTrader account using the official cTrader Open API.
|
| 14 |
-
|
| 15 |
-
---
|
| 16 |
-
|
| 17 |
-
## π How to Deploy on Hugging Face Spaces
|
| 18 |
-
|
| 19 |
-
### Step 1: Create a Hugging Face Space
|
| 20 |
-
1. Log in to your [Hugging Face](https://huggingface.co/) account (create one for free if you don't have it).
|
| 21 |
-
2. Click on your profile picture at the top right and select **New Space**.
|
| 22 |
-
3. Configure your Space:
|
| 23 |
-
- **Space Name**: Give it a name (e.g., `tradingview-ctrader-bot`).
|
| 24 |
-
- **License**: Choose `apache-2.0` or leave it blank.
|
| 25 |
-
- **SDK**: Select **Docker**.
|
| 26 |
-
- **Docker Template**: Select **Blank** (or **FastAPI** if available).
|
| 27 |
-
- **Space Hardware**: Select the free tier (**CPU basic - 2 vCPU - 16 GB - Free**).
|
| 28 |
-
- **Visibility**: Select **Public** or **Private** (we recommend **Public** so TradingView can send webhooks to it, but you can secure the webhook endpoint with an API key/password. The OAuth page also needs to be accessible).
|
| 29 |
-
|
| 30 |
-
---
|
| 31 |
-
|
| 32 |
-
### Step 2: Configure Environment Secrets
|
| 33 |
-
On Hugging Face, go to your Space's page, click the **Settings** tab, scroll down to the **Variables and secrets** section, and add the following **Secret variables** (NOT plain variables):
|
| 34 |
-
|
| 35 |
-
| Secret Name | Description | Example / Value |
|
| 36 |
-
| :--- | :--- | :--- |
|
| 37 |
-
| `CTRADER_CLIENT_ID` | Client ID from cTrader developer portal | `123_abc...` |
|
| 38 |
-
| `CTRADER_CLIENT_SECRET` | Client Secret from cTrader developer portal | `xyz789...` |
|
| 39 |
-
| `CTRADER_ENV` | Environment type | `demo` or `live` |
|
| 40 |
-
| `TRADE_VOLUME` | Standard trade size in units (e.g. 1000 = 0.01 lot) | `1000` (for 0.01 micro-lot) |
|
| 41 |
-
| `WEBHOOK_PASSPHRASE` | A secret password to secure your TradingView alerts | Create a password (e.g. `MySuperSecretBotKey`) |
|
| 42 |
-
|
| 43 |
-
---
|
| 44 |
-
|
| 45 |
-
### Step 3: Configure Redirect URI in cTrader
|
| 46 |
-
1. Once your Space is created, Hugging Face will show the app URL. It usually looks like this:
|
| 47 |
-
`https://<your-username>-<your-space-name>.hf.space`
|
| 48 |
-
2. Open the **cTrader Open API developer console** (openapi.ctrader.com).
|
| 49 |
-
3. Select your application, scroll to the **Redirect URIs** section, and add:
|
| 50 |
-
`https://<your-username>-<your-space-name>.hf.space/callback`
|
| 51 |
-
4. Click **Save** on the cTrader developer console.
|
| 52 |
-
|
| 53 |
-
---
|
| 54 |
-
|
| 55 |
-
### Step 4: Upload the Files
|
| 56 |
-
Upload the following files to your Hugging Face Space:
|
| 57 |
-
1. `app.py`
|
| 58 |
-
2. `requirements.txt`
|
| 59 |
-
3. `Dockerfile`
|
| 60 |
-
|
| 61 |
-
Once uploaded, Hugging Face will automatically build and start your application container.
|
| 62 |
-
|
| 63 |
-
---
|
| 64 |
-
|
| 65 |
-
## π One-Time Authentication
|
| 66 |
-
|
| 67 |
-
Once the Space displays **Running** status:
|
| 68 |
-
1. Open your Space's URL: `https://<your-username>-<your-space-name>.hf.space`.
|
| 69 |
-
2. You will see a dashboard with a big blue button: **"Authorize Bot with cTrader"**.
|
| 70 |
-
3. Click it, log in with your cTrader credentials, choose the accounts you want to allow, and click **Allow**.
|
| 71 |
-
4. You will be redirected back to your dashboard, showing your account balance, active positions, and status: **Connected**!
|
| 72 |
-
|
| 73 |
-
---
|
| 74 |
-
|
| 75 |
-
## π Setting up the TradingView Alert
|
| 76 |
-
In your TradingView Alert creation box:
|
| 77 |
-
* **Webhook URL**: `https://<your-username>-<your-space-name>.hf.space/webhook`
|
| 78 |
-
* **Message**: Send your alert payload in JSON, including the passphrase you configured in the settings:
|
| 79 |
-
```json
|
| 80 |
-
{
|
| 81 |
-
"passphrase": "YOUR_WEBHOOK_PASSPHRASE_HERE",
|
| 82 |
-
"action": "{{strategy.order.alert_message}}",
|
| 83 |
-
"ticker": "{{ticker}}",
|
| 84 |
-
"price": {{close}}
|
| 85 |
-
}
|
| 86 |
-
```
|
|
|
|
| 1 |
---
|
| 2 |
+
title: viewc
|
| 3 |
emoji: π
|
| 4 |
colorFrom: blue
|
| 5 |
colorTo: indigo
|
|
|
|
| 7 |
app_port: 7860
|
| 8 |
pinned: false
|
| 9 |
---
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|