finance_quote 0.1.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 68

A Dart plugin for retrieving financial quote prices.

pub package Build Status

This package provides a set of high-level functions and classes that make it easy to retrieve financial quote information and prices for stocks (Amazon, Google, ...), commodities (Gold, Oil, ...) and crypto-currencies (Bitcoin, Ethereum, ...). It's platform-independent, supports iOS and Android.

Using #

The easiest way to use this library is via the top-level functions. They allow you to make quote price requests with minimal hassle:

  final Map<String, Map<String, String>> quotePrice =
      await FinanceQuote.getPrice(
          quoteProvider: QuoteProvider.yahoo, symbols: <String>['KO']);

  print('Number of quotes retrieved: ${quotePrice.keys.length}.');
  print('Number of attributes retrieved for KO: ${quotePrice['KO'].keys.length}.');
  print('Current market price for KO: ${quotePrice['KO']['price']}.');

If you're making multiple quote requests to the same server, you can request all of them in a single function call:

  final Map<String, Map<String, String>> quotePrice =
      await FinanceQuote.getPrice(
          quoteProvider: QuoteProvider.yahoo, symbols: <String>['KO', 'GOOG']);

  print('Number of quotes retrieved: ${quotePrice.keys.length}.');
  print('Number of attributes retrieved for KO: ${quotePrice['KO'].keys.length}.');
  print('Current market price for KO: ${quotePrice['KO']['price']}.');
  print('Number of attributes retrieved for GOOG : ${quotePrice['GOOG'].keys.length}.');
  print('Current market price for KO: ${quotePrice['GOOG']['price']}.');

If you want all available quote data from the selected provider, you can request it with the function call:

  final Map<String, Map<String, dynamic>> cryptoQuoteRaw =
      await FinanceQuote.getRawData(
          quoteProvider: QuoteProvider.coincap, symbols: <String>['bitcoin', 'ethereum']);

  print('Number of quotes retrieved: ${cryptoQuoteRaw.keys.length}.');
  print('Number of attributes retrieved for bitcoin : ${cryptoQuoteRaw['bitcoin'].keys.length}.');
  print('Current market price for bitcoin: ${cryptoQuoteRaw['bitcoin']['priceUsd']}.');
  print('Number of attributes retrieved for ethereum: ${cryptoQuoteRaw['ethereum'].keys.length}.');
  print('Current market price for ethereum: ${cryptoQuoteRaw['ethereum']['priceUsd']}.');

Supported providers #

  • Yahoo
  • Morningstar
  • Coinmarketcap
  • Coincap
  • Binance

TERMS & CONDITIONS

Quote information fetched through this module is bound by the quote providers terms and conditions.

[0.1.2] - 19/9/19

  • Refactor to allow parallel quote retrieval.

[0.1.1] - 4/9/19

  • Added binance support.

[0.1.0] - 3/9/19

  • Stabilize quote retrieval interfaces.

[0.0.1] - 2/9/19

  • Initial implementation of finance_quote plugin.

example/main.dart

import 'package:finance_quote/finance_quote.dart';

Future<void> main(List<String> arguments) async {
  final Map<String, Map<String, dynamic>> quoteRaw =
      await FinanceQuote.getRawData(
          quoteProvider: QuoteProvider.yahoo, symbols: <String>['KO', 'GOOG']);

  print('Number of quotes retrieved: ${quoteRaw.keys.length}.');
  print(
      'Number of attributes retrieved for KO: ${quoteRaw['KO'].keys.length}.');
  print(
      'Current market price for KO: ${quoteRaw['GOOG']['regularMarketPrice']}.');
  print(
      'Number of attributes retrieved for GOOG: ${quoteRaw['GOOG'].keys.length}.');
  print(
      'Current market price for KO: ${quoteRaw['GOOG']['regularMarketPrice']}.');

  final Map<String, Map<String, String>> quotePrice =
      await FinanceQuote.getPrice(
          quoteProvider: QuoteProvider.yahoo, symbols: <String>['KO', 'GOOG']);

  print('Number of quotes retrieved: ${quotePrice.keys.length}.');
  print(
      'Number of attributes retrieved for KO: ${quotePrice['KO'].keys.length}.');
  print('Current market price for KO: ${quotePrice['KO']['price']}.');
  print(
      'Number of attributes retrieved for GOOG: ${quotePrice['GOOG'].keys.length}.');
  print('Current market price for KO: ${quotePrice['GOOG']['price']}.');

  final Map<String, Map<String, dynamic>> cryptoQuoteRaw =
      await FinanceQuote.getRawData(
          quoteProvider: QuoteProvider.coincap,
          symbols: <String>['bitcoin', 'ethereum']);

  print('Number of quotes retrieved: ${cryptoQuoteRaw.keys.length}.');
  print(
      'Number of attributes retrieved for bitcoin: ${cryptoQuoteRaw['bitcoin'].keys.length}.');
  print(
      'Current market price for bitcoin: ${cryptoQuoteRaw['bitcoin']['priceUsd']}.');
  print(
      'Number of attributes retrieved for ethereum: ${cryptoQuoteRaw['ethereum'].keys.length}.');
  print(
      'Current market price for ethereum: ${cryptoQuoteRaw['ethereum']['priceUsd']}.');
}

Use this package as a library

1. Depend on it

Add this to your package's pubspec.yaml file:


dependencies:
  finance_quote: ^0.1.2

2. Install it

You can install packages from the command line:

with pub:


$ pub get

with Flutter:


$ flutter pub get

Alternatively, your editor might support pub get or flutter pub get. Check the docs for your editor to learn more.

3. Import it

Now in your Dart code, you can use:


import 'package:finance_quote/finance_quote.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
36
Health:
Code health derived from static analysis. [more]
100
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
68
Learn more about scoring.

We analyzed this package on Oct 9, 2019, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.5.1
  • pana: 0.12.21

Platforms

Detected platforms: Flutter, other

Primary library: package:finance_quote/finance_quote.dart with components: io.

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
html ^0.14.0+2 0.14.0+3
http ^0.12.0 0.12.0+2
intl ^0.16.0 0.16.0
logger ^0.7.0+2 0.7.0+2
meta ^1.1.7 1.1.7
Transitive dependencies
async 2.4.0
charcode 1.1.2
collection 1.14.12
csslib 0.16.1
http_parser 3.1.3
path 1.6.4
source_span 1.5.5
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
Dev dependencies
mockito ^4.1.0
pedantic ^1.8.0+1 1.8.0+1
test >=1.3.0 <1.6.8