Skip to content

Commit 02e9e06

Browse files
authored
Chande Forecast Oscillator (CFO) indicator and strategy added. (#320)
# Describe Request Chande Forecast Oscillator (CFO) indicator and strategy added. # Change Type New indicator and strategy.
1 parent 7aca34b commit 02e9e06

File tree

24 files changed

+1216
-0
lines changed

24 files changed

+1216
-0
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,3 +26,5 @@ go.work
2626
# GoLand project
2727
.idea
2828

29+
# GitHub conductor
30+
conductor
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
# Track cfo_implementation_20260221 Context\n\n- [Specification](./spec.md)\n- [Implementation Plan](./plan.md)\n- [Metadata](./metadata.json)
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
{\n "track_id": "cfo_implementation_20260221",\n "type": "feature",\n "status": "new",\n "created_at": "2026-02-21T00:00:00Z",\n "updated_at": "2026-02-21T00:00:00Z",\n "description": "Implement Chande Forecast Oscillator (CFO) indicator and strategy"\n}
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# Implementation Plan: Chande Forecast Oscillator (CFO)
2+
3+
## Phase 1: Indicator Development
4+
- [x] Task: Write unit tests for CFO indicator (10f2bbd)
5+
- [x] Create `trend/cfo_test.go`
6+
- [x] Define test cases with CSV test data
7+
- [x] Task: Implement CFO indicator (4bdefbc)
8+
- [x] Create `trend/cfo.go`
9+
- [x] Implement linear regression forecast logic (reuse `helper` if possible)
10+
- [x] Implement CFO calculation using channels
11+
- [x] Task: Conductor - User Manual Verification 'Phase 1: Indicator Development' (Protocol in workflow.md) (4bdefbc)
12+
13+
## Phase 2: Strategy Development
14+
- [x] Task: Write unit tests for CFO strategy (4228b3f)
15+
- [x] Create `strategy/trend/cfo_strategy_test.go`
16+
- [x] Define test cases for buy/sell signals
17+
- [x] Task: Implement CFO strategy (990090d)
18+
- [x] Create `strategy/trend/cfo_strategy.go`
19+
- [x] Implement logic using CFO indicator
20+
- [x] Task: Conductor - User Manual Verification 'Phase 2: Strategy Development' (Protocol in workflow.md) (990090d)
21+
22+
## Phase 3: Integration and Backtesting
23+
- [x] Task: Register CFO in backtest tools (f13cc0d)
24+
- [x] Update `cmd/indicator-backtest` if necessary
25+
- [x] Task: Run backtest and verify results (f13cc0d)
26+
- [x] Use sample asset data to verify strategy performance
27+
- [x] Task: Conductor - User Manual Verification 'Phase 3: Integration and Backtesting' (Protocol in workflow.md) (f13cc0d)
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
# Specification: Chande Forecast Oscillator (CFO)
2+
3+
## Overview
4+
The Chande Forecast Oscillator (CFO) is a momentum indicator that measures the difference between a security's price and its linear regression forecast. It helps identify overbought or oversold conditions and potential trend reversals.
5+
6+
## Indicator Logic
7+
- **Calculation:** `CFO = ((Price - Forecast) / Price) * 100`
8+
- **Forecast:** Linear regression forecast for the current price based on a specified period.
9+
- **Period:** Number of data points used for the linear regression calculation.
10+
11+
## Strategy Logic
12+
- **Buy Signal:** CFO crosses above a specified threshold (e.g., 0).
13+
- **Sell Signal:** CFO crosses below a specified threshold (e.g., 0).
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# General Code Style Principles
2+
3+
This document outlines general coding principles that apply across all languages and frameworks used in this project.
4+
5+
## Readability
6+
- Code should be easy to read and understand by humans.
7+
- Avoid overly clever or obscure constructs.
8+
9+
## Consistency
10+
- Follow existing patterns in the codebase.
11+
- Maintain consistent formatting, naming, and structure.
12+
13+
## Simplicity
14+
- Prefer simple solutions over complex ones.
15+
- Break down complex problems into smaller, manageable parts.
16+
17+
## Maintainability
18+
- Write code that is easy to modify and extend.
19+
- Minimize dependencies and coupling.
20+
21+
## Documentation
22+
- Document *why* something is done, not just *what*.
23+
- Keep documentation up-to-date with code changes.

conductor/code_styleguides/go.md

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
# Effective Go Style Guide Summary
2+
3+
This document summarizes key rules and best practices from the official "Effective Go" guide for writing idiomatic Go code.
4+
5+
## 1. Formatting
6+
- **`gofmt`:** All Go code **must** be formatted with `gofmt` (or `go fmt`). This is a non-negotiable, automated standard.
7+
- **Indentation:** Use tabs for indentation (`gofmt` handles this).
8+
- **Line Length:** Go has no strict line length limit. Let `gofmt` handle line wrapping.
9+
10+
## 2. Naming
11+
- **`MixedCaps`:** Use `MixedCaps` or `mixedCaps` for multi-word names. Do not use underscores.
12+
- **Exported vs. Unexported:** Names starting with an uppercase letter are exported (public). Names starting with a lowercase letter are not exported (private).
13+
- **Package Names:** Short, concise, single-word, lowercase names.
14+
- **Getters:** Do not name getters with a `Get` prefix. A getter for a field named `owner` should be named `Owner()`.
15+
- **Interface Names:** One-method interfaces are named by the method name plus an `-er` suffix (e.g., `Reader`, `Writer`).
16+
17+
## 3. Control Structures
18+
- **`if`:** No parentheses around the condition. Braces are mandatory. Can include an initialization statement (e.g., `if err := file.Chmod(0664); err != nil`).
19+
- **`for`:** Go's only looping construct. Unifies `for` and `while`. Use `for...range` to iterate over slices, maps, strings, and channels.
20+
- **`switch`:** More general than in C. Cases do not fall through by default (use `fallthrough` explicitly). Can be used without an expression to function as a cleaner `if-else-if` chain.
21+
22+
## 4. Functions
23+
- **Multiple Returns:** Functions can return multiple values. This is the standard way to return a result and an error (e.g., `value, err`).
24+
- **Named Result Parameters:** Return parameters can be named. This can make code clearer and more concise.
25+
- **`defer`:** Schedules a function call to be run immediately before the function executing `defer` returns. Use it for cleanup tasks like closing files.
26+
27+
## 5. Data
28+
- **`new` vs. `make`:**
29+
- `new(T)`: Allocates memory for a new item of type `T`, zeroes it, and returns a pointer (`*T`).
30+
- `make(T, ...)`: Creates and initializes slices, maps, and channels only. Returns an initialized value of type `T` (not a pointer).
31+
- **Slices:** The preferred way to work with sequences. They are more flexible than arrays.
32+
- **Maps:** Use the "comma ok" idiom to check for the existence of a key: `value, ok := myMap[key]`.
33+
34+
## 6. Interfaces
35+
- **Implicit Implementation:** A type implements an interface by implementing its methods. No `implements` keyword is needed.
36+
- **Small Interfaces:** Prefer many small interfaces over one large one. The standard library is full of single-method interfaces (e.g., `io.Reader`).
37+
38+
## 7. Concurrency
39+
- **Share Memory By Communicating:** This is the core philosophy. Do not communicate by sharing memory; instead, share memory by communicating.
40+
- **Goroutines:** Lightweight, concurrently executing functions. Start one with the `go` keyword.
41+
- **Channels:** Typed conduits for communication between goroutines. Use `make` to create them.
42+
43+
## 8. Errors
44+
- **`error` type:** The built-in `error` interface is the standard way to handle errors.
45+
- **Explicit Error Handling:** Do not discard errors with the blank identifier (`_`). Check for errors explicitly.
46+
- **`panic`:** Reserved for truly exceptional, unrecoverable situations. Generally, libraries should not panic.
47+
48+
*Source: [Effective Go](https://go.dev/doc/effective_go)*
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# Google HTML/CSS Style Guide Summary
2+
3+
This document summarizes key rules and best practices from the Google HTML/CSS Style Guide.
4+
5+
## 1. General Rules
6+
- **Protocol:** Use HTTPS for all embedded resources.
7+
- **Indentation:** Indent by 2 spaces. Do not use tabs.
8+
- **Capitalization:** Use only lowercase for all code (element names, attributes, selectors, properties).
9+
- **Trailing Whitespace:** Remove all trailing whitespace.
10+
- **Encoding:** Use UTF-8 (without a BOM). Specify `<meta charset="utf-8">` in HTML.
11+
12+
## 2. HTML Style Rules
13+
- **Document Type:** Use `<!doctype html>`.
14+
- **HTML Validity:** Use valid HTML.
15+
- **Semantics:** Use HTML elements according to their intended purpose (e.g., use `<p>` for paragraphs, not for spacing).
16+
- **Multimedia Fallback:** Provide `alt` text for images and transcripts/captions for audio/video.
17+
- **Separation of Concerns:** Strictly separate structure (HTML), presentation (CSS), and behavior (JavaScript). Link to CSS and JS from external files.
18+
- **`type` Attributes:** Omit `type` attributes for stylesheets (`<link>`) and scripts (`<script>`).
19+
20+
## 3. HTML Formatting Rules
21+
- **General:** Use a new line for every block, list, or table element, and indent its children.
22+
- **Quotation Marks:** Use double quotation marks (`""`) for attribute values.
23+
24+
## 4. CSS Style Rules
25+
- **CSS Validity:** Use valid CSS.
26+
- **Class Naming:** Use meaningful, generic names. Separate words with a hyphen (`-`).
27+
- **Good:** `.video-player`, `.site-navigation`
28+
- **Bad:** `.vid`, `.red-text`
29+
- **ID Selectors:** Avoid using ID selectors for styling. Prefer class selectors.
30+
- **Shorthand Properties:** Use shorthand properties where possible (e.g., `padding`, `font`).
31+
- **`0` and Units:** Omit units for `0` values (e.g., `margin: 0;`).
32+
- **Leading `0`s:** Always include leading `0`s for decimal values (e.g., `font-size: 0.8em;`).
33+
- **Hexadecimal Notation:** Use 3-character hex notation where possible (e.g., `#fff`).
34+
- **`!important`:** Avoid using `!important`.
35+
36+
## 5. CSS Formatting Rules
37+
- **Declaration Order:** Alphabetize declarations within a rule.
38+
- **Indentation:** Indent all block content.
39+
- **Semicolons:** Use a semicolon after every declaration.
40+
- **Spacing:**
41+
- Use a space after a property name's colon (`font-weight: bold;`).
42+
- Use a space between the last selector and the opening brace (`.foo {`).
43+
- Start a new line for each selector and declaration.
44+
- **Rule Separation:** Separate rules with a new line.
45+
- **Quotation Marks:** Use single quotes (`''`) for attribute selectors and property values (e.g., `[type='text']`).
46+
47+
**BE CONSISTENT.** When editing code, match the existing style.
48+
49+
*Source: [Google HTML/CSS Style Guide](https://google.github.io/styleguide/htmlcssguide.html)*

conductor/index.md

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Project Context
2+
3+
## Definition
4+
- [Product Definition](./product.md)
5+
- [Product Guidelines](./product-guidelines.md)
6+
- [Tech Stack](./tech-stack.md)
7+
8+
## Workflow
9+
- [Workflow](./workflow.md)
10+
- [Code Style Guides](./code_styleguides/)
11+
12+
## Management
13+
- [Tracks Registry](./tracks.md)
14+
- [Tracks Directory](./tracks/)

conductor/product-guidelines.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Product Guidelines: Indicator
2+
3+
## Core Principles
4+
- **Reliability:** All financial calculations must be accurate and well-tested.
5+
- **Performance:** Indicators and strategies must be efficient, especially when processing large datasets.
6+
- **Maintainability:** Code should be modular, documented, and easy to extend.
7+
- **Transparency:** All algorithms and logic should be clear and well-documented.
8+
9+
## Prose & Documentation
10+
- **Clear & Concise:** Use simple language to explain complex financial concepts.
11+
- **Technical Accuracy:** Ensure all technical terms and financial formulas are used correctly.
12+
- **Consistent Terminology:** Use consistent naming conventions across the library and documentation.
13+
- **Comprehensive Examples:** Provide clear, working examples for all indicators and strategies.
14+
15+
## User Experience (API Design)
16+
- **Idiomatic Go:** Follow standard Go idioms and best practices for API design.
17+
- **Fluent APIs:** Prefer clear and intuitive interfaces for configuring indicators and strategies.
18+
- **Error Handling:** Provide descriptive error messages to help users diagnose issues.
19+
- **Configurability:** All indicators and strategies should be fully configurable with sensible defaults (if applicable).
20+
21+
## Testing & Quality
22+
- **High Coverage:** Target at least 90% code coverage for all indicators and strategies.
23+
- **Data-Driven Tests:** Use CSV-based test data for validating calculations.
24+
- **Regression Testing:** Ensure new changes don't break existing functionality.

0 commit comments

Comments
 (0)