flutter_multi_crypto_exchange 1.0.2

  • Readme
  • Changelog
  • Example
  • Installing
  • 49

Flutter Multi-Crypto Exchange #

Integrate cryprocurrency exchange platforms and convert them into the same standard format.

Exchange supported #

  • Bitkub.com
  • Satang.pro

Installation #

Add dependencies in pubspec.yaml

dependencies:
    flutter_multi_crypto_exchange: 1.0.1

Usage #

Import the package to your project.

import 'package:flutter_multi_crypto_exchange/multi_crypto_exchange.dart';

Create instance

var mc = MultiCryptoExchange();

This plugin will use external plugins of each platform. à¸şBitkub : flutter_bitkub_exchange Satang Pro : flutter_satang_pro_exchange

Initial your API Key for fetch the balances.

  //import 'package:flutter_bitkub_exchange/dao/api_key/bitkub_api_key.dart';
  //import 'package:flutter_satang_pro_exchange/dao/api_key/satang_pro_api_key.dart';

  // initial API key.
  mc.initSatang(
      userId: 1234,  // your user id.
      keyReading: SatangProApiKey(
          apiKey: "your key",
          secret: "your secret"));
  mc.initBitkub(
      keyReading: BitkubApiKey(
          apiKey: "your key",
          secret: "yoursecret"));

Get Market #

Get ticker from multi-markets, last price, percent change, volume, etc.

  // import 'package:flutter_multi_crypto_exchange/dao/multi_crypto_market_dao.dart';
  // import 'package:flutter_multi_crypto_exchange/manager/exchange_platform.dart';
  // import 'package:flutter_multi_crypto_exchange/dao/exchange_currency_market_dao.dart';

  MultiCryptoMarketDao market = await mc.getMultiMarkets();
  List<ExchangeCurrencyMarketDao> listMarketSatang = market.marketcap[ExchangePlatform.SATANG_PRO];
  List<ExchangeCurrencyMarketDao> listMarketBitkub = market.marketcap[ExchangePlatform.BITKUB];
  
  // Get information in Satang.
  for(var coin in listMarketSatang){
      // coin.percentChange;
      // coin.lastPrice;
      // coin.primaryCurrency;
      // coin.secondaryCurrency;
      // coin.avg24hr;
      // coin.baseVolume;
   }

Get portfolio #

Get portfolio from multi-exchanges.

  var portfolio = await mc.getPortfolio();

In Example, I have 0.0004 BTC , 193 THB , 116 XZC in Satang Pro. and 0.171 BTC , 4 THB , 4.61 ETH in Bitkub.

You will receive the remaining balance of each exchange. And combined into a portfolio. It also separates the amount of each exchange according to currency.

{
  "exchanges": {
    "satang": {
      "balance": [
        {
          "currency": "BTC",
          "order": 0.0,
          "available": 0.0004,
          "reserved": 0.0
        },
        {
          "currency": "THB",
          "order": 0.0,
          "available": 193.1086565347,
          "reserved": 0.0
        },
        {
          "currency": "XZC",
          "order": 0.0,
          "available": 116.06439389,
          "reserved": 0.0
        }
      ],
      "errorMessage": null
    },
    "bitkub": {
      "balance": [
        {
          "currency": "THB",
          "order": 0.0,
          "available": 4.49,
          "reserved": 30.0
        },
        {
          "currency": "BTC",
          "order": 0.0,
          "available": 0.17106842,
          "reserved": 0.0
        },
        {
          "currency": "ETH",
          "order": 0.0,
          "available": 4.61567764,
          "reserved": 0.01
        }
      ],
      "errorMessage": null
    }
  },
  "portfolio": [
    {
      "currency": "BTC",
      "order": 0.0,
      "available": 0.17146842,
      "reserved": 0.0,
      "balanceEachExchanges": {
        "satang": {
          "currency": "BTC",
          "order": 0.0,
          "available": 0.0004,
          "reserved": 0.0
        },
        "bitkub": {
          "currency": "BTC",
          "order": 0.0,
          "available": 0.17106842,
          "reserved": 0.0
        }
      }
    },
    {
      "currency": "THB",
      "order": 0.0,
      "available": 197.5986565347,
      "reserved": 30.0,
      "balanceEachExchanges": {
        "satang": {
          "currency": "THB",
          "order": 0.0,
          "available": 193.1086565347,
          "reserved": 0.0
        },
        "bitkub": {
          "currency": "THB",
          "order": 0.0,
          "available": 4.49,
          "reserved": 30.0
        }
      }
    },
    {
      "currency": "XZC",
      "order": 0.0,
      "available": 116.06439389,
      "reserved": 0.0,
      "balanceEachExchanges": {
        "satang": {
          "currency": "XZC",
          "order": 0.0,
          "available": 116.06439389,
          "reserved": 0.0
        }
      }
    },
    {
      "currency": "ETH",
      "order": 0.0,
      "available": 4.61567764,
      "reserved": 0.01,
      "balanceEachExchanges": {
        "bitkub": {
          "currency": "ETH",
          "order": 0.0,
          "available": 4.61567764,
          "reserved": 0.01
        }
      }
    }
  ]
}

