barrier.ts
This example demonstrates Monte Carlo option pricing for barrier options, showing how path-dependent payoffs are simulated under geometric Brownian motion. It uses AssemblyScript with WASI bindings, leveraging the `Console` and `FileSystem` APIs from `as-wasi`, while computing normal random deviates via the Box-Muller transform. The visualization focuses on the algorithm’s core logic—iterating through simulated price paths, tracking each path’s minimum and maximum, and applying knock-in/knock-out barrier conditions to filter payoffs. The code explicitly handles up/down barriers and prints the final discounted option price, but it does not render a chart; instead, it serves as a computational example of stochastic simulation in a WebAssembly environment.
AI-generated description