Message Boards Message Boards

0
|
2891 Views
|
2 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Error plotting FinancialDerivative with ListPlot3D?

Posted 2 years ago

I am trying to create a 3-D plot of the Delta of a European Put as a function of Strike Price and Volatility using the following code:

ListPlot3D[{FinancialDerivative[{"European", 
      "Put"}, {{"StrikePrice" -> #, "Expiration" -> #2} , { 
       "InterestRate" -> 0.0175, "Volatility" -> .3, 
       "CurrentPrice" -> 3000, "Dividend" -> 0.02}}, {"Delta"}]} & @@@
   Flatten[
   Table[{strikeprice, expiration}, {strikeprice, 1500, 3000, 
     250}, {expiration, .03, .03, .135}], 1]]

The plot does not render, and I get this error:

FinancialDerivative::unrec: Unrecognized set of arguments to function FinancialDerivative[]
POSTED BY: Carlos Abadi
2 Replies
Posted 2 years ago

Thank you so much!!!!

POSTED BY: Carlos Abadi
Posted 2 years ago

You've got three problems. One is that you're passing the wrong structure to FinancialDerivative. You've got contract parameters and ambient parameters bundled into a single list. Each parameter set should be it's own list, like this:

FinancialDerivative[{"European", "Put"}, {"StrikePrice" -> #, 
  "Expiration" -> #2}, {"InterestRate" -> 0.0175, "Volatility" -> .3, 
  "CurrentPrice" -> 3000, "Dividend" -> 0.02}, {"Delta"}]

The second problem is that you're applying ListPlot3D to data with the wrong dimensions. After mapping your FinancialDerivative function over the table and flattening, the result is just 1D data.

The third is your iteration range for expiriation has the same start and end. This is legal for the table, but it'll generate a degenerate surface that ListPlot3D won't render as you expect.

I'm assuming you want the result of FinancialDerivative plotted against strikeprice and expiration. Here's one way to do it:

ListPlot3D[
 Flatten[Table[{strikeprice, expiration, 
    FinancialDerivative[{"European", 
      "Put"}, {"StrikePrice" -> strikeprice, 
      "Expiration" -> expiration}, {"InterestRate" -> 0.0175, 
      "Volatility" -> .3, "CurrentPrice" -> 3000, 
      "Dividend" -> 0.02}, {"Delta"}]}, {strikeprice, 1500, 3000, 
    250}, {expiration, .03, .3, .135}], 1]]

I don't know what your iteration range should be for expiration, so I just made something up. Also, I thought it was simpler to just construct the data explicitly with the Table rather than do a MapApply.

POSTED BY: Eric Rimbey
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract