-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.py
63 lines (53 loc) · 1.63 KB
/
main.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
import streamlit as st
from typing import Dict, Type, Union
import sys
from pathlib import Path
# Add the project root to the Python path
file_path = Path(__file__).parent.resolve()
sys.path.append(str(file_path))
# Import strategies
from src.strategies.base_strategy import LongCall, ShortCall, LongPut, ShortPut
from src.strategies.complex_strategy import (
BullCallSpread,
BearPutSpread,
LongStraddle,
LongStrangle,
Strip,
Strap,
LongButterfly
)
from src.utils.strategy_renderer import StrategyRenderer
from src.visualisations.styling import render_header
# Strategy mapping
STRATEGY_MAP: Dict[str, Type[Union[LongCall, ShortCall, LongPut, ShortPut, BullCallSpread, BearPutSpread, LongStraddle, LongStrangle, Strip, Strap, LongButterfly]]] = {
"Long Call": LongCall,
"Short Call": ShortCall,
"Long Put": LongPut,
"Short Put": ShortPut,
"Bull Call Spread": BullCallSpread,
"Bear Put Spread": BearPutSpread,
"Long Straddle": LongStraddle,
"Long Strangle": LongStrangle,
"Strip": Strip,
"Strap": Strap,
"Long Butterfly": LongButterfly
}
def main():
# Set page config
st.set_page_config(
page_title="Options Strategy Payoff Calculator",
page_icon="📈",
layout="wide"
)
render_header()
# Strategy selection
strategy_name = st.sidebar.selectbox(
"Select Strategy",
options=list(STRATEGY_MAP.keys())
)
# Get strategy class
strategy_class = STRATEGY_MAP[strategy_name]
# Render strategy analysis
StrategyRenderer.render_strategy(strategy_class, strategy_name)
if __name__ == "__main__":
main()