sam41306061 / quant-project-rust

quant analysis project for Rust
0 stars 0 forks source link

Future Testing Outline: Order Selection , Purchase and Sale flow #2

Open sam41306061 opened 1 day ago

sam41306061 commented 1 day ago

Use Case: Run Forward-Tester for Bounce Bullish Strategy


Brief Description

This use case defines the forward-test function for the Bounce Bullish trading strategy. The forward tester simulates live market conditions to identify trades and determine the optimal options to purchase based on predefined entry and exit rules. Once trades are identified, a discretionary trader executes them. This system operates during market hours, running checks at regular intervals to evaluate trade opportunities and manage positions.


Flow of Events

Basic Flow

  1. The forward tester starts at 7:30 AM when the market opens.
  2. The system retrieves all saved strategies from the portfolio.
  3. The system inputs market data (price, volume, target contract data, time). It processes steps 4 and 5 for each strategy.
  4. Identify Buying Opportunities
    • Check for Bounce Bullish Entry conditions:
      • Strong Uptrend: Confirm higher highs and lows; validate with bullish EMA alignment (8 EMA > 21 EMA > 34 EMA > 55 EMA > 89 EMA).
      • Retracement: Ensure Stochastics %K (8,3) ≤ 40.
      • Proximity to Support: Price near support zones (8/21/34 EMA for strong trends; 50 SMA or horizontal/trendline support for weaker trends).
      • Filter out setups with abnormal gaps or bearish candles.
      • Ensure no earnings are within two weeks.
      • Validate historical profitability of similar setups.
      • Trigger Entry: Enter if the price closes above the high of the low bar or if RSI(2) > 10.
      • Option Entry: Buy call option with delta ~0.70 and at least one month to expiration (three months for Bounce 200 trades).
  5. Identify Selling Opportunities
    • Check if selling conditions are met, based on user-defined exit logic.
  6. Save relevant data:
    • Date, time, portfolio value.
    • Current positions, purchase prices, and real-time prices.
  7. At 2:00 PM, calculate the percent gain/loss for the day. Send an email with the results.

Buy Contract Flow

  1. Begin when the system identifies a valid Bounce Bullish entry.

  2. Check preconditions:

    • No existing InProgress order status.
    • Strategy does not exceed its maximum allocation.
    • Sufficient buying power is available. (at least 100 >= contracts)
    • User-defined buying conditions are met.
  3. Initiate a buy action:

    • Identify the type and quantity of contracts based on strategy parameters.
    • Generate a detailed trade recommendation, including:
      • Stock symbol, option type (e.g., call), strike price, delta, expiration date, and theoretical price.
      • Entry trigger details (e.g., price close above high of the low bar or RSI(2) > 10).
  4. Communicate Recommendation:

    • Send an email or dashboard alert with relevant information:
    • details of the recommended options trade
    • supporting data, such as proximity to support levels, EMA alignment, and historical profitability.
  5. Log the recommendation:


Sell Contract Flow

Here’s the modified Sell Contract Flow to reflect your desired outcome where the algorithm identifies sell opportunities but does not execute them:


Sell Contract Flow

  1. Begin when the system identifies valid selling conditions for a position.
  2. Check preconditions:
    • Ensure no existing InProgress order status.
    • Confirm sufficient days have passed since the last identified sale.
    • Validate that the strategy does not fall below its minimum allocation.
    • Verify that sufficient theoretical buying power is available to cover potential costs associated with the sale.
    • Confirm that user-defined selling conditions are met.
  3. Provide trade recommendation:
    • Identify the type and quantity of contracts to sell based on strategy parameters.
    • Generate a detailed sell recommendation, including:
      • Stock symbol, option type (e.g., call), strike price, expiration date, and current market price.
      • Specific trigger details (e.g., price target hit, RSI(2) crosses below a threshold, or trend reversal).
      • Risk considerations, such as abnormal market behavior or deviation from expected performance.
  4. Communicate recommendation:
    • Send an email or dashboard alert with all relevant information:
      • Details of the recommended sale (stock/contract, conditions met, and timing).
      • Supporting data, such as profit/loss for the position, current unrealized P/L, and recent performance metrics.
      • Current portfolio summary to provide overall context.
  5. Log the recommendation:
    • Save all sell recommendation details, including the time of identification and associated data, in the database for future review and performance tracking.
sam41306061 commented 1 day ago

Considerations for API structure to execute the above solutions:

  1. API to evaluate the specific Tickers to select
  2. use Yahn Financials API to pull in the specific options strike prices to get the most accurate selection.

API for ticker selection: API for options: https://rapidapi.com/apidojo/api/yahoo-finance1/playground/apiendpoint_b740bff0-ed23-4326-a419-0dfdefe96604