Serendipity2-0 / TradeManV1

0 stars 0 forks source link

Exe Engine #42

Closed amolkittur closed 1 month ago

amolkittur commented 1 month ago

Equity Module Testing

Description

We need to perform comprehensive testing of the Equity module, focusing on the short-term, mid-term, and long-term modules. The primary objectives are to ensure that orders are placed correctly, logged accurately, and properly written to the database under holdings.

Tasks

  1. Test the short-term module

    • Verify order placement
    • Check logging functionality
    • Confirm database entries in holdings
  2. Test the mid-term module

    • Verify order placement
    • Check logging functionality
    • Confirm database entries in holdings
  3. Test the long-term module

    • Verify order placement
    • Check logging functionality
    • Confirm database entries in holdings

Acceptance Criteria

Additional Notes

Serendipity2-0 commented 1 month ago

@amolkittur Its possible to get a better documentation like this: https://docs.docker.com/engine/api/v1.25/#tag/Image refer to: https://fastapi.tiangolo.com/#alternative-api-docs-upgrade to how to do this for our project. Include this in your story.

amolkittur commented 1 month ago

Sections Involved:

  1. Onboarding of Clients
  2. Execution (Exe) Engine
  3. Database Logging

1. Onboarding of Clients


2. Execution (Exe) Engine

The Exe Engine is divided into three phases:

A. Before Market

  1. Login to Broker
    • Description: Successfully implemented login functionality for respective brokers.
  1. Funds Validator

    • Description:
      • Fetch free cash from the broker.
      • Update the portfolio section in the accounts section of the Firebase DB.
      • Split the free cash based on the capital allocation of each segment.
      • Update the free cash with today's date as a prefix.
      • Example Portfolio Dict:
        {
        "18Jul24_Portfolio_AccountValue": 141559,
        "18Jul24_Portfolio_FreeCash": 141558.6,
        "18Jul24_Portfolio_Holdings": 81028
        }
      • Example Segment Dict:
        {
        "Equity": {
        "18Jul24_Equity_AccountValue": 141559,
        "18Jul24_Equity_FreeCash": 141558.6,
        "18Jul24_Equity_Holdings": 81028
        }
        }
  2. Market Info Endpoint

    • Description:
      • Create an endpoint for the admin page to update and log market information values.
      • Example Market Info Dict:
        {
        "EquityQtyAmplifier": 1,
        "OBQtyAmplifier": 2,
        "OSQtyAmplifier": 1,
        "TradeView": "Bullish"
        }
  3. Daily Instrument Aggregator

    • Status: Completed
    • Description: Successfully implemented the daily instrument aggregator to consolidate and update daily trading instruments.

B. During Market

  1. Running Strategy Scripts
  1. Calculate Quantity

    • Description:
      • Calculate the quantity based on risk, capital allocation, and other factors.
      • Fetch free cash and calculate the allocation for each strategy.
      • Update the quantity in the strategy dictionary.
      • Example Strategy Dict:
        {
        "Strategy1": {
        "Qty": 28,
        "CapitalAllocation": 50,
        "StrategyName": "PyStocks",
        "TradeState": {
         "orders": [
           {
             "avg_prc": 83.2,
             "exchange_token": 9881,
             "message": "PASS",
             "order_id": "240212501608640",
             "qty": 321,
             "time_stamp": "2024-02-12 10:12",
             "trade_id": "PS2_LG_MO_EN"
           }
         ]
        }
        }
        }
  2. Place Orders

    • Description:
      • Use the order details dictionary provided by the strategy script to place orders.
  3. Trade State Verification

    • Description:
      • Ensure the trade state is updated correctly with all relevant values.

C. After Market

  1. Database Logging Verification

    • Description:
      • Verify the logged values in the DB, such as trade ID, entry, exit, time, price, PnL, tax, etc.
  2. Holdings Collection Verification

    • Description:
      • Check the values in the Holdings collection in the database for accuracy and completeness.

