Black & Scholes Model

The VBA sub bs_future is shown below; it uses a number of Mercury functions to interact with GAUSS.

  1. Sub bs_future()
  2. Sheets("B&S").Select
  3. Mercury.Load
  4. GE.WorkspaceCreate
  5. GE.RangePut "b5", "k"
  6. GE.RangePut "b6", "f"
  7. GE.RangePut "b7", "sigma"
  8. GE.RangePut "b8", "tau"
  9. GE.RangePut "b9", "r"
  10.  
  11. 'call
  12. GE.ExecCode "d9:d15"
  13. GE.ExecCode "c = bscall_future(k,f,sigma,tau,r);"
  14. GE.RangeGet "e5", "c"
  15.  
  16. 'put
  17. GE.ExecCode "d17:d23"
  18. GE.ExecCode "p = bsput_future(k,f,sigma,tau,r);"
  19. GE.RangeGet "f5", "p"
  20. GE.WorkspaceClear
  21.  
  22. End Sub

 

This VBA maco demonstrates the Black & Scholes Model for evaluating future call and put options. In this example, the sheet B&S is selected as the active sheet in line 2, and the parameter values of the model taken from this sheet and set as Gauss variables using the RangePut command in lines 5 to 9. The call code is programmed in cells d5:d11 of the spreadsheet and this proc is then executed in line 12 using the ExecCode command. The call value c is then evaluated in line 13, and returned to cell e4 in line 14. A similar procedure is used for the put value.