-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrho.py
81 lines (71 loc) · 2.39 KB
/
rho.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!C:\xampp\htdocs\options\venv\Scripts\python.exe
import cgi,cgitb,pymysql
from model import Option, options_chain
cgitb.enable()
# Create instance of FieldStorage
form = cgi.FieldStorage()
contract = form.getvalue('contract')
ticker = form.getvalue('ticker')
value = form.getvalue('value')
db = pymysql.connect(host="localhost", # your host
user="habegger", # username
passwd="JzZCLgeDj.TJyo9f", # password
db="Options") # name of the database
cur = db.cursor()
print("Content-type:text/html\r\n\r\n")
print("<html>")
print("<head>")
print("<style>")
print("table, th, td {")
print(" border: 1px solid black;")
print(" border-collapse: collapse;")
print(" text-align: center;")
print(" width: 50%")
print("}")
print("</style>")
print("<title>Rho - {0}</title>".format(contract))
print("</head>")
print("<body>")
print("<table>")
print(" <tr>")
print(" <th>Contract Name</th>")
print(" <th>Ticker</th>")
print(" <th>Rho</th>")
print(" </tr>")
print("<tr>", end="")
print("<td>{0}</td>".format(contract))
print("<td>{0}</td>".format(ticker))
print("<td>{0}</td>".format(value))
print("</tr>", end="")
print("</table>")
print("<style>")
print(".symbol {")
print(" margin-top:25px;")
print(" text-align:center;")
print(" font-size:70px;")
print(" font-weight: bold;")
print(" margin-bottom:0px;")
print("}")
print("</style>")
print("<p class='symbol'>Ρ</p>")
print("<h2>Rho Options</h2>")
print("<ul>")
print(" <li>Rho measures the expected change in an option’s price per one-percentage-point change in interest rates. </li>")
print(" <li>It tells you how much the price of an option should rise or fall if the risk-free interest rate (U.S. Treasury-bills)* increases or decreases.</li>")
print(" <li>As interest rates increase, the value of call options will generally increase.</li>")
print(" <li>As interest rates increase, the value of put options will usually decrease.</li>")
print(" <li>For these reasons, call options have positive Rho and put options have negative Rho.</li>")
print("</ul>")
cur.close()
del cur
db.close()
print("<style>")
print(".bottom {")
print(" margin-top:35px;")
print(" text-align:right;")
print(" margin-right:25px;")
print("}")
print("</style>")
print("<p class='bottom'><a href='contract.py?ticker={0}&contract={1}'>Back</a></p>".format(ticker, contract))
print("</body>")
print("</html>")