Merge detailed explanation into main markdown for guaranteed visibility
Browse files
    	
        app.py
    CHANGED
    
    | 
         @@ -17,9 +17,10 @@ def run_simulation( 
     | 
|
| 17 | 
         
             
                std_dev_inflation: float,
         
     | 
| 18 | 
         
             
                min_swr_test: float,
         
     | 
| 19 | 
         
             
                max_swr_test: float,
         
     | 
| 20 | 
         
            -
                 
     | 
| 21 | 
         
             
                progress=gr.Progress()
         
     | 
| 22 | 
         
             
            ):
         
     | 
| 
         | 
|
| 23 | 
         
             
                progress(0, desc="Starting simulation...")
         
     | 
| 24 | 
         
             
                # --- Core Parameters ---
         
     | 
| 25 | 
         
             
                initial_investment = float(initial_investment)
         
     | 
| 
         @@ -47,7 +48,9 @@ def run_simulation( 
     | 
|
| 47 | 
         
             
                ])
         
     | 
| 48 | 
         | 
| 49 | 
         
             
                # --- SWRs to Test ---
         
     | 
| 50 | 
         
            -
                 
     | 
| 
         | 
|
| 
         | 
|
| 51 | 
         
             
                all_results = []
         
     | 
| 52 | 
         
             
                portfolio_paths_for_plotting = {}
         
     | 
| 53 | 
         | 
| 
         @@ -263,7 +266,7 @@ with gr.Blocks() as demo: 
     | 
|
| 263 | 
         
             
                        gr.Markdown("### SWR Test Range")
         
     | 
| 264 | 
         
             
                        min_swr_test = gr.Slider(minimum=0.5, maximum=10.0, value=2.5, step=0.1, label="Min SWR to Test (%)", interactive=True)
         
     | 
| 265 | 
         
             
                        max_swr_test = gr.Slider(minimum=0.5, maximum=10.0, value=5.0, step=0.1, label="Max SWR to Test (%)", interactive=True)
         
     | 
| 266 | 
         
            -
                         
     | 
| 267 | 
         | 
| 268 | 
         
             
                        run_button = gr.Button("Run Simulation")
         
     | 
| 269 | 
         | 
| 
         @@ -297,7 +300,7 @@ with gr.Blocks() as demo: 
     | 
|
| 297 | 
         
             
                        std_dev_inflation,
         
     | 
| 298 | 
         
             
                        min_swr_test,
         
     | 
| 299 | 
         
             
                        max_swr_test,
         
     | 
| 300 | 
         
            -
                         
     | 
| 301 | 
         
             
                    ],
         
     | 
| 302 | 
         
             
                    outputs=[status_output, results_output, swr_plot_output, paths_plot_output]
         
     | 
| 303 | 
         
             
                )
         
     | 
| 
         | 
|
| 17 | 
         
             
                std_dev_inflation: float,
         
     | 
| 18 | 
         
             
                min_swr_test: float,
         
     | 
| 19 | 
         
             
                max_swr_test: float,
         
     | 
| 20 | 
         
            +
                num_swr_intervals: int,
         
     | 
| 21 | 
         
             
                progress=gr.Progress()
         
     | 
| 22 | 
         
             
            ):
         
     | 
| 23 | 
         
            +
                swr_test_step = (max_swr_test - min_swr_test) / num_swr_intervals if num_swr_intervals > 0 else 0.1 # Calculate step
         
     | 
| 24 | 
         
             
                progress(0, desc="Starting simulation...")
         
     | 
| 25 | 
         
             
                # --- Core Parameters ---
         
     | 
| 26 | 
         
             
                initial_investment = float(initial_investment)
         
     | 
| 
         | 
|
| 48 | 
         
             
                ])
         
     | 
| 49 | 
         | 
| 50 | 
         
             
                # --- SWRs to Test ---
         
     | 
| 51 | 
         
            +
                # Calculate swr_test_step based on range and number of intervals
         
     | 
| 52 | 
         
            +
                # Ensure the range is inclusive of max_swr_test by adding a small epsilon or adjusting arange end
         
     | 
| 53 | 
         
            +
                withdrawal_rates_to_test = np.arange(min_swr_test / 100.0, (max_swr_test + swr_test_step/2) / 100.0, swr_test_step / 100.0)
         
     | 
| 54 | 
         
             
                all_results = []
         
     | 
| 55 | 
         
             
                portfolio_paths_for_plotting = {}
         
     | 
| 56 | 
         | 
| 
         | 
|
| 266 | 
         
             
                        gr.Markdown("### SWR Test Range")
         
     | 
| 267 | 
         
             
                        min_swr_test = gr.Slider(minimum=0.5, maximum=10.0, value=2.5, step=0.1, label="Min SWR to Test (%)", interactive=True)
         
     | 
| 268 | 
         
             
                        max_swr_test = gr.Slider(minimum=0.5, maximum=10.0, value=5.0, step=0.1, label="Max SWR to Test (%)", interactive=True)
         
     | 
| 269 | 
         
            +
                        num_swr_intervals = gr.Slider(minimum=10, maximum=200, value=25, step=1, label="Number of SWR Intervals", interactive=True)
         
     | 
| 270 | 
         | 
| 271 | 
         
             
                        run_button = gr.Button("Run Simulation")
         
     | 
| 272 | 
         | 
| 
         | 
|
| 300 | 
         
             
                        std_dev_inflation,
         
     | 
| 301 | 
         
             
                        min_swr_test,
         
     | 
| 302 | 
         
             
                        max_swr_test,
         
     | 
| 303 | 
         
            +
                        num_swr_intervals
         
     | 
| 304 | 
         
             
                    ],
         
     | 
| 305 | 
         
             
                    outputs=[status_output, results_output, swr_plot_output, paths_plot_output]
         
     | 
| 306 | 
         
             
                )
         
     |