How octree/stockee works
Main Components
a. Library Core (Sources/Stockee):
• Core Functionality: Includes files in the “Core” directory with modules such as ChartRenderer, Configuration, QuoteProcessing, and other utilities that manage the rendering engine and data processing.
• Chart Renders: Divided into several subdirectories:
• Main Chart Renders (e.g., CandlestickChart, EMAChart, MAChart, SARChart, TimeShareChart, BOLLChart in the Main subdirectory).
• Sub Chart Renders (e.g., KDJChart, MACDChart, RSIChart, VolumeChart).
• Layers and Auxiliary Indicators: You see files in “ChartRenders/Auxiliary” and “ChartRenders/Layers” handling visual components such as grid indicators, price annotations, indicators’ views, etc.
• Indicator Algorithms: Contains implementations for various technical analysis algorithms (BollingerBands, ExponentialMovingAverage, MACDAlgorithm, etc.) found in the “IndicatorAlgorithm” directory. This component typically processes data inputs to compute values required by the renderers.
• Utilities and Extensions: Found in “Utils” and other helper modules, offering capabilities like binding, mathematical extensions, and patching.
b. View Layer:
• Chart Presentation and UI Composition: Located in “View” directory, which includes components for building the composite chart view (e.g., ChartView, ChartGroup, views for captions, interactions like tap or zoom, and selection indicators).
• Interaction Handlers: These files (in the “View/Interaction” subdirectory) capture user gestures such as long press, tap, or zoom actions that influence the chart’s presentation.
c. Demo / Example Usage:
• The “Demo/Playground” directory contains a sample Xcode project that demonstrates how to use Stockee’s components. This acts as an illustrative example of how the library is integrated into a SwiftUI-like workflow where developers set a chart descriptor using declarative syntax.
d. Testing:
• The “Tests” directory contains unit tests for various components (such as rendering, core processing, indicator algorithms, and utility functions) ensuring the reliability of the library.
Relationships and Interactions
• The Chart Renderer and Core Processing components (e.g., QuoteProcessing, Configuration, RendererContext) form the backbone that processes incoming data and prepares it for visualization.
• The Chart Renders are layered on top of the core to render different parts of the chart, organized into Main and Sub renders depending on their role (primary chart vs. supplementary indicators).
• Utility and algorithm components feed computed values into the renderers.
• The view components coordinate the final display by composing various chart groups, integrating both the visual layers and interaction handlers.
• The demo application shows how declarative syntax builds the chart by combining these components, and it often interacts with additional modules like WebSocket (for dynamic updates) – although that Websocket folder is only present in the demo’s playground for experimental purposes, its concept can be shown as an optional external data feed.
Architectural Patterns and Design Principles
• Modular Architecture: Each module (Core, Renderers, Algorithms, Views) is separated by responsibility, which encourages reusability and ease of testing.
• Declarative Syntax: The sample in the README hints at a SwiftUI-like approach where various components (like ChartGroup, GridIndicator, YAxisAnnotation, etc.) are declared to build the overall chart.
• Layered Architecture: The architecture is naturally divided into lower-level data processing and rendering layers, with higher-level interaction and view composition layers.
• Extensibility: The separation into auxiliary, main, and sub-components, along with support for extensions (as seen in the “Extensions” subdirectory), underlines an emphasis on customizable behavior.