Serendipity2-0 / TradeManV1

0 stars 0 forks source link

Exe Engine Workflow Documentation #83

Closed amolkittur closed 6 days ago

amolkittur commented 3 weeks ago

Software Workflow Documentation

1. Morning Pre-market

1.1 Account Login and Access Token Update

1.2 Fund Validation

1.3 Market Info Parameters Update

1.4 Instrument Aggregator

1.5 ASM/GSM Instrument Aggregator

1.6 Equity Calculation

2. Strategies During Market

2.1 Strategy Execution

2.2 Strategy Behavior

2.3 Example: Expiry Trader Strategy

  1. Update market info parameters
  2. Execute at 9:18 AM
  3. Calculate:
    • ATM strike price
    • Option type (based on market info)
    • Stoploss
    • Hedge order
  4. Calculate stoploss price for main order
  5. Determine strike price, option type, and expiry for 3 orders
  6. Fetch exchange token from database
  7. Create order details for all orders
  8. Retrieve users opted for this strategy
  9. Place orders asynchronously
  10. Update Firebase with order details (order ID, tax, entry time, etc.)
  11. Send Discord notification for failed orders

3. EOD After Market

3.1 Order Sweeping

3.2 Tradebook Validator

3.3 Trade Logging

3.4 Ticker DB Script

3.5 EOD Reporting

amolkittur commented 3 weeks ago

Software Design Nomenclature

1. Brokers

2. Strategy Types

2.1 Place order and exit the script

  1. Execute script using Celery for required calculations:
    • Determine market status (bearish/bullish)
    • Analyze historic data
  2. Wait for entry time (declared in strategy entry params in database)
  3. Fetch exchange tokens for main order and hedge order (if applicable)
  4. Calculate stop-loss price based on main order LTP (if required)
  5. Prepare order details and send as a single list to place order function
  6. Record order ID and relevant information in Firebase

2.2 Continuously monitor the instrument

  1. Execute script using Celery for required calculations:
    • Determine market status (bearish/bullish)
    • Analyze historic data
  2. Obtain entry points for instrument monitoring
  3. Place orders when market reaches specified levels
  4. Add main order token to instrument monitor class with trigger points (if monitoring required)
  5. Record order ID and relevant information in Firebase

3. Post-Order Processing

  1. Validate orders from broker with Firebase records
  2. Fetch average price for each order
  3. Remove extra and failed orders (with empty average price) from database
  4. Calculate PnL, tax, and net PnL using entry and exit prices
  5. Store calculations in database
  6. Clear orders with both entry and exit
  7. Move holding orders to holdings database

4. Strategies

4.1 Place order and exit the script

4.2 Continuously monitor the instrument

amolkittur commented 6 days ago

Moved this entire document to docs folder in the project directory.