Giter VIP home page Giter VIP logo

alpha_vantage_package's Introduction

alpha_vantage_package

A new Flutter package for using alpha vantage api.

You will need your own API key from https://www.alphavantage.co/ (it's free) to use stocks other than MSFT

This was refactored and updated from the original source: https://github.com/jcmelend/flutter_alpha_vantage_api so credits to the maker.

For more information about how the JSON is layed out, visit https://www.alphavantage.co/documentation/

Getting Started

For help getting started with Flutter, view our online documentation.

For help on editing package code, view the documentation.

Usage

Add the following import statement where you need to use this package libraries: import 'package:alpha_vantage_package/alpha_vantage_package.dart';

There are four libraries to use to call Alpha Vantage rest api: TimeSeries.dart, SectorPerformances.dart, ForeignExchange.dart, CryptoCurrencies.dart, and TechnicalIndicators.dart.

Example:

import 'package:flutter_test/flutter_test.dart';

import 'package:flutter_alpha_vantage_package/alpha_vantage_package.dart';

void main() async {


  test('Intraday', () async {
    final timeSeries = new TimeSeries("YourAlphaVantageAPIKey");
    //get the hourly time series for Microsoft with to-the-minute updates. You can change this.
    JSONObject json = await timeSeries.getIntraday("MSFT");
    var data = json.getJSONMap()["Time Series (1min)"];

    //convert to map to get specific data like the amount during lcose
    var data2 = Map<String, dynamic>.from(data);
    data2.forEach((k,v) => print(v["4. close"]));

     //Use get method to search entire json for key for stock
    expect(json.get("2. Symbol"), "MSFT");

    // Use map to find stock symbol
    expect(json.getJSONMap()["Meta Data"]["2. Symbol"], "MSFT");
    print(json.getJSONMap());


  });

  test('Intraday', () async {
    final technicalIndicator = new TechnicalIndicators("YourAlphaVantageAPIKey");
    //get SMA for microsoft
    JSONObject json = await technicalIndicator.getSMA("MSFT");

    // Use get method to search entire json for key for stock
    expect(json.get("1: Symbol"), "MSFT");

    // Use map to find stock symbol
    expect(json.getJSONMap()["Meta Data"]["1: Symbol"], "MSFT");
    print(json.getJSONMap());
  });
}

alpha_vantage_package's People

Contributors

basilzuberi avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.