2009년 07월 03일
제 책이 나왔습니다. 어~ 이거 쑥쓰럽구만!
오늘은 저에게 특별한 포스팅이 되겠군요. 나라 돈 불리시느라 애쓰시는 이기홍박사님과 컴퓨터앞에서 노느라 바쁜 제가 책을 한 권 냈습니다. 책 이름은 거창하게 '금융공학 프로그래밍'입니다. 재작년 가을에 기획을 하고 일 년간 썼는데, 웬지 여러분 앞에 나서자니 쑥쓰럽군요.

책은 학생과 금융공학을 배우려는 분들을 위해 썼는데, 무지 쉽게 쓴다고 했지만 다른 분 보기엔 어떠실지 모르겠군요. 책의 내용은 주로 옵션과 VBA프로그래밍에 대한 내용입니다. 원래는 c/c++로 하려다가 초보를 위한 답시고 VBA로 했습니다. 책 잘 팔리면 Fixed Income이나 Mathematical Algorithms방면으로 2탄을 내볼까 하는데, 안 팔리면 남태평양 섬으로 망명을 할지도 모릅니다.

뱀 꺼내놓고 뜸만 들이는 길거리 만병통치약 장수짓 그만 하고 책의 목차를 보여드리면...

1장 파생상품과 옵션
01 파생상품이란?
02 옵션이란?
03 옵션의 손익구조
04 첫 VBA 프로그래밍

2장 옵션의 가치
01 옵션의 내재가치
02 옵션의 시간가치
03 시간가치와 내재가치, 그리고 프리미엄의 관계
04 풋-콜 패리티

3장 단순하지만 매력있는 이항모델
01 단순한 1기간 모델
02 2기간 모델
03 이항모델의 일반식
04 아메리칸 옵션의 이항모델

4장 노벨상에 빛나는 블랙-숄즈 모델
01 주가의 확률과정과 분포
02 블랙-숄즈 모델
03 변동성
04 블랙-숄즈 모델의 한계
05 블랙-숄즈 모델과 옵션민감도

5장 변동성과 알고리즘
01 이분법과 가중이분법
02 뉴턴-랩슨 알고리즘과 내재 변동성
03 변동성 스마일

6장 유한차분법을 이용한 옵션가격 알아보기
01 유한차분법
02 양함수차분법
03 음함수차분법
04 크랭크-니콜슨 차분법
05 프로그램의 실행과 디버깅, 그리고 조사식창

7장 몬테 카를로 시뮬레이션
01 난수의 발생
02 박스-뮬러 난수
03 주가 시뮬레이션
04 몬테 카를로 시뮬레이션을 이용한 콜 옵션가격결정
05 촐레스키 분해를 이용하여 상관 관계를 가진 난수 만들기
06 VBA의 행렬 연산

8장 VBA 프로그래밍
01 프로시저
02 변수와 연산자
03 조건 판단문
04 반복문
05 문자열 함수
06 날짜 함수
07 수학 함수
08 워크시트 핸들링

9장 유용한 엑셀 애드인
01 MATRIX 애드인
02 XlXtrFun 애드인

[URL]금융공학 프로그래밍

마침 제가 좋아하는 웹툰인 '마음의 소리' 조석님도 책을 내셨더군요. 그 분의 팬이기도 하고 묻어갈 작정으로 ...좀 사줘요~
by 타임버드 | 2009/07/03 15:01 | 금융공학 | 트랙백 | 덧글(8)
2009년 07월 02일
WriteFile API를 사용하여 이진 파일 데이터 쓰기 방법
남의 일 도와주다 검색한 건데, 나중에 혹 쓸 일이 있을 까 싶어...
Public Const GENERIC_WRITE = &H40000000
Public Const GENERIC_READ = &H80000000
Const FILE_ATTRIBUTE_NORMAL = &H80
Const CREATE_ALWAYS = 2
Const OPEN_ALWAYS = 4
Const INVALID_HANDLE_VALUE = -1
Const FILE_NAME = "TEST.DAT" 'This can be any file that does not
'currently exist.

Type MyType
value As Integer
End Type

Declare Function ReadFile Lib "kernel32" (ByVal hFile As Long, _
lpBuffer As Any, ByVal nNumberOfBytesToRead As Long, _
lpNumberOfBytesRead As Long, ByVal lpOverlapped As Long) As Long

Private Declare Function CloseHandle Lib "kernel32" ( _
ByVal hObject As Long) As Long

Private Declare Function WriteFile Lib "kernel32" ( _
ByVal hFile As Long, lpBuffer As Any, _
ByVal nNumberOfBytesToWrite As Long, _
lpNumberOfBytesWritten As Long, ByVal lpOverlapped As Long) As Long