1.0.2 #

Add total method to balance.

1.0.1 #

Fix bug Bitkub pair.

1.0.0 #

Support Satang Pro. Support Bitkub.

example/lib/main.dart

import 'package:flutter/material.dart';
import 'package:flutter_multi_crypto_exchange/multi_crypto_exchange.dart';
import 'package:flutter_multi_crypto_exchange/dao/crypto_portfolio_dao.dart';
import 'package:flutter_multi_crypto_exchange_example/my_utils.dart';
import 'package:flutter_bitkub_exchange/dao/api_key/bitkub_api_key.dart';
import 'package:flutter_satang_pro_exchange/dao/api_key/satang_pro_api_key.dart';

import 'package:flutter_multi_crypto_exchange/dao/multi_crypto_market_dao.dart';
import 'package:flutter_multi_crypto_exchange/manager/exchange_platform.dart';
import 'package:flutter_multi_crypto_exchange/dao/exchange_currency_market_dao.dart';

Future main() async {
  MultiCryptoExchange mc = MultiCryptoExchange();

  // initial API key.
  mc.initSatang(
      userId: 1234,  // your user id.
      keyReading: SatangProApiKey(
          apiKey: "...",
          secret: "..."));
  mc.initBitkub(
      keyReading: BitkubApiKey(
          apiKey: "...",
          secret: "..."));

  // build portfolio.
  CryptoPortfolioDao portfolio = await mc.getPortfolio();
  printPrettyJson(portfolio.toJson());

  // build multi-market.
  MultiCryptoMarketDao market = await mc.getMultiMarkets();
  List<ExchangeCurrencyMarketDao> listMarketSatang = market.marketcap[ExchangePlatform.SATANG_PRO];
  List<ExchangeCurrencyMarketDao> listMarketBitkub = market.marketcap[ExchangePlatform.BITKUB];
  for(var coin in listMarketSatang){
    // coin.percentChange;
    // coin.lastPrice;
    // coin.primaryCurrency;
    // coin.secondaryCurrency;
    // coin.avg24hr;
    // coin.baseVolume;
  }
  printPrettyJson(market.toJson());

  runApp(MyApp());
}

class MyApp extends StatefulWidget {
  @override
  _MyAppState createState() => _MyAppState();
}

class _MyAppState extends State<MyApp> {
  @override
  void initState() {
    super.initState();
  }

  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        body: Center(
          child: Text(
            'CRYPTO PORTFOLIO CORE',
            style: TextStyle(fontSize: 22),
          ),
        ),
      ),
    );
  }
}

Use this package as a library

1. Depend on it

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


dependencies:
  flutter_multi_crypto_exchange: ^1.0.2

2. Install it

You can install packages from the command line:

with Flutter:


$ flutter pub get

