SHOW ME THE CODE !

Andy Nguyen

Member
I invite you to join me in a quest to learn something new this year. Either master C++, learn .NET, C#, etc...I promise that you will have a great feeling at the end of the day after you learn something useful.

As more and more people join me in this quest, this can turn out to be a very rewarding experience. Everything I code will be fully available here for others to download, exam, improve and I hope that you do the same.

To start this off, I just wrote a quick Euro option calculator using Black Scholes model. I used C# 2008 Express edition to code. You can download it from MS site.

It also calculates more Greeks than you would normally find. Besides the usual delta, theta, gamma, vega, rho, it gives you volga, vanna, charm, color, dual delta, dual gamma. You can choose no dividend or continuous dividend.

If I find sometime, I will add this calculator to Quantnet so people can use it to calculate.

All the greek formula is available at http://en.wikipedia.org/wiki/Greeks_(finance)
 

Attachments

Yuriy

MFE Alum
Great job, Andy, I want to learn how to program that nice GUI some day :)

I wonder what volga is :) is that a Russian river? :)
 

Bastian Gross

German Mathquant
Hey Andy,
I want to join your quest. Also I want to have a great feeling ;) at the end of the day after I learn something useful. :)

Thanks!
 

Andy Nguyen

Member
Bastian,
Go get that feeling ;)
I've seen some nice GUI application in Matlab. Maybe you can start one.

Visual Studio and .NET makes it easy to create window application. There are books on Window Forms Programming (WFP) that focus on that. There are books that focus on Windows Presentation Foundation (WPF) - the graphical interface used in Vista.

So yes, you can create application that looks like Vista, Office 2007, etc. And by popular demands, M$ finally released the icons pack used in many Windows application like VS, Office, etc

If you have VS 2008, the icon pack is at C:\Program Files\Microsoft Visual Studio 9.0\Common7\VS2008ImageLibrary

For VS2005, it's at C:\Program Files\Microsoft Visual Studio 8\Common7\VS2005\mageLibrary
 

Vadim

Member
Andy, I like an idea. We can add PDE, ODE, binomial tree's solvers etc.
We can use C++ code and implement GUI in C#.
For some parts we can compile dll assemblies to keep the code hidden.
 

Bastian Gross

German Mathquant
Hi Andy,
I'll do my best, to start an very nice GUI Matlab-application.
But I need some help by some Matlab-Tutorium.
 

Andy Nguyen

Member
Bastian,
Thanks for the link. It looks like a good starting point.
Still, the GUI capacity in Matlab, VBA is really primitive compared to the .NET platform. I was first overwhelmed by it but after getting a gist of it, you can do quite a lot.

For what it worth, I like how natural VB.NET feels with window forms. C# is similar but i have to write extra lines to accomplish the same thing in VB
 

Andy Nguyen

Member
I wrote my first window service in C# today. It's so cool.
There are plenty of guide online but most are confusing, outdated so it feels great when it's finally working.

The window service will run in the background. I need to write this so it will copy all the tools code I wrote in my C:\ and put them into a network drive. It will do it once a day when I leave work. You never know what will happen with your code, machine, etc so having latest code will come back and save my life sometimes.

Some of the problem is .NET don't have a copy directory method. It only has copy file so I have to add a copy directory recursively class. I also have to add a timer and set it to start the service every 24 hours. It will copy and overwrite all my code to a shared drive. It will also write to a log file with timestamp when it start/stop.

Apparently, I can write some code so it can call Winrar program, zip it to a zip file and dump that file instead of copy the whole dir. I'll do it tomorrow.

Having a window service is so great. I can add many tasks to it so it can update the database, save the code, email me if there is any error. Once I set this up, I don't have to remember anymore. This will come in handy in the future when we need to run something overnight.

I love C# !

Code:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.IO;
using System.IO.Compression;
using System.Diagnostics;
using System.ServiceProcess;
using System.Text;
using System.Threading;
 
