API Integration & Examples
This section outlines how to integrate with the QE API and provides examples of API usage.
1. Integration Process
2. Example API Usage
import time, hmac, hashlib
import requests
# Credentials (obtained from QE)
CLIENT_ID = "your_client_id"
API_SECRET = b"your_api_secret_bytes" # ensure this is in bytes for HMAC
# Example order parameters
payload = {
"exchange": "Binance",
"symbol": "BTCUSDT",
"side": "buy",
"strategy": "TWAP",
"order_quantity": 100, # total quantity to buy
"duration": 3600, # execution duration in seconds (e.g., 1 hour)
"start_time": int(time.time()) # start now (current epoch time)
# ... other optional parameters like price limits, etc.
}
# Convert payload to JSON string
import json
body = json.dumps(payload)
# Prepare authentication headers
timestamp = str(int(time.time() * 1000)) # current timestamp in ms
# Create signature: HMAC_SHA256(secret, <timestamp + body>)
signing_payload = (timestamp + body).encode('utf-8')
signature = hmac.new(API_SECRET, signing_payload, hashlib.sha256).hexdigest()
headers = {
"X-QE-CLIENTID": CLIENT_ID,
"X-QE-TIMESTAMP": timestamp,
"X-QE-SIGNATURE": signature,
"Content-Type": "application/json"
}
# Send request (assuming endpoint URL and path)
url = "https://api.quantumexecute.com/v1/algo_order"
response = requests.post(url, data=body, headers=headers)
res_data = response.json()
print("Order Status:", res_data)3. Important Notes
Last updated