Open omkarh25 opened 11 months ago
3c5b3d3e11
)The sandbox appears to be unavailable or down.
I found the following snippets in your repository. I will now analyze these snippets and come up with a plan.
Summary of related docs from https://kite.trade/docs/pykiteconnect/v4/:
Based on the provided documentation snippets, the user needs to use the Kite Connect API to check the available margin for a given user list. To do this, they need to create a function and place it in the appropriate location within their project structure.
Sources:
MarketUtils/margin_utils.py
✓ https://github.com/SerendipityOrg/TradeMan/commit/d1abf2fd9ae6af97f8558b9fcfa63a0c19a4969f Edit
Create MarketUtils/margin_utils.py with contents:
• Import the `KiteConnect` class from the `kiteconnect` module.
• Define a new function, `fetch_user_margins`, that takes a list of users as an argument.
• In the `fetch_user_margins` function, iterate over the user list. For each user, create a `KiteConnect` object using the user's API key and access token, and call the `margins` method to fetch the available margin. Store the result in a dictionary with the user's name as the key and the available margin as the value.
• Handle any exceptions that may occur when fetching the margins, and return an appropriate error message.
• Return the dictionary of user margins at the end of the function.
MarketUtils/test_margin_utils.py
✓ https://github.com/SerendipityOrg/TradeMan/commit/f1efe0dd27fb5785ed6b70c86f84c409fb19be5b Edit
Create MarketUtils/test_margin_utils.py with contents:
• Import the `pytest` module for writing the tests.
• Import the `fetch_user_margins` function from the `margin_utils.py` file.
• Write tests for the `fetch_user_margins` function. The tests should cover all possible scenarios, including when the user list is empty, when the user list contains valid users, and when an error occurs while fetching the margins.
• Use mock data for the user list and the expected results.
I have finished reviewing the code for completeness. I did not find errors for sweep/check-margin
.
💡 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
Details
place the new file appropriately in project structure
Checklist
- [X] Create `MarketUtils/margin_utils.py` ✓ https://github.com/SerendipityOrg/TradeMan/commit/d1abf2fd9ae6af97f8558b9fcfa63a0c19a4969f [Edit](https://github.com/SerendipityOrg/TradeMan/edit/sweep/check-margin/MarketUtils/margin_utils.py) - [X] Create `MarketUtils/test_margin_utils.py` ✓ https://github.com/SerendipityOrg/TradeMan/commit/f1efe0dd27fb5785ed6b70c86f84c409fb19be5b [Edit](https://github.com/SerendipityOrg/TradeMan/edit/sweep/check-margin/MarketUtils/test_margin_utils.py) ![Flowchart](https://raw.githubusercontent.com/SerendipityOrg/TradeMan/sweep/assets/6d21e4a172d57bd3234cbad36613c2ce8f80d9426b624c1a04dace2dce1f3c53_17_flowchart.svg)