Private Declare Function CreateFile Lib "kernel32" _
Alias "CreateFileA" (ByVal lpFileName As String, _
ByVal dwDesiredAccess As Long, ByVal dwShareMode As Long, _
ByVal lpSecurityAttributes As Long, _
ByVal dwCreationDisposition As Long, _
ByVal dwFlagsAndAttributes As Long, ByVal hTemplateFile As Long) _
As Long

Declare Function FlushFileBuffers Lib "kernel32" ( _
ByVal hFile As Long) As Long

Sub fillArray(anArray() As MyType)
Dim x As Integer

For x = 0 To UBound(anArray)
anArray(x).value = x
Next x
End Sub

Sub Main()
Dim fHandle As Integer
Dim T(1000) As MyType 'Define a large array of data
Dim S(1000) As MyType 'Define another large array

fillArray T 'Fill the array with some values
writearray FILE_NAME, T 'Write the entire array to disk
readArray FILE_NAME, S 'Read into a different array
End Sub

Sub readArray(Fname As String, anArray() As MyType)
Dim fHandle As Long
Dim fSuccess As Long
Dim sTest As String
Dim lBytesRead As Long
Dim BytesToRead As Long

'Get size of data to write
BytesToRead = (UBound(anArray) + 1) * LenB(anArray(0))
'Get a handle to a file Fname.
fHandle = CreateFile(Fname, GENERIC_WRITE Or GENERIC_READ, _
0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0)
'Here you should test to see if you get a file handle or not.
'CreateFile returns INVALID_HANDLE_VALUE if it fails.
If fHandle <> INVALID_HANDLE_VALUE Then
fSuccess = ReadFile(fHandle, anArray(LBound(anArray)), _
BytesToRead, lBytesRead, 0)
'ReadFile returns a non-zero value if it is successful.
'Now you just close the file.
fSuccess = CloseHandle(fHandle)
End If
End Sub

Sub writearray(Fname As String, anArray() As MyType)
Dim fHandle As Long
Dim fSuccess As Long
Dim sTest As String
Dim lBytesWritten As Long
Dim BytesToWrite As Long
'Get the length of data to write
BytesToWrite = (UBound(anArray) + 1) * LenB(anArray(0))
'Get a handle to a file Fname.
fHandle = CreateFile(Fname, GENERIC_WRITE Or GENERIC_READ, _
0, 0, OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL, 0)
'Here you should test to see if you get a file handle or not.
'CreateFile returns INVALID_HANDLE_VALUE if it fails.
If fHandle <> INVALID_HANDLE_VALUE Then
fSuccess = WriteFile(fHandle, anArray(LBound(anArray)), _
BytesToWrite, lBytesWritten, 0)
'Check to see if you were successful writing the data
If fSuccess <> 0 Then
'Flush the file buffers to force writing of the data.
fSuccess = FlushFileBuffers(fHandle)
'Close the file.
fSuccess = CloseHandle(fHandle)
End If
End If
End Sub


[DOWNLOAD]Another WayFileAPI.zip
by 타임버드 | 2009/07/02 08:28 | EXCEL/VBA | 트랙백 | 덧글(0)
2009년 06월 30일
새로운 함수 CUBESUM(...)
여러 워크시트나 통합문서에서 동일한 셀 위치(가령 A1:A3처럼)의 값을 편리하게 처리할 수 있는 방법이 없을 까 고민해 본 적이 있다. 가령 Sheet1!A9과 Sheet2!A9의 값을 합산하는 등등...또는 다른 워크북의 A9셀값과 현재 워크북의 A9셀값을 합쳐야 하는 경우
Function CUBESUM(rng As Range, ParamArray location())
Dim i As Long
Dim sum As Double

For i = 0 To UBound(location)
sum = sum + WorksheetFunction.sum(Range(location(i) & rng.Address))
Next
CUBESUM = sum
End Function

다음은 사용예이다.
=CUBESUM( A1:B5, "Sheet1!", "Sheet2!", "Sheet3!" )


Sheet1,2,3의 각각의 셀영역 A1:B5의 합계를 낸다.
함수이름을 CUBE~로 정했는데, 데이터 마이닝과는 큰 관계는 없다. 이번에는 비록 단순히 합계만 내는 함수이지만 좀 더 다양한 기능을 가진 함수를 만들어 볼 생각이다.
by 타임버드 | 2009/06/30 17:56 | EXCEL/VBA | 트랙백 | 덧글(0)


<< 이전 페이지 | 다음 페이지 >>