Closed amolkittur closed 1 month ago
I have modified the JSON with margin allocation. If any changes are to be made let me know @omkarh25
{
"Tr00": {
"Accounts": {
"Equity": {
"CapitalAllocation": 100,
"11Jul24_Equity_FreeCash": 141558.6,
"11Jul24_Equity_Holdings": 81028
},
"01Jul24_Portfolio_AccountValue": 141559,
"01Jul24_Portfolio_FreeCash": 141558.6,
"01Jul24_Portfolio_Holdings": 81028,
"02Jul24_Portfolio_FreeCash": 141507.7,
"02Jul24_Portfolio_AccountValue": 141507.7,
"02Jul24_Portfolio_Holdings": 81028
},
"Active": true,
"Broker": {
"ApiKey": "asdasd",
"ApiSecret": "asd",
"BrokerName": "Zerodha",
"BrokerPassword": "K@asdf",
"BrokerUsername": "asdf",
"SessionId": "asdf",
"TotpAccess": "dgh"
},
"Profile": {
"AadharCardNo": "234",
"AccountStartDate": "03Jul23",
"BankAccountNo": "234",
"BankName": "State Bank of India",
"DOB": "25Apr90",
"Email": "nightysky123123asdkk@gmail.com",
"GmailPassword": "a",
"Name": "Omkar Hegde",
"PANCardNo": "asddfasdf",
"PhoneNumber": "+asdfsadf",
"RiskProfile": {
"AreaOfInvestment": [
"Debt",
"Equity",
"Derivatives"
],
"Commission": "50-50",
"DrawdownTolerance": "35",
"Duration": "12 months",
"WithdrawalFrequency": "OnRequest"
},
"pwd": "a",
"usr": "0"
},
"Strategies": {
"Equity": {
"MidTerm": {
"AllocationPercent": 50,
"Strategy1": {
"AllocationPercent": 33.33,
"Qty": 28,
"RiskPerTrade": 1,
"StrategyName": "Midterm_Strategy1"
},
"Strategy2": {
"AllocationPercent": 33.33,
"Qty": 28,
"RiskPerTrade": 1,
"StrategyName": "Midterm_Strategy2"
},
"Strategy3": {
"AllocationPercent": 33.33,
"Qty": 28,
"RiskPerTrade": 1,
"StrategyName": "Midterm_Strategy3"
}
}
}
},
"Tr_No": "Tr00"
}
}
Description
This issue outlines critical tasks for refactoring our database management system and implementing key business logic algorithms in our application. These tasks encompass database cleanup, API enhancements for a touchless database interaction, and the development of capital allocation and strategy selection algorithms.
Tasks
[ ] Implement a database migration script to purge all existing records and reset the schema to its initial state. Ensure proper error handling and logging mechanisms are in place.
[ ] Refactor the FastAPI endpoints to include all necessary request/response models, query parameters, and path variables. Implement comprehensive data validation using Pydantic models to ensure a touchless database interaction.
[ ] Develop an algorithm to dynamically allocate capital based on user-defined segment percentages. Implement this logic as a separate module with unit tests. The function signature should accept a total capital amount and a dictionary of segment-percentage pairs.
[ ] Create a strategy selection algorithm that considers risk tolerance and available capital. Implement this as a class with methods for risk assessment, capital evaluation, and strategy matching. Integrate this with the existing database models for strategies and risk profiles.