ash_candle_chart_core 0.1.0-dev.1 copy "ash_candle_chart_core: ^0.1.0-dev.1" to clipboard
ash_candle_chart_core: ^0.1.0-dev.1 copied to clipboard

Core logic for Ash Candle Chart, including data structures and compute engine.

example/main.dart

import 'package:ash_candle_chart_core/ash_candle_chart_core.dart';
import 'package:ash_candle_chart_core/src/indicators/indicator_registry.dart';
import 'package:ash_candle_chart_core/src/indicators/sma.dart';

void main() async {
  // 1. Setup Data
  final candles = [
    Candle(
        timestamp: 1600000000000,
        open: 100,
        high: 110,
        low: 90,
        close: 105,
        volume: 1000),
    Candle(
        timestamp: 1600000060000,
        open: 105,
        high: 115,
        low: 100,
        close: 110,
        volume: 1200),
  ];
  final series = Series.fromCandles(candles);

  // 2. Initialize IsolatePool
  final pool = IsolatePool(workerCount: 1);

  // Use a top-level or static function for registry provider
  await pool.initialize(_dummyHandler, registryProvider: _createRegistry);

  // 3. Compute Indicators in background
  final configs = [
    const SMAConfig(id: 'sma20', period: 20),
  ];

  final results = await pool.computeIndicatorBatch(configs, series);
  // ignore: avoid_print
  print('Computed SMA: ${results['sma20']}');

  await pool.dispose();
}

Future<Object?> _dummyHandler(String method, Object? payload) async => null;

IndicatorRegistry _createRegistry() {
  final registry = IndicatorRegistry();
  registry.registerBuiltIns();
  return registry;
}
0
likes
0
points
38
downloads

Publisher

unverified uploader

Weekly Downloads

Core logic for Ash Candle Chart, including data structures and compute engine.

Homepage
Repository (GitHub)
View/report issues

License

unknown (license)

Dependencies

freezed_annotation, json_annotation, meta

More

Packages that depend on ash_candle_chart_core