3. Database Logging


Task Division


1. Admin

2. Backend

Fast API

3. Frontend

amolkittur commented 1 month ago

@amolkittur Its possible to get a better documentation like this: https://docs.docker.com/engine/api/v1.25/#tag/Image refer to: https://fastapi.tiangolo.com/#alternative-api-docs-upgrade to how to do this for our project. Include this in your story.

I will check and update the swagger/docs into a new look

amolkittur commented 1 month ago

Endpoints for admin pages

amolkittur commented 1 month ago

Funds Validator

amolkittur commented 1 month ago

As discussed with @omkarh25 , we will update the base capital field in the accounts section and split the capital based on the Capital Allocation during the onboarding process. After the freecash values have been updated in the segment, we start trading from the freecash available in the segment and maintain the account separately for each segment.

For quantity calculation, we can directly fetch the freecash from the segment, calculate the quantity, and trade with the calculated quantity. At the end of the day (EOD), we calculate the P&L, holdings, and update the values in the segment.

amolkittur commented 1 month ago

Today we celebrate a key milestone: our system's first successful order. This achievement marks the beginning of an exciting phase of enhancements and growth for our project.

Major error

amolkittur commented 1 month ago

Phase 2 Enhancement Docs

This document is for planned enhancements for our software across Admin, Backend, and Frontend components to improve functionality and user experience over the next 2 weeks.

1. Admin

  1. Setup Env files for prod, staging and dev

    • Create environment-specific configuration files to manage settings across different deployment stages.
  2. Update the admin section with the primary accounts

    • Zerodha and Firstock primary account broker details should be uploaded in the admin section and use it for daily login
  3. Update the primary accounts with the live brokers (Zerodha and Firstock)

    • Check for the brokers which are used for day to day trading (AliceBlue can be removed)
  4. Logic for Funds Validation at the portfolio level

    • Implement a system to verify and validate funds across the entire portfolio.
  5. Qty calculation (Done)

    • Quantity calculation feature has been completed and implemented.
  6. Instrument Aggregator

    • Logic to replace aliceblue feature which were used for developing the instrument db and replace it with the latest brokers(Firstock)

2. Backend

  1. Separate script for equity calculation which needs to be executed before the market hours

    • Develop a standalone script to perform equity calculations prior to market opening.
  2. Schedule the tasks (short, mid and long term) i.e daily, weekly and monthly

    • Set up automated task scheduling for various timeframes to ensure regular system updates and maintenance.
  3. Error handling logic for new user while placing stoploss

    • Implement robust error management for new users when they set stop-loss orders because the strategy collection wont be present in the db when running the script for the first time.
  4. Eod report should include all the opted segments

    • Expand end-of-day reports to cover all segments that users have opted into(Equity and Derivatives).
  5. Refactoring the fast api endpoints used for onboarding process

    • Include Tr_No in the firebase
    • Update the Accounts section with the latest format(without the dates)
    • Add BaseCapital to the accounts section
    • Validation to check wether all the fields are present in the dict which is being uploaded
  6. Add indicators/strategies to mid and long term

    • As of now only 2 strategies are present in mid and long term

3. Frontend

  1. Order executor endpoints

    • Develop API endpoints for executing trading orders from the frontend.
  2. Endpoint to modify the orders/stoploss

    • Create an API endpoint allowing users to adjust existing orders and stop-loss settings.
  3. Send notice to all users

    • Implement a system-wide notification feature to broadcast important messages to all users.
  4. Admin dashboard page (Should include AUM/ graphs)

    • Design and implement an admin dashboard displaying key metrics like AUM and relevant graphs.
  5. Live pnl and live positions for users

    • Develop real-time display of profit/loss and current positions for each user.
Serendipity2-0 commented 1 month ago

@amolkittur Closing this issue. Hope you have transferred all the remaining tasks to phase 2. Well done!