

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# 在截止日期雲端上執行 Monte Carlo 模擬
<a name="examples-jb-monte-carlo"></a>

[monte\_carlo\_simulation](https://github.com/aws-deadline/deadline-cloud-samples/tree/mainline/job_bundles/monte_carlo_simulation) 任務套件使用 Monte Carlo 模擬搭配 QuantLib 的 Heston 隨機波動模型，為可自動呼叫的結構化備註產品組合定價。任務是 [AWS Batch 研討會定價財務衍生產品的](https://ec2spotworkshops.com/monte-carlo-with-batch.html)截止日期雲端連接埠。

套件定義兩個步驟的管道：

1. `PricePositions` — 每個產品組合位置一個任務。任務會分組為校正 Heston 模型一次的區塊，並對區塊中的所有位置定價，以攤銷校正成本。

1. `AggregateResults` — 將每個位置的結果收集到產品組合摘要中。

套件使用 Open Job Description [TASK\_CHUNKING](https://github.com/OpenJobDescription/openjd-specifications/blob/mainline/rfcs/0001-task-chunking.md) 延伸模組進行負載平衡。排程器會從分派個別位置開始，觀察它們需要多長時間，然後自動擴展區塊大小以符合目標執行時間。快速位置會分組為較大的區塊；慢速位置會保留在小型區塊中，以保持工作分散到整個機群。

若要執行此套件，您需要具有包含 `conda-forge`頻道之 conda 佇列環境的佇列`quantlib-python`。部署[入門陣列範本](https://github.com/aws-deadline/deadline-cloud-samples/tree/mainline/cloudformation/farm_templates/starter_farm)時，請將 `ProdCondaChannels` 參數設定為 `deadline-cloud conda-forge`。

使用 GUI 提交者提交套件：

```
deadline bundle gui-submit monte_carlo_simulation/
```

或者提交位置較少的快速測試：

```
deadline bundle submit monte_carlo_simulation/ \
  -p PositionRange="0-1" -p NumPaths=100
```