Code Monkey home page Code Monkey logo

bitcoinchecker's Introduction

Bitcoin Checker

Bitcoin Checker is a FREE app to track the most recent prices of your favourite currency pairs (on over 80 supported exchanges) in many customizable ways (such as rich notifications, TTS voice announcements, Home and Lockscreen widget or multiple alarms).

As you know, the number of virtual currencies is increasing very fast. Currency pairs set on existing exchanges change almost every day and there is also a need to add newer and newer exchanges over time. We proudly announce that DataModule (containing exchanges and currency pairs) for Bitcoin Checker app is now OPEN for our users to make this application even better! This means that anyone can now:

  • Add support for a new exchange
  • Update currency pairs on their favourite exchange

Issues

Please submit all requests for new exchanges/currency pairs or bugs in Bitcoin Checker apps in the Issues section.

Bitcoin Checker on Google Play Store:

https://play.google.com/store/apps/details?id=com.mobnetic.coinguardian

Donate to Bitcoin Checker project:

BTC: 1KyLY5sT1Ffa6ctFPFpdL2bxhSAxNqfvMA

DOGE: D81kyZ49E132enb7ct7RcPGpjgsrN7bsd7

LTC: LZ3EiK42o5nbDW3cwiaKUptFQ9eBA3x1vw

Table of Contents

Introduction

To start working, you should fork this repo. It basically contains two projects:

  • DataModule: Library project that stores information about exchanges and currencies used in Bitcoin Checker. This is the project that you will work with.
  • DataModuleTester: Simple project that provides minimal interface in order to launch and test your changes - to see if they will work :)

The whole tutorial described below refers to the DataModule project because only this project is meant to be edited by users. After making your changes, please create a pull request to the original repo.

Updating currency pairs on existing exchange:

*Note if particular exchange supports dynamic currency pairs syncing mechanism there is NO need to add pairs manually here. *

To update currency pairs on your favourite exchange, you have to find the corresponding exchange class file in the com.mobnetic.coinguardian.model.market package. In every exchange file there is a CURRENCY_PAIRS HashMap that contains a base currency (as a key) and a list of counter currencies. Every combination of base and counter currency represents one currency pair.

CURRENCY_PAIRS.put(VirtualCurrency.LTC,  // Base currency
  new String[]{
    VirtualCurrency.BTC,             // Counter currency
    Currency.USD,                    // Counter currency
    Currency.RUR,                    // Counter currency
    Currency.EUR                     // Counter currency
  }
);

This example from BTC-e represents 4 pairs: LTC/BTC, LTC/USD, LTC/RUR and LTC/EUR.

Adding new pair on Cryptsy?

This is generally enough, but while adding a new currency pair on Cryptsy you also need to provide a special pair ID. Please include it in a map called CURRENCY_PAIRS_IDS, as shown here:

[...]
CURRENCY_PAIRS_IDS.put("DOGE_BTC", 132);
CURRENCY_PAIRS_IDS.put("DOGE_LTC", 135);
[...]

The simplest way to find the pair ID is to click or hover on that particular pair in the trading section on the Cryptsy website. The number at the end of the page url represents the ID of that particular pair: https://www.cryptsy.com/markets/view/132

Good practise:

Try to keep alphabetical order of base currencies (or even with counter currencies) but sometimes it's also good to mirror the order from the exchange site.

While adding new pairs, you should use currency names from these two classes:

  • Currency - where you can find fiat currencies
  • VirtualCurrency - where all of the crypto/virtual currencies are stored

Some currencies are missing?

You want to add some currency pairs but one currency (or both) is missing in Currency or VirtualCurrency class? Just add them to the Currency or VirtualCurrency class. Please put all fiat/normal currencies in the Currency.java file and all crypto/virtual currencies in VirtualCurrency.java.

Adding new exchange:

Example:

Please see the example of a class that represents a single exchange here - MarketExample

1. New exchange configuration:

To add support for a new exchange, you have to provide some constants describing that particular exchange:

  • NAME - name of the exchange that will be displayed in the app.
  • TTS_NAME - name of the exchange that will be used in spoken announements. Sometimes it's just fine to put NAME here (see Kraken), but sometimes it's better to provide a more spoken friendly version (like on McxNOW - "MCX now").
  • URL - this field stores the Url for the Ticker API. Most often it contains two parameters, but sometimes it has one (%1$s and %2$s). These parameters are replaced with currency names or the selected currency pair. Providing a URL is described in the next section.
  • CURRENCY_PAIRS - map of all currencies supported by this exchange - described later.

