ChipMaster's bwBASIC This also includes history going back to v2.10. *WARN* some binary files might have been corrupted by CRLF.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

46 lines
1.6 KiB

  1. 5 CLS
  2. 8 GOSUB 30000
  3. 10 PRINT"THIS PROGRAM WILL GIVE THE VALUE OF A CALL OPTION VIA THE
  4. 20 PRINT"BLACK SCHOLES OPTION VALUATION FORMULA. NECESSARY INPUT
  5. 30 PRINT"CONSISTS OF PRESENT STOCK PRICE, EXERCISE PRICE OF THE
  6. 40 PRINT"OPTION,INTEREST RATE,# OF DAYS TO EXPIRATION OF THE OPTION
  7. 50 PRINT"AND STOCK VOLATILITY. OUTPUT IS THE VALUE OF THE OPTION
  8. 60 PRINT"AND THE HEDGE RATIO."
  9. 70 PRINT:INPUT"PRESS ENTER TO CONTINUE";Z9
  10. 1000 PRINT"STOCK PRICE,EXERCISE PR.,INT.RATE(%),DAYS TO EXP,VOLATILITY(%)"
  11. 1010 INPUT ST,EX,IN,TM,VL
  12. 1015 TI=TM/365:IN=IN/100:VL=VL/100
  13. 1020 PRINT:INPUT"ARE OPTIONS PUTS(P) OR CALLS(C)";Z9$
  14. 1030 IF Z9$<>"P" AND Z9$<>"C" THEN PRINT"INPUT ERROR":GOTO 1020
  15. 1100 D1=(LOG(ST/EX)+(IN + 1/2*VL[2)*TI)/(VL*SQR(TI))
  16. 1110 D2=(LOG(ST/EX)+(IN - 1/2*VL[2)*TI)/(VL*SQR(TI))
  17. 1120 IF Z9$="P" THEN GOTO 1200
  18. 1150 X1=D1:GOSUB 9000:N1=N
  19. 1160 X1=D2:GOSUB 9000:N2=N
  20. 1170 W= ST*N1 - EX*EXP(-IN*TI)*N2
  21. 1180 GOTO 1500
  22. 1200 REM VALUE OF PUT
  23. 1210 X1=-D1:GOSUB 9000:N1=N
  24. 1220 X1=-D2:GOSUB 9000:N2=N
  25. 1230 W=-ST*N1+EX*EXP(-IN*TI)*N2
  26. 1240 GOTO 1500
  27. 1500 CLS:PRINT F$(1)
  28. 1510 PRINT:PRINT USING F$(2);ST,EX,IN,TM,VL,W,N1
  29. 1520 PRINT:INPUT"PRESS ENTER FOR MORE";Z9
  30. 1530 IF Z9 = -1 THEN END
  31. 1540 CLS:GOTO 1000
  32. 1600 GOTO 1000
  33. 9000 ' PI=3.141592654
  34. 9005 X = ABS(X1)
  35. 9015 Z = 1/SQR(2*PI)*EXP(-X[2/2)
  36. 9020 B1=.319381530 :B2=-.356563782:B3=1.781477937
  37. 9025 B4= -1.821255978:B5=1.330274429:P=.2316419
  38. 9030 T=1/(1+P*X)
  39. 9040 Q=Z*(B1*T+B2*T[2+B3*T[3+B4*T[4+B5*T[5)
  40. 9050 IF X1>0 THEN N=1-Q ELSE N=Q
  41. 9060 RETURN
  42. 30000 REM FORMAT VARIABLES
  43. 30010 F$(1)="ST.PR. EX.PR. INT.RT. D.T.EXP. VOL. VALUE HEDGE"
  44. 30020 F$(2)="###.## ###.## ###.## ### ##.## ###.## ##.##"
  45. 30030 RETURN