About March of this year (or thereabouts), I paid several hundred dollars to Saif and his crew as downpayment on a project. Unfortunately, that has never been delivered. Now that they are down and out, it seems it might never be completed, and I might be out a lot of money.
I'm reaching out to the community again to see if I can get someone to help develop an app incorporating the XChange library.
We would only need to develop it to work with one exchange--say, Binance, Kraken, or Coinbase--and it should then be applicable to all the exchanges. The library facilitates the same interface to all the exchange libraries, so once done, it is all done.
The nice thing with the XChange library is that all the APIs are already programmed and use a common interface. Program your app once, and all exchanges are available.
Otherwise, each exchange does its thing differently, and you'd have to customize your B4J codefor each exchange...
Hello.
Just for fun, had a look at it, since the subject interests me also. But the damn thing is huge. It will take months to do properly.
I was able to wrap a couple of the methods from the classes needed for the first example, "Get Bitcoin Ticker Data from Bitstamp" . Just look at the #AdditionalJars needed to make it run. But it does run, i get
#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#AdditionalJar: slf4j-simple-1.7.32
#AdditionalJar: slf4j-api-1.7.32
#AdditionalJar: rescu-2.0.2
#AdditionalJar: signpost-core-1.2.1.2.jar
#AdditionalJar: jsr305-3.0.2.jar
#AdditionalJar: javax.ws.rs-api-2.1.jar
#AdditionalJar: jackson-databind-2.9.1.jar
#AdditionalJar: jackson-core-2.9.1.jar
#AdditionalJar: jackson-annotations-2.9.0.jar
#AdditionalJar: commons-codec-1.3.jar
#AdditionalJar: guava-30.1.1-jre.jar
#AdditionalJar: resilience4j-all-1.7.0
#AdditionalJar: resilience4j-retry-1.7.0
#AdditionalJar: resilience4j-ratelimiter-1.7.0
#AdditionalJar: resilience4j-core-1.7.0.jar
#AdditionalJar: resilience4j-circuitbreaker-1.7.0.jar
#AdditionalJar: resilience4j-cache-1.7.0.jar
#AdditionalJar: resilience4j-bulkhead-1.7.0.jar
#AdditionalJar: vavr-match-0.10.2.jar
#AdditionalJar: vavr-0.10.2.jar
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private xui As XUI
Private Button1 As B4XView
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show
Dim bitStampExchange As xChange
Dim bitstamp As BitStamp
bitStampExchange.Initialize(bitstamp.name)
Dim dataService As MarketDataService
dataService = bitStampExchange.MarketDataService
Log(dataService.Ticker)
End Sub
You only have to complete the code for one exchange to have them all... supposedly. All exchanges use the same unified interface. We need to make the app somehow non-exchange-centric.
Hi. Yes, it's a b4j library.
Will play with it later tonight, since i have no idea what websocket/ticker data is.
But this will be "jar hell". Keeping all the jars updated will be a pain.
In the mean time, i'm looking at https://github.com/ccxt/ccxt , looks way better in terms of keeping the app updated.
Hello.
Just for fun, had a look at it, since the subject interests me also. But the damn thing is huge. It will take months to do properly.
I was able to wrap a couple of the methods from the classes needed for the first example, "Get Bitcoin Ticker Data from Bitstamp" . Just look at the #AdditionalJars needed to make it run. But it does run, i get
#Region Project Attributes
#MainFormWidth: 600
#MainFormHeight: 600
#AdditionalJar: slf4j-simple-1.7.32
#AdditionalJar: slf4j-api-1.7.32
#AdditionalJar: rescu-2.0.2
#AdditionalJar: signpost-core-1.2.1.2.jar
#AdditionalJar: jsr305-3.0.2.jar
#AdditionalJar: javax.ws.rs-api-2.1.jar
#AdditionalJar: jackson-databind-2.9.1.jar
#AdditionalJar: jackson-core-2.9.1.jar
#AdditionalJar: jackson-annotations-2.9.0.jar
#AdditionalJar: commons-codec-1.3.jar
#AdditionalJar: guava-30.1.1-jre.jar
#AdditionalJar: resilience4j-all-1.7.0
#AdditionalJar: resilience4j-retry-1.7.0
#AdditionalJar: resilience4j-ratelimiter-1.7.0
#AdditionalJar: resilience4j-core-1.7.0.jar
#AdditionalJar: resilience4j-circuitbreaker-1.7.0.jar
#AdditionalJar: resilience4j-cache-1.7.0.jar
#AdditionalJar: resilience4j-bulkhead-1.7.0.jar
#AdditionalJar: vavr-match-0.10.2.jar
#AdditionalJar: vavr-0.10.2.jar
#End Region
Sub Process_Globals
Private fx As JFX
Private MainForm As Form
Private xui As XUI
Private Button1 As B4XView
End Sub
Sub AppStart (Form1 As Form, Args() As String)
MainForm = Form1
MainForm.RootPane.LoadLayout("Layout1")
MainForm.Show
Dim bitStampExchange As xChange
Dim bitstamp As BitStamp
bitStampExchange.Initialize(bitstamp.name)
Dim dataService As MarketDataService
dataService = bitStampExchange.MarketDataService
Log(dataService.Ticker)
End Sub
I can now write this b4j code (not sure about the results, but looks good)
B4X:
Dim x As xChange
Dim exchangeList As List
Dim spec As ExchangeSpecification 'Ignore
exchangeList.Initialize
exchangeList.Add( x.Initialize(spec.EXCHANGE_BitStamp ))
exchangeList.Add( x.Initialize(spec.EXCHANGE_Poloinex ))
exchangeList.Add( x.Initialize(spec.EXCHANGE_Yobit ))
For Each exchange As xChange In exchangeList
Dim dataService As MarketDataService
Dim exchangeSpec As ExchangeSpecification
dataService = exchange.MarketDataService
exchangeSpec = exchange.ExchangeSpecification
Log("Exchange : " & exchangeSpec.ExchangeDescription)
Dim tick As Ticker
For Each coinPair As String In Array As String("BTC-USD", "ETH-USD", "LTC-EUR")
Try
tick=dataService.getTicker(coinPair)
Log(tick.Ask)
Log(tick.AskSize)
Log(tick.Bid)
Log(tick.BidSize)
Log(tick.CurrencyPair)
Log(tick.hashCode)
Log(tick.High)
Log(tick.Last)
Log(tick.Low)
Log(tick.Open)
Log(tick.PercentageChange)
Log(tick.QuoteVolume)
Log(tick.Timestamp)
Log(tick.Volume)
Log(tick.Vwap)
Log(tick.toString)
Catch
Log("Error : " & LastException.Message )
End Try
Next
Next
@ behnam_tr : Partial code done for one of the classes.
Java:
@ShortName("ExchangeSpecification")
public static class Exchangespecification extends AbsObjectWrapper<ExchangeSpecification> {
public final String EXCHANGE_BitStamp = "org.knowm.xchange.bitstamp.BitstampExchange";
public final String EXCHANGE_Poloinex = "org.knowm.xchange.poloniex.PoloniexExchange";
public final String EXCHANGE_Yobit = "org.knowm.xchange.yobit.YoBitExchange";
public final String EXCHANGE_OkCoin = "org.knowm.xchange.okcoin.OkCoinExchange";
public Exchangespecification initialize(String exchangeClassName) {
setObject( new ExchangeSpecification(exchangeClassName) );
return this;
}
public String getApiKey() {
return getObject().getApiKey();
}
public Exchangespecification setApiKey(String apiKey) {
getObject().setApiKey(apiKey);
return this;
}
public String getExchangeDescription() {
return getObject().getExchangeDescription();
}
public String getExchangeName() {
return getObject().getExchangeName();
}
public anywheresoftware.b4a.objects.collections.Map getExchangeSpecificParameters() {
anywheresoftware.b4a.objects.collections.Map m = new anywheresoftware.b4a.objects.collections.Map();
m.Initialize();
m.getObject().putAll(this.getObject().getExchangeSpecificParameters());
return m;
}
}