Crypto · 10/29/2025
Intégration à une plateforme de trading (testnet)

Espace publicitaire (in-article 1)
A) Exchange crypto via CCXT (ex. Binance Futures testnet)
Ouvre un compte testnet et crée des API keys.
Renseigne .env (EXCHANGE=binanceusdm, EXCHANGE_TESTNET=true).
Lance node dist/executor.js (ou tsx src/executor.ts) → l’ordre part en paper.
Vérifie l’historique d’ordres sur le testnet.
B) Webhooks (TradingView → ton exécuteur)
Dans src/server.ts, expose une route POST /signal qui reçoit { symbol, side } signée en HMAC.
Dans TradingView, configure une alerte avec la webhook URL et un payload JSON.
// src/server.ts
import 'dotenv/config'
import express from 'express'
import crypto from 'node:crypto'
import { CcxtAdapter } from './broker/ccxt-adapter'
const app = express()
app.use(express.json())
function verify(sig: string, payload: string) {
const h = crypto.createHmac('sha256', process.env.WEBHOOK_SECRET || 'demo').update(payload).digest('hex')
return h === sig
}
app.post('/signal', async (req, res) => {
const signature = req.headers['x-signature'] as string
const payload = JSON.stringify(req.body)
if (!verify(signature, payload)) return res.status(401).send('bad signature')
const { symbol, side, amount } = req.body
const ex = new CcxtAdapter({
id: process.env.EXCHANGE || 'binanceusdm',
apiKey: process.env.EXCHANGE_API_KEY || '',
secret: process.env.EXCHANGE_API_SECRET || '',
testnet: String(process.env.EXCHANGE_TESTNET).toLowerCase()==='true',
})
const order = await ex.createOrder({ symbol, side, type:'market', amount, clientOrderId: `WBK-${Date.now()}` })
res.json({ ok: true, order })
})
app.listen(process.env.PORT || 3000, () => console.log('Webhook server up'))
Espace publicitaire (in-article 2)



