# code-aarush/swingtradingalgorithm architecture

> Architecture diagram of the GitHub repository code-aarush/swingtradingalgorithm, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-08-13). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/code-aarush/swingtradingalgorithm
- Repository: https://github.com/code-aarush/swingtradingalgorithm

## Overview

#### Purpose and Entry Point
This is a standalone Python trading-strategy analysis repository, centered on `swingtrend_strategy.py`. It appears to run a SwingTrend-style strategy against NSE market-data CSV inputs and produce trade and equity-curve outputs.

#### Strategy Execution
`swingtrend_strategy.py` is the primary control point: it likely loads price data, applies signal/position rules, simulates trades, and calculates strategy performance. There is no visible package structure, service layer, API, or separate runtime entry point.

Paths:
- `swingtrend_strategy.py`

#### Market-Data Inputs
CSV files provide local, file-based datasets rather than an external market-data service. Multiple datasets suggest alternative sample sizes or scenarios can be selected when running the strategy.

Paths:
- `sample_nse_data.csv`
- `large_sample_nse_data.csv`
- `profitable_sample_data.csv`

#### Backtest / Trade Simulation Boundary
The key architectural boundary is between historical input data and generated simulation results. The strategy script should treat input CSVs as immutable historical observations and emit derived trade records and portfolio performance artifacts.

Paths:
- `swingtrend_strategy.py`
- `trades.csv`
- `equity_curve.csv`

#### Performance Outputs
`trades.csv` represents the transaction-level result set from strategy execution, while `equity_curve.csv` represents the time-series portfolio/value trajectory. These files are the primary integration surface for downstream analysis, reporting, or graph planning.

Paths:
- `trades.csv`
- `equity_curve.csv`

#### Runtime and Infrastructure
The repository is designed for a local Python runtime with filesystem access. No deployment infrastructure, database, message broker, web application, or external service integration is visible in the supplied tree. The operational workflow is therefore: choose/load a local NSE CSV, execute `swingtrend_strategy.py`, then consume the generated CSV outputs.