//window service
namespace wsAndy
{
public partial class wsSaveProject : ServiceBase
{
private Timer stateTimer;
private TimerCallback timerDelegate;
 
public wsSaveProject()
{
InitializeComponent();
}
 
protected override void OnStart(string[] args)
{
//TODO: Add code here to start your service.
 
timerDelegate = new TimerCallback(OnTick);
stateTimer = new Timer(timerDelegate, null, 0, 86400000); // 1000ms = 1 secs
}
 
protected override void OnStop()
{
// TODO: Add code here to perform any tear-down necessary to stop your service.
stateTimer.Dispose();
FileStream fs = new FileStream(@"\\Backup\wsBackupCodeLog.txt",
FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter m_streamWriter = new StreamWriter(fs);
m_streamWriter.BaseStream.Seek(0, SeekOrigin.End);
m_streamWriter.WriteLine("Windows service wsSP stopped at \n" + DateTime.Now.ToString());
m_streamWriter.Flush();
m_streamWriter.Close();
}
 
private void OnTick(object stateObject)
{
 
// Don't let service crash
try
{
// Do your stuff here
 
DirectoryInfo src2005 = new DirectoryInfo(@"c:\Documents and Settings\My Documents\Visual Studio 2005");
DirectoryInfo dsn2005 = new DirectoryInfo(@"\\backups\VS2005");
 
FileStream fs = new FileStream(@"\\backups\wsBackupCodeLog.txt",
FileMode.OpenOrCreate, FileAccess.Write);
StreamWriter m_streamWriter = new StreamWriter(fs);
m_streamWriter.BaseStream.Seek(0, SeekOrigin.End);
m_streamWriter.WriteLine("VS2005/8 last copied at \n" + DateTime.Now.ToString());
m_streamWriter.Flush();
m_streamWriter.Close();
copyDirectory(src2005, dsn2005, true);
}
catch (Exception ex)
{
try
{
this.EventLog.WriteEntry(ex.Message, EventLogEntryType.Error);
}
catch (Exception exx)
{
//Bad luck, handle it differently or rethrow original exception
}
}
}
 
public static void copyDirectory(DirectoryInfo srcPath, DirectoryInfo destPath, bool recursive)
{
if (!destPath.Exists)
destPath.Create();
 
// copy files
foreach (FileInfo fi in srcPath.GetFiles())
{
fi.CopyTo(Path.Combine(destPath.FullName, fi.Name), true);
}
 
// copy directories
if (recursive)
{
foreach (DirectoryInfo di in srcPath.GetDirectories())
{
copyDirectory(di, new DirectoryInfo(Path.Combine(destPath.FullName, di.Name)), recursive);
}
}
}
}
}
 

alain

Older and Wiser
Andy, it is very nice that you learned how to write a Windows service but it is kind of overkill for copying files on schedule. The easiest way is to write a batch program and schedule it using the windows scheduler "at". Check the following links:

How To Use the AT Command to Schedule Tasks

http://technet.microsoft.com/en-us/library/bb490866.aspx

You should always use the right tool for the job. Services are more oriented to Asynchronous type of tasks. BTW, this is not the type of task that I picture a quant doing.
 

Andy Nguyen

Member
Thanks for the input, Alain.
You are absolutely right. This is overkill. A scheduler is working much better
An interesting read on windows service vs scheduler http://haacked.com/archive/2005/10/24/10997.aspx

By the way, what I have in mind is an event-driven background process instead of task scheduler. Probably something that read the signal in real time, if something interesting trickles then send out messages through email/sms to the set of designated recipients (traders). This will involve calling a bunch of other code I wrote in C# and do a bunch of other things.

I know, writing ws to back up a bunch of files seems dumb but I gotta start somewhere, right ;)
 

alain

Older and Wiser
By the way, what I have in mind is an event-driven background process instead of task scheduler. Probably something that read the signal in real time, if something interesting trickles then send out messages through email/sms to the set of designated recipients (traders). This will involve calling a bunch of other code I wrote in C# and do a bunch of other things.
This is more reasonable. Again, if you are dealing with asynchronous process, write a service. If not, the scheduler will be probably better.