These constants (without URL) should be provided in the default constructor:

public MarketExample() {
  super(NAME, TTS_NAME, CURRENCY_PAIRS);
}

2. Providing currency pairs:

If given exchanges provides a mechanism to fetch currency pairs dynamically, there is no need to specify them manually then. Please see [this section](# 6-fetching-currency-pairs-directly-from-exchange).

Otherwise you have to specify which currency pairs are supported by your new exchange. Description for this is done above, in the [Updating currency pairs on existing exchange](https://github.com/mobnetic/BitcoinCheckerDataModule# updating-currency-pairs-on-existing-exchange) section.

3. Providing API Url:

The API Url is provided by the getUrl method. The simplest implementation is to just return the URL field. Sometimes, the Url requires some additional parameters (like currency names) - then you have to provide them using String.format() method. See examples below:

Example without parameters:
@Override
public String getUrl(int requestId, CheckerInfo checkerInfo) {
  return URL;
}
Example with arguments - for given currency pair:
@Override
public String getUrl(int requestId, CheckerInfo checkerInfo) {
  return String.format(URL, checkerInfo.getCurrencyBase(), checkerInfo.getCurrencyCounter());
}

Note that currency names are always in uppercase; however, some APIs requires them to be in lowercase.

Example with lowercase currency parameters:
@Override
public String getUrl(int requestId, CheckerInfo checkerInfo) {
  return String.format(URL, checkerInfo.getCurrencyBaseLowerCase(), checkerInfo.getCurrencyCounterLowerCase());
}

3a. Providing other parameters in URL (advanced):

Sometimes there is a need to include some kind of pair ID instead of just currency names. Please see Cryptsy as an example. There is a separate CURRENCY_PAIRS_IDS map that holds pair ids:

[...]
CURRENCY_PAIRS_IDS.put("DMD_BTC", 72);
CURRENCY_PAIRS_IDS.put("DOGE_BTC", 132);
CURRENCY_PAIRS_IDS.put("DOGE_LTC", 135);
CURRENCY_PAIRS_IDS.put("DVC_BTC", 40);
[...]

While providing the URL, we need to obtain the proper ID that is associated with this pair:

Example for DOGE/BTC (id=132) on Cryptsy:
@Override
public String getUrl(int requestId, CheckerInfo checkerInfo) {
  final String pairString = String.format("%1$s_%2$s", checkerInfo.getCurrencyBase(), checkerInfo.getCurrencyCounter());
  if(CURRENCY_PAIRS_IDS.containsKey(pairString))
    return String.format(URL, String.valueOf(CURRENCY_PAIRS_IDS.get(pairString)));
  return URL;
}

4. Parsing API response:

While parsing the response from the exchange you have to fill the fieds of Ticker object. If the API response is just in plain JSON object, you can parse it in the parseTickerFromJsonObject method:

@Override
protected void parseTickerFromJsonObject(int requestId, JSONObject jsonObject, Ticker ticker, CheckerInfo checkerRecord) throws Exception {
  ticker.bid = jsonObject.getDouble("bid");
  ticker.ask = jsonObject.getDouble("ask");
  ticker.vol = jsonObject.getDouble("volume");
  ticker.high = jsonObject.getDouble("high");
  ticker.low = jsonObject.getDouble("low");
  ticker.last = jsonObject.getDouble("last");
  ticker.timestamp = jsonObject.getLong("timestamp");
}

IMPORTANT: The ticker.last field is mandatory; the rest of the fields are optional. NOTE: Parsing the timestamp field (in millis) is not required. If omitted, Bitcoin Checker will fill it with now date. If you want to parse this information, please note that some exchanges provide time in different formats (like seconds or nanos) so you have to multiply or divide it to get the time in millis format. You can use TimeUtils.NANOS_IN_MILLIS or TimeUtils.MILLIS_IN_SECOND constants from TimeUtils for that.

4a. Parsing non JSONObject responses (advanced):

Sometimes responses are more complicated than plain JSON, then you should use the parseTicker method. The default implementation try to parse received response as a JSONObject, but you can parse also other formats by overriding this method:

protected void parseTicker(int requestId, String responseString, Ticker ticker, CheckerInfo checkerInfo) throws Exception {
  parseTickerFromJsonObject(requestId, new JSONObject(responseString), ticker, checkerInfo);
}

Here you can find examples of usage:

  • Huobi: "almost" JSON object response, there is a need to trim some characters at the begining and at the end of the response
  • MintPal: JSON array response (instead of JSON object)
  • McxNOW: XML based response

5. Parsing error (not required):

Sometimes an exchange is down but with some error message in their API (See Crypto-Trade as an example). You can also handle this situation and display an error message directly from the exchange to the user. There are two methods related with it and they are designed in a similar way to parsing a normal response:

protected String parseErrorFromJsonObject(int requestId, JSONObject jsonObject, CheckerInfo checkerInfo);

or if JSONObject is not suitable, you can override following method:

protected String parseError(int requestId, String responseString, CheckerInfo checkerInfo);

6. Fetching currency pairs directly from exchange:

If there is any API (or other way) to obtain currency pairs directly from exchange (without need to update them manually) you should implement currency pairs fetching functionality instead of providing a static set of currency pairs. See example on Basebit. Because there are no static currency pairs defined - you should pass a null as a last argument in the constructor and do NOT initialize CURRENCY_PAIRS at all. You need to provide the url to fetch currency pairs instead:

private final static String URL_CURRENCY_PAIRS = "http://pubapi.cryptsy.com/api.php?method=marketdatav2";

public SampleExchange() {
  super(NAME, TTS_NAME, null);  // <- null intead of CURRENCY_PAIRS map
}

[...]

@Override
public String getCurrencyPairsUrl(int requestId) {
  return URL_CURRENCY_PAIRS;
}

Then you need to do parsing in:

protected void parseCurrencyPairsFromJsonObject(int requestId, JSONObject jsonObject, List<CurrencyPairInfo> pairs)
or
protected void parseCurrencyPairs(int requestId, String responseString, List<CurrencyPairInfo> pairs)

While parsing currency pairs you need to create CurrencyPairInfo and add it to List<CurrencyPairInfo> pairs. The last argument pairId is a unique pair id used on some exchanges. You can just pass null if there is no such thing on given exchange.

You can also use multiple requests to fetch currency pairs from exchange - it is described in section [Multiple requests while fetching currency pairs](# multiple-requests-while-fetching-currency-pairs).

7. Enabling exchange:

To enable a newly created exchange, you should add the corresponding line at the bottom of MarketsConfig file:

static {
  [...]
  addMarket(new MyNewExchangeClass());
}

Advanced things

Multiple requests per exchange:

Some exchanges do not provide a nice ticker api with the all important information (bid, ask, vol, high, low, last), so there is a need to perform a few requests (for example 2) to acquire as much information as possible. These requests will be performed in a sequense and a new price notification will appear when all of these requests are finished. See the Poloniex exchange as a good example. In order to perform 2 requests you have to override getNumOfRequests method:

@Override
public int getNumOfRequests(CheckerInfo checkerRecord) {
  return 2;
}

Then make use of requestId variable passed to getUrl and parseTickerFromJsonObject methods. requestId variable is incremented from 0 to numOfRequests-1 for every new request made. From the first request, we are able to obtain only the last price. We want to obtain also the bid and ask values, so we do another request for the orders list:

@Override
public String getUrl(int requestId, CheckerInfo checkerInfo) {
  if(requestId==0)
    return URL;
  else
    return String.format(URL_ORDERS, checkerInfo.getCurrencyCounter(), checkerInfo.getCurrencyBase()); // Reversed currencies
}

@Override
protected void parseTickerFromJsonObject(int requestId, JSONObject jsonObject, Ticker ticker, CheckerInfo checkerInfo) throws Exception {
  if(requestId==0) {
    ticker.last = jsonObject.getDouble(checkerInfo.getCurrencyCounter()+"_"+checkerInfo.getCurrencyBase());  // Reversed currencies
  } else {
    ticker.bid = getFirstPriceFromOrder(jsonObject, "bids");
    ticker.ask = getFirstPriceFromOrder(jsonObject, "asks");
  }
}

Multiple requests while fetching currency pairs

You can also use multiple requests support for fetching currency pairs from exchange. The implementation is almost identical - just override following method:

@Override
public int getCurrencyPairsNumOfRequests() {
  return 2;
}

Then use the requestId argument in the same way as in previous section.

bitcoinchecker's People

Contributors

agusx1211 avatar akmamansoor avatar amaramrahul avatar anandvarkeyphilips avatar brandon-barker avatar bskim45 avatar d4rk5t4r avatar jondwillis avatar jpereira avatar kgeri avatar lionzeye avatar maciejciemiega avatar martynasbudvytis avatar matkwan avatar pabloolvcastro avatar pingu8007 avatar readonlyp avatar richyhbm avatar rpdiep avatar rtitlestad avatar saheedn avatar sharefm avatar sibijohn72 avatar snoopen avatar soysergiogomez avatar strml avatar toomyem avatar whalecalls-zz avatar xnaveira avatar xperimental avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

bitcoinchecker's Issues

Adding Bit2c.co.il exchange

Hi,
Can you please add this exchange?
Can I do it myself?
I am not a programmer, but I know a thing or wo about programming.
Oren

Nightly build of the app?

I thought I would be compile the full version of the app to keep track of the newest coins, but I see this project is just an adapter.

Doing a nightly push on the playstore is probably not feasible (and annoying for users), how about some private APK download URL on a nightly basis?

Bitfinex: Parsing Error

Hello. For at least 2 weeks I've only received a "Parsing Error" displayed for the BitFinex pricing. Any ideas? This is pretty important as it's my primary exchange. Thanks for your help and all the work you do!

Procentage change indicators

Typically in market price indicators you get also a procentage change in last 24 hours period. This is missing in Bitcoin checker both directly in app and in widget.

mintcoin donate

hello dev, can u give me pipeline with mintcoin as donation, i think it is a good coin, thank you very much!

[Request] Display prices that will trigger the alarm

Hello
First of all,Thanks for this awesome app..really helpful.
So I have a suggestion..I hope you agree with me on it...

In the alarm section.. When I choose the percent change condition,, It would be great to see what's the price is going to be after playing with the percentage, without using a calculator.

Hope you understood my idea. :)
Regards,

Bitfinex parsing error

Greetings!

Awesome work on the app. Tweeted @mobnetic recently regarding a "parsing error" returned when trying to check prices on Bitfinex. I'm using a GalaxyS4 - not sure if this is relevant. How can I help you help me? Please advise.

screenshot_2014-04-22-01-48-00

BitFinex parsing error

BitFinex integration is not working for me (any currency). It's written "Parsing error". This started about a month ago. I'm using the latest version from Google Play.

[request] Custom checker, smaller widget?

It would be nice to be able to define custom checkers, perhaps by combining existing checkers that have already been created?

An example to clarify what I mean:

Let's say I want to know the current value of DarkCoin in CAD $. But there are no exchanges that deal with DRK and CAD. So: I create checker _1 tracking DRK/BTC at Mintpal. Then I create checker *2 tracking BTC/CAD at VirtEx. Then my custom checker tracks *1/_2 which outputs an effective DRK/CAD value.

It would also be nice to have the option for a tiny (1x1 or 2x1) widget to display a single checker value.

I don't know if anyone else would find this useful. I may teach myself java just to do it myself.

Fix Bter API

They have moved API from http to https so it stopped working in app.

Bitcoin Venezuela's API VEF and ARS prices

Hello! I wanted you to know that http://btcReport.com the iOS app for Bitcoin prices will integrate VEF (Venezuelan Bolivar) and ARS (Argentine Peso) prices from BitcoinVenezuela.com for their new version. Also Electrum and Electrum-LTC (Litecoin fork) already have BTC and LTC real-time and historical prices taken from Bitcoin Venezuela's API.

http://api.bitcoinvenezuela.com

http://api.bitcoinvenezuela.com/historical

Documentation: https://github.com/btcven/api

Bitcoin Venezuela is an information site and market price reference for Venezuelan Bolívar and Argentine Peso. Created on October 11, 2012. Bitcoin Venezuela is the only site showing current and historical prices for Bitcoin, Litecoin and Mastercoin in the real market price that is traded inside the country due to the money control imposed by the governments.

Most of the pages and ticker/charts apps show VEF and ARS prices taken from CoinDesk or other APIs and that exchange rate shown is only available to the government and not the citizens due to the money control.

Hope you integrate this real exchange rate to bring more freedom on these complex places

http://motherboard.vice.com/blog/five-economies-that-could-actually-use-bitcoin?trk_source=homepage-lede

https://medium.com/p/6bb828a1bf2

Regards!

[REQUEST] Dodaj bitmarket.pl

Witam. Jeśli można prosić o dodanie tej giełdy to bym prosił ;). Mają API wiec nie będzie problemu. Jest to nowa giełda, ale sądząc po jakości wykonania, ekspresowych wpłatach i wypłatach, braku prowizji, coś czuję, że niedługo zyska sporą popularność. Mnie już tym "kupili" i żałuję że nie ma jej w Twoim programie. Pozdrawiam.

{feature request} universal fiat currency

Being able to display a single fiat currency (USD for example) for every BTC exchange would be a powerful enhancement for the margin trader. I would gladly pay for such a feature.

3 ideas/suggestions: volume related, and alarm improvement

Hey

I'm new to github, apologies if the 'issues' section isn't really the right place for suggestions like the ones below. I think I saw someone else suggested something similar, but here are 3 items I really would love to see:

  1. showing volume information in the widget (probably: volume of last hour)

  2. being able to set an alarm based on that volume information (I think that was the suggestion I already saw)

  3. Finding some "trick" to get a Bitcoinchecker alarm to use sound even when the phone is silent/on vibrate. Right now, if the alarm is triggered but the phone is silent, only the notification works, and LED warning and a short buzz. Not enough to wake you up. Somehow however, other apps (like Sleepasandroid for example) are able to set alarms that play, with sound, even when the phone is silent. I'm not an android developer, so I don't know how they do it, but I would wish Btcchecker could do something similar.

I'm aware, that's a lot of requests, and I read mobnetic already stated he doesn't have much time right now, but I was wondering if we could maybe set up a BTC/LTC/Doge "donation drive" that gives some extra incentive to put in the effort to implement a number of new features. Just a suggestion, and I know I'd put in a decent contribution myself if that helps.

Hability to lower TTS volume.

Sometimes it would be useful to lower the notifications volume independently from the rest of the phone applications.

Volume alerts

Would it be possible to have same alerts like for price but for volume?
In my case, I use volume to be alerted for LTC because price depends here a lot of whale, so they decide markets.
I'm a pay user. Thanks

Bter exchange Server error

Hi, i have a Problem. Bter exchange information except error. Exchange Server error. How is solve this Problem. Thanks.

Support for currency symbol placement (before/after price)

Hi,

I've noticed that the Bitcoin Checker App doesn't seem to pick up the correct currency culture info for ZAR, as it is placing the symbol at the end of the amount.

eg; it currently shows it as "7250 R" where it should be "R 7250"

I've had a quick look but it doesn't seem like this logic is contained within the DataModule, so i'm not sure if this is the correct place to log the issue?

Thanks
Brandon

Huobi LTC

It would be great to have LTC CNP on Huobi. Thanks!

Fetching currency pairs dynamically from some exchanges

Hello:)
I've written functionality to fetching currency pairs directly from exchanges.
Currently I've implemented it on Cryptsy to make an example how it should look like: https://github.com/mobnetic/BitcoinChecker/blob/master/DataModule/src/com/mobnetic/coinguardian/model/market/Cryptsy.java#L327

This feature will be published in version 1.0 (finally!) of Bitcoin Checker next week.
When implemented - there will be no need to track new pairs on some exchanges and adding them manually via making pull requests and updating whole app:)
But until then, there is a need to add this feature to more exchanges.
These of you who are willing to help me implement this feature on other exchanges are very welcome:) I've also updated DataModuleTester project to give you ability to test this feature.

Tutorial will be done tomorrow, but it is pretty straightforward (see attached example on Cryptsy):

  1. Override method getCurrencyPairsUrl (even simpler than getUrl)
  2. Implement parseCurrencyPairsFromJsonObject or parseCurrencyPairs methods. Parse array of pairs and adding them to List<CurrencyPairInfo> pairs by constructing new objects.
    new CurrencyPairInfo(String currencyBase, String currencyCounter, String currencyPairId)
    currencyPairId is used only on Cryptsy, so everywhere else it should be null:)

NOTE: Exchanges that provides some form of API to fetch currency pairs have higher priority now. On others we can try to parse regular websites to obtains currency pairs list.

Thanks:)

add mintpal

Turned into a huge exchange already with massive volume. Please can you support it?

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.