Alternatively, your editor might support 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:flutter_multi_crypto_exchange/dao/crypto_portfolio_dao.dart';
import 'package:flutter_multi_crypto_exchange/dao/crypto_portfolio_exchange_dao.dart';
import 'package:flutter_multi_crypto_exchange/dao/currency_balance_dao.dart';
import 'package:flutter_multi_crypto_exchange/dao/currency_balance_exchange_dao.dart';
import 'package:flutter_multi_crypto_exchange/dao/exchange_currency_market_dao.dart';
import 'package:flutter_multi_crypto_exchange/dao/exchange_dao.dart';
import 'package:flutter_multi_crypto_exchange/dao/exchange_meta_dao.dart';
import 'package:flutter_multi_crypto_exchange/dao/multi_crypto_market_dao.dart';
import 'package:flutter_multi_crypto_exchange/manager/bitkub_manager.dart';
import 'package:flutter_multi_crypto_exchange/manager/exchange_platform.dart';
import 'package:flutter_multi_crypto_exchange/manager/satang_manager.dart';
import 'package:flutter_multi_crypto_exchange/multi_crypto_exchange.dart';
  
Popularity:
Describes how popular the package is relative to other packages. [more]
0
Health:
Code health derived from static analysis. [more]
97
Maintenance:
Reflects how tidy and up-to-date the package is. [more]
100
Overall:
Weighted score of the above. [more]
49
Learn more about scoring.

We analyzed this package on May 24, 2020, and provided a score, details, and suggestions below. Analysis was completed with status completed using:

  • Dart: 2.8.1
  • pana: 0.13.8-dev
  • Flutter: 1.17.0

Health suggestions

Fix lib/dao/crypto_portfolio_exchange_dao.dart. (-1 points)

Analysis of lib/dao/crypto_portfolio_exchange_dao.dart reported 2 hints:

line 1 col 8: Unused import: 'package:flutter_multi_crypto_exchange/dao/exchange_dao.dart'.

line 2 col 8: Unused import: 'package:flutter_multi_crypto_exchange/manager/exchange_platform.dart'.

Fix lib/dao/crypto_portfolio_dao.dart. (-0.50 points)

Analysis of lib/dao/crypto_portfolio_dao.dart reported 1 hint:

line 1 col 8: Unused import: 'package:flutter_multi_crypto_exchange/dao/crypto_portfolio_exchange_dao.dart'.

Fix lib/dao/multi_crypto_market_dao.dart. (-0.50 points)

Analysis of lib/dao/multi_crypto_market_dao.dart reported 1 hint:

line 2 col 8: Unused import: 'package:flutter_satang_pro_exchange/dao/satang_pro_market_cap_currency_dao.dart'.

Fix additional 6 files with analysis or formatting issues. (-1.50 points)

Additional issues in the following files:

  • lib/manager/bitkub_manager.dart (1 hint)
  • lib/manager/satang_manager.dart (1 hint)
  • lib/multi_crypto_exchange.dart (1 hint)
  • lib/dao/currency_balance_exchange_dao.dart (Run flutter format to format lib/dao/currency_balance_exchange_dao.dart.)
  • lib/dao/exchange_meta_dao.dart (Run flutter format to format lib/dao/exchange_meta_dao.dart.)
  • lib/manager/exchange_platform.dart (Run flutter format to format lib/manager/exchange_platform.dart.)

Dependencies

Package Constraint Resolved Available
Direct dependencies
Dart SDK >=2.1.0 <3.0.0
flutter 0.0.0
flutter_bitkub_exchange ^1.0.1 1.0.1
flutter_satang_pro_exchange ^1.1.0 1.1.0
Transitive dependencies
charcode 1.1.3
collection 1.14.12
convert 2.1.1
crypto 2.1.5
http 0.12.1
http_parser 3.1.4
meta 1.1.8
path 1.7.0
pedantic 1.9.0
pointycastle 1.0.2
sky_engine 0.0.99
source_span 1.7.0
string_scanner 1.0.5
term_glyph 1.1.0
typed_data 1.1.6
vector_math 2.0.8
Dev dependencies
flutter_test