Do you want to write a service that is going to be really useful? Write a file watcher. A service that looks at directory for a file and then triggers some task.
 

Bastian Gross

German Mathquant
Computing Greeks with Matlab GUI

Hi Andy,

this is my Matlab-Gui-Application (with main-part in the middle):

Code:
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%                                    Computing  Greeks!!!!!!!!!!!
%                                      Bastian Groß
%                                    Universität Trier
%       
%                                  16-Feb-2008 20:30:00
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
 
function varargout = Greek_Gui_2(varargin)
% GREEK_GUI_2 M-file for Greek_Gui_2.fig
%      GREEK_GUI_2, by itself, creates a new GREEK_GUI_2 or raises the existing
%      singleton*.
%
%      H = GREEK_GUI_2 returns the handle to a new GREEK_GUI_2 or the handle to
%      the existing singleton*.
%
%      GREEK_GUI_2('CALLBACK',hObject,eventData,handles,...) calls the local
%      function named CALLBACK in GREEK_GUI_2.M with the given input arguments.
%
%      GREEK_GUI_2('Property','Value',...) creates a new GREEK_GUI_2 or raises the
%      existing singleton*.  Starting from the left, property value pairs are
%      applied to the GUI before Greek_Gui_2_OpeningFunction gets called.  An
%      unrecognized property name or invalid value makes property application
%      stop.  All inputs are passed to Greek_Gui_2_OpeningFcn via varargin.
%
%      *See GUI Options on GUIDE's Tools menu.  Choose "GUI allows only one
%      instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES
% Edit the above text to modify the response to help Greek_Gui_2
% Last Modified by GUIDE v2.5              16-Feb-2008 20:41:58
% Begin initialization code - DO NOT EDIT
gui_Singleton = 1;
gui_State = struct('gui_Name',      mfilename, ...
                  'gui_Singleton',  gui_Singleton, ...
                  'gui_OpeningFcn', @Greek_Gui_2_OpeningFcn, ...
                  'gui_OutputFcn',  @Greek_Gui_2_OutputFcn, ...
                  'gui_LayoutFcn',  [] , ...
                  'gui_Callback',  []);
if nargin & isstr(varargin{1})
    gui_State.gui_Callback = str2func(varargin{1});
