-
Notifications
You must be signed in to change notification settings - Fork 0
/
app.py
24 lines (19 loc) · 813 Bytes
/
app.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
from flask import Flask, render_template, request
app = Flask(__name__)
@app.route('/', methods=['GET', 'POST'])
def calculator():
lot_size = None
if request.method == 'POST':
try:
# Retrieve the form data
capital = float(request.form['capital'])
risk_percentage = float(request.form['risk_percentage'])
stop_loss_points = float(request.form['stop_loss_points'])
# Calculate the lot size
risk_amount = capital * (risk_percentage / 100)
lot_size = risk_amount / stop_loss_points
except (ValueError, ZeroDivisionError):
lot_size = "Invalid input. Please check your values."
return render_template('calculator.html', lot_size=lot_size)
if __name__ == '__main__':
app.run(debug=True)