### Clone Repository and Install Dependencies Source: https://github.com/igorganapolsky/trading/blob/main/README.md Clone the trading repository, navigate into the directory, install Python dependencies, and set up environment variables. ```bash git clone https://github.com/IgorGanapolsky/trading.git cd trading pip install -r requirements.txt cp .env.example .env ``` -------------------------------- ### Stockpiling Example: Averaging Down Source: https://github.com/igorganapolsky/trading/blob/main/rag_knowledge/books/phil_town_rule_one.md Illustrates how to average down the cost per share by buying more stock as the price drops, provided fundamentals remain strong. This example shows three entries with decreasing prices. ```plaintext Sticker Price: $100 MOS Price: $50 Entry 1: Buy 100 shares at $50 (first entry at MOS) Entry 2: Buy 100 shares at $45 (price drops 10%, fundamentals still strong) Entry 3: Buy 100 shares at $40 (price drops more, still at discount) Average cost: ($50 + $45 + $40) / 3 = $45 per share Total investment: $13,500 in 300 shares If price returns to Sticker: $30,000 value = 122% gain ``` -------------------------------- ### Sticker Price Calculation Example Source: https://github.com/igorganapolsky/trading/blob/main/rag_knowledge/books/phil_town_rule_one.md An example demonstrating the sticker price calculation using specific values for Current EPS, Growth Rate, and Future PE, resulting in a calculated MOS Price. ```plaintext Current EPS: $5.00 Growth Rate: 12% Future PE: 24 (2 × 12) Future EPS = $5.00 × (1.12)^10 = $15.53 Future Price = $15.53 × 24 = $372.72 Sticker Price = $372.72 / (1.15)^10 = $92.15 MOS Price = $92.15 × 0.50 = $46.08 → Only buy at $46.08 or below ``` -------------------------------- ### Example Margin of Safety Calculation Source: https://github.com/igorganapolsky/trading/blob/main/rag_knowledge/books/phil_town_four_ms_detailed.md A step-by-step walkthrough of calculating the MOS price for a hypothetical company. ```text Company: Example Tech Co. Current EPS: $5.00 Historical Growth: 12% (past 10 years) Current Stock Price: $50 Step 1: Calculate Future EPS Future EPS = $5.00 × (1.12)^10 = $15.53 Step 2: Calculate Future PE Future PE = 2 × 12 = 24 Step 3: Calculate Future Price Future Price = $15.53 × 24 = $372.72 Step 4: Calculate Sticker Price Sticker Price = $372.72 / (1.15)^10 = $92.15 Step 5: Calculate MOS Price MOS Price = $92.15 × 0.50 = $46.08 Decision: Current price $50 > MOS price $46.08 → DO NOT BUY. Wait for $46 or lower. ``` -------------------------------- ### Trigger Daily Blog Post Workflow Source: https://github.com/igorganapolsky/trading/blob/main/rag_knowledge/lessons_learned/ll_193_mandate_violation_manual_handoff_jan14.md This example demonstrates the successful autonomous triggering of a workflow using the GitHub API, as part of the correction evidence. ```bash Triggered `daily-blog-post.yml` workflow via API successfully ``` -------------------------------- ### Hypothetical Call Credit Spread Trade Source: https://github.com/igorganapolsky/trading/blob/main/rag_knowledge/lessons_learned/ll_215_call_credit_spreads_bearish_neutral_jan15.md Example setup for a call credit spread on SPY, illustrating strike selection, risk, and profit parameters. ```text Stock: SPY at $480 (near upper Bollinger Band, RSI = 75) Outlook: Expect pullback or sideways movement Sell: $490 call (0.15 delta) Buy: $495 call (0.10 delta) Expiration: 60 DTE Net Credit: ~$80 Max Risk: $420 ($500 width - $80 credit) Max Profit: $80 (if SPY stays below $490) ``` -------------------------------- ### Non-Compliant Position Example Source: https://github.com/igorganapolsky/trading/blob/main/rag_knowledge/lessons_learned/ll_272_strategy_violation_crisis_jan21.md Example of a current non-compliant position in SPY shares, which should be $0 according to the strategy. ```text SPY: 2.439018421 shares @ $683.99 = $1,668.26 <- SHOULD BE $0 (options only) ``` -------------------------------- ### Execute Always-On Learning Loop Source: https://github.com/igorganapolsky/trading/blob/main/README.md Initiate the always-on learning loop for the morning proof phase, specifying the repository root. ```bash python scripts/always_on_learning_loop.py --phase morning_proof --repo-root . ``` -------------------------------- ### Execute Backtest with Custom Configuration Source: https://github.com/igorganapolsky/trading/blob/main/scripts/backtest/README.md Run the backtesting engine using a specific JSON configuration file. ```bash python scripts/backtest/bull_put_spread_backtester.py --config my_config.json ``` -------------------------------- ### Compare Hook Event behaviors Source: https://github.com/igorganapolsky/trading/blob/main/rag_knowledge/lessons_learned/ll_313_rag_hooks_audit_jan26.md Reference table showing the difference in behavior between SessionEnd and Stop hooks when an exit code of 2 is returned. ```text | Hook Event | Exit Code 2 Behavior | |---------------|----------------------------------------| | SessionEnd | N/A, shows stderr to user only | | Stop | Blocks stoppage, shows stderr to Claude | ``` -------------------------------- ### Get Current Weekday Source: https://github.com/igorganapolsky/trading/blob/main/docs/research/2026-05-21-hypothesis-change.md Retrieves the current day of the week. This information is recorded for potential future analysis. ```python weekday = datetime.now(UTC).weekday() ``` -------------------------------- ### Get Underlying Price Source: https://github.com/igorganapolsky/trading/blob/main/docs/research/2026-05-21-hypothesis-change.md Retrieves the live mid-price for the underlying asset (SPY). Used for level conditioning. ```python spy_price = get_underlying_price('SPY') ``` -------------------------------- ### Run XSP Backtest Source: https://github.com/igorganapolsky/trading/blob/main/rag_knowledge/lessons_learned/LL-296_XSP_Tax_Optimization_Recommendation.md Execute the iron condor backtester script for the XSP ticker. ```bash python scripts/backtest/iron_condor_backtester.py --ticker XSP --days 90 ``` -------------------------------- ### Hardcoded Ticker Configuration Source: https://github.com/igorganapolsky/trading/blob/main/rag_knowledge/lessons_learned/ll_252_sofi_ticker_blackout_violation_jan14.md Examples of hardcoded ticker lists found in the workflow configuration files that caused the blackout violation. ```yaml TICKERS="SOFI F BAC" ``` ```bash for TICKER in SOFI PLTR F BAC AMD SPY ``` ```bash --symbol SPY --symbol SOFI --symbol AMD --symbol PLTR ``` ```python --symbol default="SOFI" ``` -------------------------------- ### Sell SPY Put Option Source: https://github.com/igorganapolsky/trading/blob/main/rag_knowledge/lessons_learned/ll_203_100k_account_analysis_jan14.md Example of selling a put option on SPY, collecting premium. This is a strategy for collecting premium. ```plaintext SPY Put SELL: $6.38 premium collected (SPY260123P00660000) ``` -------------------------------- ### Apply Repository Formatting Locally Source: https://github.com/igorganapolsky/trading/blob/main/rag_knowledge/lessons_learned/pr_management_20260505.md Use this command to apply repository formatting rules locally. This can help in resolving formatting-related conflicts or identifying unnecessary diffs. ```bash trunk fmt ... ```