Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Bitpanda #866

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -148,5 +148,6 @@ private final static void addMarket(Market market) {
addMarket(new OmniTrade());
addMarket(new Coinome());
addMarket(new Nocks());
addMarket(new Bitpanda());
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
package com.mobnetic.coinguardian.model.market;


import java.util.Iterator;
import java.util.List;

import org.json.JSONObject;

import com.mobnetic.coinguardian.model.CheckerInfo;
import com.mobnetic.coinguardian.model.CurrencyPairInfo;
import com.mobnetic.coinguardian.model.Market;
import com.mobnetic.coinguardian.model.Ticker;


public class Bitpanda extends Market {

private final static String NAME = "Bitpanda";
private final static String TTS_NAME = NAME;
private final static String URL = "https://api.bitpanda.com/v1/ticker";



public Bitpanda() {
super(NAME, TTS_NAME, null);
}

@Override
public String getUrl(int requestId, CheckerInfo checkerInfo) {
return String.format(URL, checkerInfo.getCurrencyPairId());
}

@Override
protected void parseTickerFromJsonObject(int requestId, JSONObject jsonObject, Ticker ticker, CheckerInfo checkerInfo) throws Exception {

ticker.last = jsonObject.getJSONObject(checkerInfo.getCurrencyBase()).getDouble(checkerInfo.getCurrencyCounter());

}

// ====================
// Get currency pairs
// ====================
@Override
public String getCurrencyPairsUrl(int requestId) {
return URL;
}

@Override
protected void parseCurrencyPairsFromJsonObject(int requestId, JSONObject jsonObject, List<CurrencyPairInfo> pairs) throws Exception {

final Iterator<String> data = jsonObject.keys();

while(data.hasNext()) {
final String baseCurrency = data.next();
final Iterator<String> qouteCurrency = jsonObject.getJSONObject(baseCurrency).keys();

while(qouteCurrency.hasNext()) {
final String qoute = qouteCurrency.next();
pairs.add(new CurrencyPairInfo(
baseCurrency,
qoute,
baseCurrency+":"+qoute
));
}
}
}

}