BitcoinChecker
DataModule for Bitcoin Checker android app
Install / Use
/learn @mobnetic/BitcoinCheckerREADME
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
<!-- START doctoc generated TOC please keep comment here to allow auto update --> <!-- DON'T EDIT THIS SECTION, INSTEAD RE-RUN doctoc TO UPDATE -->Table of Contents
- Introduction
- Updating currency pairs on existing exchange:
- Adding new exchange:
- Advanced things
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 putNAMEhere (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$sand%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:
- API example: https://www.bitstamp.net/api/ticker/
- URL field: https://www.bitstamp.net/api/ticker/
@Override
public String getUrl(int requestId, CheckerInfo checkerInfo) {
return URL;
}
Example with arguments - for given currency pair:
- API example: https://anxpro.com/main/stats?ccyPair=BTCUSD
- URL field: https://anxpro.com/main/stats?ccyPair=%1$s%2$s
@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:
- API example: https://bter.com/api/1/ticker/btc_cny
- URL field: https://bter.com/api/1/ticker/%1$s_%2$s
@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