Main entry points: [`swingtrend_strategy.py`](https://github.com/code-aarush/swingtradingalgorithm/blob/main/swingtrend_strategy.py) (SwingTrend strategy), [`sample_nse_data.csv`](https://github.com/code-aarush/swingtradingalgorithm/blob/main/sample_nse_data.csv) (Sample NSE data), [`large_sample_nse_data.csv`](https://github.com/code-aarush/swingtradingalgorithm/blob/main/large_sample_nse_data.csv) (Large NSE data), [`profitable_sample_data.csv`](https://github.com/code-aarush/swingtradingalgorithm/blob/main/profitable_sample_data.csv) (Profitable sample data)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_inputs["Historical Market Data"]
  node_sample_data["Sample NSE data<br/>market-data CSV"]
  node_large_sample_data["Large NSE data<br/>market-data CSV"]
  node_profitable_sample_data["Profitable sample data<br/>market-data CSV"]
end

subgraph group_strategy["Strategy Execution"]
  node_strategy_entry["SwingTrend strategy<br/>Python entry point"]
  node_signal_rules["Signal and position rules<br/>strategy logic"]
  node_trade_simulation["Trade simulation<br/>backtest engine"]
  node_performance_calculation["Performance calculation<br/>portfolio accounting"]
end

subgraph group_outputs["Simulation Results"]
  node_trades_output["Trade records<br/>result CSV<br/>[trades.csv]"]
  node_equity_curve_output["Equity curve<br/>result CSV<br/>[equity_curve.csv]"]
end

node_sample_data -->|"selected input"| node_strategy_entry
node_large_sample_data -->|"selected input"| node_strategy_entry
node_profitable_sample_data -->|"selected input"| node_strategy_entry
node_strategy_entry -->|"historical prices"| node_signal_rules
node_signal_rules -->|"signals and positions"| node_trade_simulation
node_trade_simulation -->|"writes trades"| node_trades_output
node_trade_simulation -->|"executed positions"| node_performance_calculation
node_performance_calculation -->|"writes equity values"| node_equity_curve_output

click node_sample_data "https://github.com/code-aarush/swingtradingalgorithm/blob/main/sample_nse_data.csv"
click node_large_sample_data "https://github.com/code-aarush/swingtradingalgorithm/blob/main/large_sample_nse_data.csv"
click node_profitable_sample_data "https://github.com/code-aarush/swingtradingalgorithm/blob/main/profitable_sample_data.csv"
click node_strategy_entry "https://github.com/code-aarush/swingtradingalgorithm/blob/main/swingtrend_strategy.py"
click node_signal_rules "https://github.com/code-aarush/swingtradingalgorithm/blob/main/swingtrend_strategy.py"
click node_trade_simulation "https://github.com/code-aarush/swingtradingalgorithm/blob/main/swingtrend_strategy.py"
click node_performance_calculation "https://github.com/code-aarush/swingtradingalgorithm/blob/main/swingtrend_strategy.py"
click node_trades_output "https://github.com/code-aarush/swingtradingalgorithm/blob/main/trades.csv"
click node_equity_curve_output "https://github.com/code-aarush/swingtradingalgorithm/blob/main/equity_curve.csv"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_sample_data,node_large_sample_data,node_profitable_sample_data toneBlue
class node_strategy_entry,node_signal_rules,node_trade_simulation,node_performance_calculation toneAmber
class node_trades_output,node_equity_curve_output toneMint
```

## Components

### Historical Market Data

Selectable local NSE CSV datasets.

- [Sample NSE data](https://github.com/code-aarush/swingtradingalgorithm/blob/main/sample_nse_data.csv): market-data CSV · `sample_nse_data.csv`
- [Large NSE data](https://github.com/code-aarush/swingtradingalgorithm/blob/main/large_sample_nse_data.csv): market-data CSV · `large_sample_nse_data.csv`
- [Profitable sample data](https://github.com/code-aarush/swingtradingalgorithm/blob/main/profitable_sample_data.csv): market-data CSV · `profitable_sample_data.csv`

### Strategy Execution

Local Python backtest workflow.

- [SwingTrend strategy](https://github.com/code-aarush/swingtradingalgorithm/blob/main/swingtrend_strategy.py): Python entry point · Selects and loads a local historical dataset. · `swingtrend_strategy.py`
- [Signal and position rules](https://github.com/code-aarush/swingtradingalgorithm/blob/main/swingtrend_strategy.py): strategy logic · `swingtrend_strategy.py`
- [Trade simulation](https://github.com/code-aarush/swingtradingalgorithm/blob/main/swingtrend_strategy.py): backtest engine · Applies positions to historical prices and records trades. · `swingtrend_strategy.py`
- [Performance calculation](https://github.com/code-aarush/swingtradingalgorithm/blob/main/swingtrend_strategy.py): portfolio accounting · Builds the portfolio-value trajectory from simulated trades. · `swingtrend_strategy.py`

### Simulation Results

Generated CSV artifacts for downstream analysis.

- [Trade records](https://github.com/code-aarush/swingtradingalgorithm/blob/main/trades.csv): result CSV · Transaction-level simulation output. · `trades.csv`
- [Equity curve](https://github.com/code-aarush/swingtradingalgorithm/blob/main/equity_curve.csv): result CSV · Time-series portfolio value output. · `equity_curve.csv`

## Connections

- Sample NSE data → SwingTrend strategy: selected input
- Large NSE data → SwingTrend strategy: selected input
- Profitable sample data → SwingTrend strategy: selected input
- SwingTrend strategy → Signal and position rules: historical prices
- Signal and position rules → Trade simulation: signals and positions
- Trade simulation → Trade records: writes trades
- Trade simulation → Performance calculation: executed positions
- Performance calculation → Equity curve: writes equity values
