Fintech Engineering Mistakes

best-practices csharp aspnetcore
  • Using floating point data types

    • Use integers to represent money and count pennies.

    • If money needs to be divided, and the division isn’t even, the extra pennies should be apportioned according to well-understood business rules.

  • Updating transactions

    • Build transaction tracking systems.

    • Every transaction and updates to transactions should be new records.

    • Store checksums of the transaction data to make sure that the data is not modified.

  • Transaction Ordering

    • Financial transactions often need to be processed in the order they were initiated.

    • This is especially crucial in high-frequency trading where trades are often made in milliseconds or microseconds.

    • A small difference in timing could potentially lead to substantial financial gains or losses.

    • Therefore, accurate time synchronization ensures fairness and order in the execution of these transactions.

  • Audit Trails and Dispute Resolution

    • Timestamping transactions can help create a precise audit trail, which is critical for detecting and investigating fraudulent activities.

    • In case of any dispute, a detailed and accurate transaction history backed by synchronized time can help resolve the issue.

  • Timekeeping and Clocks and Distributed Systems

    • In distributed systems, time synchronization is important to ensure data consistency.

    • Many financial systems are distributed over different geographical locations, and transactions need to be coordinated between these systems in an orderly fashion.

    • This requires all servers to have their clocks synchronized.

  • Store money with the currency and the timestamp

    • You don’t represent money as (currency, amount), you may want to store it as (currency, amount, timestamp) to be able to apply the correct exchange rate post-facto, and not have to deduce from the transaction history.

    • Start recording the currency of the transactions as early as possible. It can be a separate column in your table.

  • Use TIMESTAMPTZ

    • Use TIMESTAMPTZ. Always.

    • When you’re using JSON to pass around datetime data, Use ISO8601 date and time with offset info, always. e.g. "transactionDate": "2023‐06‐28T15:55:22.511Z"

References