Skip to content
This repository has been archived by the owner on Feb 15, 2019. It is now read-only.

Commit

Permalink
Use coinbase spotrate rather than bitcoin average's spot rate
Browse files Browse the repository at this point in the history
  • Loading branch information
dessalines committed Oct 9, 2014
1 parent a8247a4 commit aa58925
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/main/java/com/bitpieces/shared/tools/CoinbaseTools.java
Expand Up @@ -8,6 +8,7 @@
import java.util.Map;
import java.util.Properties;

import org.joda.money.CurrencyUnit;
import org.joda.money.Money;

import com.bitpieces.shared.DataSources;
Expand Down Expand Up @@ -205,6 +206,9 @@ public static void deleteAccountNames(Coinbase cb, List<String> names) {

@Deprecated // because it costs to transfer between accounts, have to keep track of funds other ways
public static String createCoinbaseAccount(Coinbase cb, String userName) {



Account account = new Account();
account.setName(userName);

Expand Down
6 changes: 5 additions & 1 deletion src/main/java/com/bitpieces/shared/tools/UnitConverter.java
Expand Up @@ -45,6 +45,9 @@ public static String bitcoinAverageHistoricalCurrQuery(String ISO) {
public static String bitcoinCurrentCurrQuery(String ISO) {
return "https://api.bitcoinaverage.com/ticker/global/" + ISO + "/last" ;
}
public static String bitcoinCoinbaseCurrentCurrQuery(String ISO) {
return "https://api.coinbase.com/v1/prices/spot_rate?currency=" + ISO;
}


// The map of toCurrency, and the given currency service
Expand All @@ -60,7 +63,8 @@ public Map<DateTime, Double> load(String ISO) {
Map<DateTime, Double> rates = btcSpotRatesFromBtcAverageResponse(historyRes);

// Grab the most recent rate for today, and add it
String currentRes = Tools.httpGet(bitcoinCurrentCurrQuery(ISO));
// String currentRes = Tools.httpGet(bitcoinCurrentCurrQuery(ISO));
String currentRes = Tools.httpGet(bitcoinCoinbaseCurrentCurrQuery(ISO));
Entry<DateTime, Double> recentRate = getMostRecentConversionRateForToday(currentRes);

rates.put(recentRate.getKey(), recentRate.getValue());
Expand Down

0 comments on commit aa58925

Please sign in to comment.