Dev.to Security 🔐 Cybersecurity 👁 2 📖 1 min read

How to Audit a Crypto Trading Bot from Its Logs

A trade count tells you how often a bot acted. To explain a specific outcome, trace one order from signal to fill, then reconcile fees and the closing execution. 1. Start with the order ID Record the symbol,

A trade count tells you how often a bot acted. To explain a specific outcome, trace one order from signal to fill, then reconcile fees and the closing execution.

1. Start with the order ID

Record the symbol, side, requested quantity and timestamps in UTC. Keep the bot’s signal time separate from the exchange acknowledgement time.

2. Reconcile the fills

Join executions to the order ID and deduplicate by execution ID before summing filled quantity. An order can have several fills or finish partially filled.

3. Account for fees

Record the amount and currency of each fee. If the exchange charges in another asset, document the conversion price and timestamp used in the report.

4. Separate open and closed exposure

Calculate realized P&L for the matched closed quantity. Report the marked value of the remaining open position separately. Flag missing identifiers, mismatched quantities and unpriced fees before presenting a result as complete.

Worked example

Suppose an order buys 0.10 units at 100 USDT and 0.10 units at 101 USDT. Entry cost before fees is 20.10 USDT. Closing both at 103 USDT yields 20.60 USDT in proceeds. After 0.08 USDT in total fees, net P&L is 0.42 USDT in this synthetic example.

I’m building Omega Titan, a trading bot log review and reporting service. The interactive sample report uses synthetic data to illustrate how fills, fees and net results can appear together.

What discrepancy in your bot logs takes the longest to investigate?

📰 Read the original article on Dev.to Security

Originally published by Dev.to Security. Aggregated on AIWithGhost for educational purposes — full credit and traffic to the original publisher.