Open omkarh25 opened 11 months ago
6cc9768546
)Here are the sandbox execution logs prior to making any changes:
2e08b68
Checking Brokers/BrokerUtils/broker_tax_calc.py for syntax errors... ✅ Brokers/BrokerUtils/broker_tax_calc.py has no syntax errors!
1/1 ✓Checking Brokers/BrokerUtils/broker_tax_calc.py for syntax errors... ✅ Brokers/BrokerUtils/broker_tax_calc.py has no syntax errors!
Sandbox passed on the latest main
, so sandbox checks will be enabled for this issue.
I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.
Brokers/BrokerUtils/constants.py
✓ https://github.com/SerendipityOrg/TradeMan/commit/e2b940774976d40efe4c18a63872db48f4271dd6 Edit
Create Brokers/BrokerUtils/constants.py with contents:
• Create a new file named 'constants.py' in the 'Brokers/BrokerUtils/' directory.
• Define constants for all the hard-coded values currently in the 'broker_tax_calc.py' file. The constants should be named in a way that clearly indicates what they represent. For example, 'BROKERAGE_ZERODHA' for the brokerage charge for Zerodha, 'STT_CTT_RATE' for the STT/CTT rate, etc.
• The values for the constants should be taken from the link to the Zerodha website provided by the user. Double-check the values to ensure they are accurate.
Brokers/BrokerUtils/constants.py
✓ Edit
Check Brokers/BrokerUtils/constants.py with contents:
Ran GitHub Actions for e2b940774976d40efe4c18a63872db48f4271dd6:
Brokers/BrokerUtils/broker_tax_calc.py
✓ https://github.com/SerendipityOrg/TradeMan/commit/7a50943402183941ade24fc25dc04a8d3277af8e Edit
Modify Brokers/BrokerUtils/broker_tax_calc.py with contents:
• Import the constants defined in 'constants.py' at the beginning of the 'broker_tax_calc.py' file.
• Replace all the hard-coded values in the 'broker_tax_calc.py' file with the corresponding constants. For example, replace the hard-coded value of 20 for the brokerage charge for Zerodha with 'BROKERAGE_ZERODHA', the hard-coded value of 0.0125 / 100 for the STT/CTT rate with 'STT_CTT_RATE', etc.
• Ensure that all the hard-coded values have been replaced with the corresponding constants.
--- +++ @@ -84,7 +84,7 @@ # Stamp charges stamp_charges_rate = 0.002 / 100 - stamp_charges = max(stamp_charges_rate * entry_prc * qty, 200) + stamp_charges = max(STAMP_CHARGES_RATE_ZERODHA * entry_prc * qty, 200) total_charges = brokerage + stt_ctt + transaction_charges + gst + sebi_charges + stamp_charges
Brokers/BrokerUtils/broker_tax_calc.py
✓ Edit
Check Brokers/BrokerUtils/broker_tax_calc.py with contents:
Ran GitHub Actions for 7a50943402183941ade24fc25dc04a8d3277af8e:
I have finished reviewing the code for completeness. I did not find errors for sweep/optimize-broker-tax-calc
.
💡 To recreate the pull request edit the issue title or description. To tweak the pull request, leave a comment on the pull request. Join Our Discord
Sweep: Refactor 'Brokers/BrokerUtils/broker_tax_calc.py'
Details
there is lot of redundant variables and hard coded values in the code. Remove coupling in the code by extracting constants and hard coded values. Use this documentation: https://zerodha.com/charges#tab-equities, for exact value reference from equity segment
Checklist
- [X] Create `Brokers/BrokerUtils/constants.py` ✓ https://github.com/SerendipityOrg/TradeMan/commit/e2b940774976d40efe4c18a63872db48f4271dd6 [Edit](https://github.com/SerendipityOrg/TradeMan/edit/sweep/optimize-broker-tax-calc/Brokers/BrokerUtils/constants.py) - [X] Running GitHub Actions for `Brokers/BrokerUtils/constants.py` ✓ [Edit](https://github.com/SerendipityOrg/TradeMan/edit/sweep/optimize-broker-tax-calc/Brokers/BrokerUtils/constants.py) - [X] Modify `Brokers/BrokerUtils/broker_tax_calc.py` ✓ https://github.com/SerendipityOrg/TradeMan/commit/7a50943402183941ade24fc25dc04a8d3277af8e [Edit](https://github.com/SerendipityOrg/TradeMan/edit/sweep/optimize-broker-tax-calc/Brokers/BrokerUtils/broker_tax_calc.py) - [X] Running GitHub Actions for `Brokers/BrokerUtils/broker_tax_calc.py` ✓ [Edit](https://github.com/SerendipityOrg/TradeMan/edit/sweep/optimize-broker-tax-calc/Brokers/BrokerUtils/broker_tax_calc.py) ![Flowchart](https://raw.githubusercontent.com/SerendipityOrg/TradeMan/sweep/assets/58c50d5820f1db2aae51299414517ce973263a5352a158db360e7f4222ff48e0_12_flowchart.svg)