Class QTSurfer
Quick start
QTSurfer qts = QTSurfer.builder()
.baseUrl("https://api.qtsurfer.com/v1")
.token(System.getenv("JWT_API_TOKEN"))
.build();
// One-shot shortcut:
ResultMap result = qts.backtest(request, options).join();
// Or decomposed for streaming / reuse:
Strategy strategy = qts.compile(source).join();
Backtest job = strategy.backtest(request, options).join();
job.progress().subscribe( ... );
ResultMap result = job.await().join();
-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic AuthenticatedClientOverload that reads the API key fromQTSURFER_APIKEY.static AuthenticatedClientauthenticate(String apikey) One-call setup: exchange an API key for a short-lived JWT and return anAuthenticatedClientthat mirrors this SDK's surface (compile / backtest / exchanges / instruments / tickers / klines) with automatic refresh-on-401.static AuthenticatedClientauthenticate(String apikey, AuthOptions options) Overload accepting anAuthOptions(base URL, token store, executor).CompletableFuture<com.qtsurfer.api.client.model.ResultMap>backtest(BacktestRequest request) Run the full compile → prepare → execute → await pipeline as a single future.CompletableFuture<com.qtsurfer.api.client.model.ResultMap>backtest(BacktestRequest request, BacktestOptions options) Run the full compile → prepare → execute pipeline and resolve once the run reaches a terminal state (completed, failed, or canceled).static QTSurfer.Builderbuilder()Start building aQTSurferclient via the fluentQTSurfer.Builder.compile(BacktestRequest request) Convenience: compile the strategy embedded in the given request.compile(BacktestRequest request, BacktestOptions options) Convenience overload that compilesBacktestRequest.strategy()with the given options, ignoring every other field of the request.Compile a strategy source.compile(String source, BacktestOptions options) Compile strategy source into a reusableStrategyhandle.List<com.qtsurfer.api.client.model.Exchange>List available exchanges on the platform.List<com.qtsurfer.api.client.model.InstrumentDetail>instruments(String exchangeId) List instruments available on the given exchange, including per-data-type coverage (seeInstrumentDetail.getCoverage()) and market info.Download one hour of klines for an instrument as a streamingInputStream.Download one hour of klines for an instrument as a streamingInputStream, requesting the givenDownloadFormat.options()Configuration this client was built with.Download one hour of raw tickers for an instrument as a streamingInputStream.Download one hour of raw tickers for an instrument as a streamingInputStream, requesting the givenDownloadFormat.
-
Method Details
-
options
Configuration this client was built with. -
compile
Compile a strategy source. Resolves with aStrategyhandle you can reuse. -
compile
Compile strategy source into a reusableStrategyhandle.Issues a single synchronous HTTP request; the compile endpoint returns the
strategyIddirectly, so a failing compile surfaces immediately asQTSStrategyCompileErrorrather than on a later poll. A429means the platform was holding too many compilations and the source was never judged, so it is safe to retry; any other error status reflects a judgment on the submitted code and will not succeed by retrying alone.- Parameters:
options- tuning knobs; onlyonProgressis used here (a singleCOMPILINGevent) — polling and timeout settings do not apply to this stage
-
compile
Convenience: compile the strategy embedded in the given request. -
compile
Convenience overload that compilesBacktestRequest.strategy()with the given options, ignoring every other field of the request. Seecompile(String, BacktestOptions). -
backtest
Run the full compile → prepare → execute → await pipeline as a single future. Equivalent tocompile(request).thenCompose(s -> s.backtest(request, options)).thenCompose(Backtest::await). -
backtest
public CompletableFuture<com.qtsurfer.api.client.model.ResultMap> backtest(BacktestRequest request, BacktestOptions options) Run the full compile → prepare → execute pipeline and resolve once the run reaches a terminal state (completed, failed, or canceled). The returned future completes exceptionally withQTSStrategyCompileErrorif compilation fails,QTSPreparationErrorif data preparation fails,QTSExecutionErrorif execution fails, orQTSTimeoutErrorif a stage exceeds its configured timeout.- Parameters:
options- tuning knobs (poll interval, timeout, progress callback) applied to every stage of the pipeline
-
exchanges
List available exchanges on the platform.- Throws:
QTSError- on HTTP 4xx/5xx or transport failure
-
instruments
List instruments available on the given exchange, including per-data-type coverage (seeInstrumentDetail.getCoverage()) and market info.Unwraps the
InstrumentListResponseHAL envelope returned by the underlying API client and returns just the instrument list.- Parameters:
exchangeId- exchange identifier (e.g."binance")- Throws:
QTSError- on HTTP 4xx/5xx or transport failure
-
tickers
Download one hour of raw tickers for an instrument as a streamingInputStream. Defaults toDownloadFormat.LASTRA; passDownloadFormat.PARQUETfor on-the-fly Parquet conversion.The caller is responsible for closing the stream — typically via try-with-resources, piping to
Files.copy(...), or feeding it into a Lastra/Parquet reader.- Throws:
QTSDownloadError- on HTTP 4xx/5xx or transport failure
-
tickers
public InputStream tickers(String exchangeId, String base, String quote, String hour, DownloadFormat format) Download one hour of raw tickers for an instrument as a streamingInputStream, requesting the givenDownloadFormat. The 4-argument overload delegates here withDownloadFormat.LASTRA.- Throws:
QTSDownloadError- on HTTP 4xx/5xx or transport failure
-
klines
Download one hour of klines for an instrument as a streamingInputStream. Seetickers(java.lang.String, java.lang.String, java.lang.String, java.lang.String)for semantics.- Throws:
QTSDownloadError- on HTTP 4xx/5xx or transport failure
-
klines
public InputStream klines(String exchangeId, String base, String quote, String hour, DownloadFormat format) Download one hour of klines for an instrument as a streamingInputStream, requesting the givenDownloadFormat. Seetickers(String, String, String, String, DownloadFormat)for stream-closing semantics.- Throws:
QTSDownloadError- on HTTP 4xx/5xx or transport failure
-
authenticate
One-call setup: exchange an API key for a short-lived JWT and return anAuthenticatedClientthat mirrors this SDK's surface (compile / backtest / exchanges / instruments / tickers / klines) with automatic refresh-on-401.If
apikeyisnullor blank, the value is read from theQTSURFER_APIKEYenvironment variable.- Throws:
QTSAuthError- when no API key is available or the initial JWT exchange fails.
-
authenticate
Overload accepting anAuthOptions(base URL, token store, executor). -
authenticate
Overload that reads the API key fromQTSURFER_APIKEY. -
builder
Start building aQTSurferclient via the fluentQTSurfer.Builder.
-