How to Automate Your Delta Exchange India Trading Journal with Google Sheets & Apps Script
Manual logging is the single biggest point of failure in trade journaling. When you hit a losing streak, emotional exhaustion takes over, and the journal stops getting updated.
To achieve true rule-based execution, your system must log itself.
In this guide, we will build an automated, zero-cost trading journal for Delta Exchange India using Google Sheets and Google Apps Script. Every executed order will sync directly to your spreadsheet, calculating net P&L, contract sizing, and fee drag automatically.
The Architecture
Instead of running a dedicated server, we use Google Sheets as our database and Google Apps Script as an automated cron job.
[Delta Exchange India API] ---> [Google Apps Script (Trigger Every 15m)] ---> [Google Sheets Journal]
- Delta Exchange India REST API: Fetches your filled trades (
GET /v2/fills). - Google Apps Script: Authenticates via HMAC-SHA256 signatures, processes raw JSON payload, and appends unique fills.
- Google Sheets: Calculates position size in BTC, net P&L, and fee friction automatically.
Step 1: Generate Read-Only API Keys on Delta Exchange
- Log into your Delta Exchange India account.
- Navigate to API Keys under your Profile settings.
- Click Create New Key.
- Set permissions to Read-Only (never grant Trade or Transfer access for a journal script).
- Store your API Key and API Secret securely.
Step 2: Set Up Your Google Sheet Structure
Create a new Google Sheet named Delta Trading Journal and set up the following column headers in Row 1:
| Column | Header | Auto-Calculated via Formula? |
|---|---|---|
| A | Fill Time (IST) | Populated by Script |
| B | Symbol | Populated by Script |
| C | Side (BUY/SELL) | Populated by Script |
| D | Lots Traded | Populated by Script |
| E | Fill Price (USD) | Populated by Script |
| F | BTC Volume | Formula: =D2 * 0.001 |
| G | Total Value (USD) | Formula: =F2 * E2 |
| H | Exchange Fee (USD) | Populated by Script |
| I | Trade ID | Populated by Script (De-duplication Key) |
Step 3: Add the Google Apps Script
- In your Google Sheet, open Extensions > Apps Script.
- Clear any default code and paste the following production script:
// ==========================================
// CONFIGURATION
// ==========================================
const API_KEY = "YOUR_DELTA_API_KEY_HERE";
const API_SECRET = "YOUR_DELTA_API_SECRET_HERE";
const BASE_URL = "https://api.india.delta.exchange"; // Delta India Endpoint
// Main execution function
function syncDeltaFills() {
const path = "/v2/fills";
const queryParams = "?limit=50";
const timestamp = Math.floor(Date.now() / 1000).toString();
const signatureData = "GET" + timestamp + path + queryParams;
// Generate HMAC-SHA256 Signature
const signature = Utilities.computeHmacSha256Signature(signatureData, API_SECRET)
.map(byte => ('0' + (byte & 0xFF).toString(16)).slice(-2))
.join('');
const options = {
"method": "get",
"headers": {
"api-key": API_KEY,
"signature": signature,
"timestamp": timestamp,
"Content-Type": "application/json"
},
"muteHttpExceptions": true
};
try {
const response = UrlFetchApp.fetch(BASE_URL + path + queryParams, options);
const json = JSON.parse(response.getContentText());
if (!json.success) {
Logger.log("API Error: " + JSON.stringify(json));
return;
}
processFills(json.result);
} catch (e) {
Logger.log("Fetch Error: " + e.toString());
}
}
// Write new fills to sheet without duplicating existing entries
function processFills(fills) {
const sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
const lastRow = sheet.getLastRow();
// Get existing Trade IDs from Column I to prevent duplicates
let existingIDs = new Set();
if (lastRow > 1) {
const ids = sheet.getRange(2, 9, lastRow - 1, 1).getValues();
ids.forEach(row => existingIDs.add(row[0].toString()));
}
// Iterate backwards so oldest trades are written first
for (let i = fills.length - 1; i >= 0; i--) {
const fill = fills[i];
const fillId = fill.id.toString();
if (!existingIDs.has(fillId)) {
const fillTime = new Date(fill.created_at).toLocaleString("en-IN", { timeZone: "Asia/Kolkata" });
const symbol = fill.product_symbol;
const side = fill.side.toUpperCase();
const size = fill.size; // Lot count
const price = parseFloat(fill.price);
const fee = parseFloat(fill.fee);
// Append row matching Columns A through I
sheet.appendRow([
fillTime,
symbol,
side,
size,
price,
`=D${sheet.getLastRow() + 1} * 0.001`, // BTC Volume formula
`=F${sheet.getLastRow() + 1} * E${sheet.getLastRow() + 1}`, // USD Value formula
fee,
fillId
]);
}
}
}
3. Replace YOUR_DELTA_API_KEY_HERE and YOUR_DELTA_API_SECRET_HERE with your API credentials.
4. Click Save (disk icon).
Step 4: Automate Execution via Time-Driven Triggers
To make the script pull trades automatically without opening Google Sheets:
- Click the Triggers (Clock icon) on the left sidebar in Apps Script.
- Click + Add Trigger (bottom right).
- Set the following parameters:
- Choose function to run:
syncDeltaFills - Select event source:
Time-driven - Type of time based trigger:
Minutes timer - Select minute interval:
Every 15 minutes
- Choose function to run:
- Click Save and grant the required permissions when prompted.
The Result: Zero-Friction Journaling
Every 15 minutes, your script syncs your actual exchange executions. Because the script checks against unique Trade ID values, it guarantees zero duplicate entries.
Why This Fixes Discipline Issues
- No Manual Data Entry: You focus on market structure and rule adherence rather than typing numbers into cells.
- Exact Fee Accounting: Delta contracts involve maker/taker fees and funding rates. Auto-fetching raw exchange fees gives you your exact net return.
- Execution Metrics: By pairing this sheet with high-level rule-checking metrics, you separate P&L outcome from execution quality.