end
if nargout
    [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
    gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT
 
%Berechnung von Greeks!!!!!!!!!!!
%Bastian Groß
%Universität Trier
 
% --- Executes just before Greek_Gui_2 is made visible.
function Greek_Gui_2_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% varargin  command line arguments to Greek_Gui_2 (see VARARGIN)
% Choose default command line output for Greek_Gui_2
handles.output = hObject;
% Update handles structure
guidata(hObject, handles);
% UIWAIT makes Greek_Gui_2 wait for user response (see UIRESUME)
% uiwait(handles.figure1);
 
% --- Outputs from this function are returned to the command line.
function varargout = Greek_Gui_2_OutputFcn(hObject, eventdata, handles)
% varargout  cell array for returning output args (see VARARGOUT);
% hObject    handle to figure
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Get default command line output from handles structure
varargout{1} = handles.output;
 
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%      See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
function edit1_Callback(hObject, eventdata, handles)
Value = str2double(get(hObject,'String'));
handles.edit1 = Value;
guidata(hObject,handles);
% hObject    handle to edit1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
%        str2double(get(hObject,'String')) returns contents of edit1 as a double
 
% --- Executes during object creation, after setting all properties.
function edit2_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%      See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
function edit2_Callback(hObject, eventdata, handles)
Value = str2double(get(hObject,'String'));
handles.edit2 = Value;
guidata(hObject,handles);
% hObject    handle to edit2 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit2 as text
%        str2double(get(hObject,'String')) returns contents of edit2 as a double
 
% --- Executes during object creation, after setting all properties.
function edit3_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%      See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
function edit3_Callback(hObject, eventdata, handles)
Value = str2double(get(hObject,'String'));
handles.edit3 = Value;
guidata(hObject,handles);
% hObject    handle to edit3 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit3 as text
%        str2double(get(hObject,'String')) returns contents of edit3 as a double
 
% --- Executes during object creation, after setting all properties.
function edit4_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%      See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
function edit4_Callback(hObject, eventdata, handles)
Value = str2double(get(hObject,'String'));
handles.edit4 = Value;
guidata(hObject,handles);
% hObject    handle to edit4 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit4 as text
%        str2double(get(hObject,'String')) returns contents of edit4 as a double
 
% --- Executes during object creation, after setting all properties.
function edit5_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%      See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
function edit5_Callback(hObject, eventdata, handles)
Value = str2double(get(hObject,'String'));
handles.edit5 = Value;
guidata(hObject,handles);
% hObject    handle to edit5 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit5 as text
%        str2double(get(hObject,'String')) returns contents of edit5 as a double
 
% --- Executes during object creation, after setting all properties.
function edit6_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%      See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
function edit6_Callback(hObject, eventdata, handles)
Value = str2double(get(hObject,'String'));
handles.edit6 = Value;
guidata(hObject,handles);
% hObject    handle to edit6 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit6 as text
%        str2double(get(hObject,'String')) returns contents of edit6 as a double
 
% --- Executes during object creation, after setting all properties.
function edit7_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%      See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
function edit7_Callback(hObject, eventdata, handles)
% hObject    handle to edit7 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit7 as text
%        str2double(get(hObject,'String')) returns contents of edit7 as a double
 
 
 
 
%%%%%%%%%%%%%%%%%%
%%%%%%MAIN-PART%%%%%%%
%%%%%%%%%%%%%%%%%%
 
 
 
% --- Executes on button press in pushbutton1.
function pushbutton1_Callback(hObject, eventdata, handles)
clear Price;
S = handles.edit1;
K = handles.edit2;
r = handles.edit3;
q = handles.edit4;
t = handles.edit5;
Vola = handles.edit6;
a = Vola*sqrt(t);
d1 = (log(S/K) + (r - q + (Vola^2)/2)*t)/a;
d2 = d1 - a;
n1 = normcdf(d1);
n2 = normcdf(d2);
p  = sqrt(2*pi);
p1 = exp(d1^2/2)/p;
p2 = exp(d2^2/2)/p;
eq = exp(-q*t);
er = exp(-t*r);
Price = exp((-1)*q*t)*S*n1-exp((-1)*r*t)*K*n2;
delta = eq*n1;
gamma = eq*p1/(S*a);
vega  = eq*S*p1*sqrt(t);
theta = eq*S*p1*Vola/(2*sqrt(t))-r*K*er*n2+q*S*eq*n1;
rho  = K*t*er*n2;
volga = S*eq*p1*sqrt(t)*d1*d2/Vola;
vanna = -eq*p1*d2/Vola;
charm = -eq*q*n1+p1*eq*(2*(r-q)*t-d2*a)/(a*2*t);
color = -eq*p1*(2*t*q+1+d1*((2*(r-q)*t-d2*a)/(a*2*t)))/(2*S*t*a);
duald = -er*d2;
dualg = er*p2/(K*a);
Price2= num2str(Price);
delta2= num2str(delta);
gamma2= num2str(gamma);
vega2 = num2str(vega);
theta2= num2str(theta);
rho2  = num2str(rho);
volga2= num2str(volga);
vanna2= num2str(vanna);
charm2= num2str(charm);
color2= num2str(color);
duald2= num2str(duald);
dualg2= num2str(dualg);
set(handles.edit7, 'String', Price2);
set(handles.edit8, 'String', delta2);
set(handles.edit9, 'String', gamma2);
set(handles.edit10, 'String', vega2);
set(handles.edit11, 'String', theta2);
set(handles.edit12, 'String', rho2);
set(handles.edit13, 'String', volga2);
set(handles.edit14, 'String', vanna2);
set(handles.edit15, 'String', charm2);
set(handles.edit16, 'String', color2);
set(handles.edit17, 'String', duald2);
set(handles.edit18, 'String', dualg2);
 
 
% hObject    handle to pushbutton1 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
 
% --- Executes during object creation, after setting all properties.
function edit8_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%      See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
function edit8_Callback(hObject, eventdata, handles)
% hObject    handle to edit8 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit8 as text
%        str2double(get(hObject,'String')) returns contents of edit8 as a double
 
% --- Executes during object creation, after setting all properties.
function edit9_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%      See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
function edit9_Callback(hObject, eventdata, handles)
% hObject    handle to edit9 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit9 as text
%        str2double(get(hObject,'String')) returns contents of edit9 as a double
 
% --- Executes during object creation, after setting all properties.
function edit10_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%      See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
function edit10_Callback(hObject, eventdata, handles)
% hObject    handle to edit10 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit10 as text
%        str2double(get(hObject,'String')) returns contents of edit10 as a double
 
% --- Executes during object creation, after setting all properties.
function edit11_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%      See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
function edit11_Callback(hObject, eventdata, handles)
% hObject    handle to edit11 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit11 as text
%        str2double(get(hObject,'String')) returns contents of edit11 as a double
 
% --- Executes during object creation, after setting all properties.
function edit12_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%      See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
function edit12_Callback(hObject, eventdata, handles)
% hObject    handle to edit12 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit12 as text
%        str2double(get(hObject,'String')) returns contents of edit12 as a double
 
% --- Executes during object creation, after setting all properties.
function edit13_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit13 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%      See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
function edit13_Callback(hObject, eventdata, handles)
% hObject    handle to edit13 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit13 as text
%        str2double(get(hObject,'String')) returns contents of edit13 as a double
 
% --- Executes during object creation, after setting all properties.
function edit14_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit14 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%      See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
function edit14_Callback(hObject, eventdata, handles)
% hObject    handle to edit14 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit14 as text
%        str2double(get(hObject,'String')) returns contents of edit14 as a double
 
% --- Executes during object creation, after setting all properties.
function edit15_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit15 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%      See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
function edit15_Callback(hObject, eventdata, handles)
% hObject    handle to edit15 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit15 as text
%        str2double(get(hObject,'String')) returns contents of edit15 as a double
 
% --- Executes during object creation, after setting all properties.
function edit16_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit16 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%      See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
function edit16_Callback(hObject, eventdata, handles)
% hObject    handle to edit16 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit16 as text
%        str2double(get(hObject,'String')) returns contents of edit16 as a double
 
% --- Executes during object creation, after setting all properties.
function edit17_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit17 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%      See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
function edit17_Callback(hObject, eventdata, handles)
% hObject    handle to edit17 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit17 as text
%        str2double(get(hObject,'String')) returns contents of edit17 as a double
 
% --- Executes during object creation, after setting all properties.
function edit18_CreateFcn(hObject, eventdata, handles)
% hObject    handle to edit18 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    empty - handles not created until after all CreateFcns called
% Hint: edit controls usually have a white background on Windows.
%      See ISPC and COMPUTER.
if ispc
    set(hObject,'BackgroundColor','white');
else
    set(hObject,'BackgroundColor',get(0,'defaultUicontrolBackgroundColor'));
end
 
function edit18_Callback(hObject, eventdata, handles)
% hObject    handle to edit18 (see GCBO)
% eventdata  reserved - to be defined in a future version of MATLAB
% handles    structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit18 as text
%        str2double(get(hObject,'String')) returns contents of edit18 as a double
I've recognized, that Uwe Wystup developed the Volga, Vanna, Speed, Charm, Color-"Greeks".

Unbenannt.JPG
 

Attachments

Bastian Gross

German Mathquant
Computing Greeks with Matlab

Hello,
I estimate call and put Greeks now.
 

Attachments

wliu

New Member
Hi Andy:

I am very interested in your topic, and I am learning C++ in quantitative finance. DO you have a C++ vesion of this code you posted here? If so, could you please post here so we all can learn from it. Thanks a lot.

Leo
 

sugi

New Member
Hi,

I just finished coding C++ and attached here. Hope it useful.
It is similar to Andy C#, just remove the dividend calculation to make it simple.

Cheers,

Sugi
 

Attachments

Top