Package com.longbridge.dca
Class DcaContext
- java.lang.Object
-
- com.longbridge.dca.DcaContext
-
- All Implemented Interfaces:
AutoCloseable
public class DcaContext extends Object implements AutoCloseable
Dollar-cost averaging (DCA) plan management context.
-
-
Constructor Summary
Constructors Constructor Description DcaContext()
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description CompletableFuture<DcaCalcDateResult>calcDate(DcaCalcDateOptions opts)Calculate the next projected trade date for a DCA plan with the given schedule parameters.CompletableFuture<DcaSupportList>checkSupport(String[] symbols)Check DCA support for a batch of securities.voidclose()static DcaContextcreate(Config config)Create a DcaContext object.CompletableFuture<DcaCreateResult>createDca(DcaCreateOptions opts)Create a new DCA plan.CompletableFuture<DcaHistoryResponse>history(DcaHistoryOptions opts)Get execution history for a DCA plan.CompletableFuture<DcaList>list(DcaListOptions opts)List DCA plans, optionally filtered by status and/or symbol.CompletableFuture<Void>pause(String planId)Pause a DCA plan.CompletableFuture<Void>resume(String planId)Resume a suspended DCA plan.CompletableFuture<Void>setReminder(String hours)Update the advance reminder hours for DCA execution notifications.CompletableFuture<DcaStats>stats(String symbol)Get DCA statistics, optionally scoped to a single security.CompletableFuture<Void>stop(String planId)Stop (permanently finish) a DCA plan.CompletableFuture<DcaCreateResult>updateDca(DcaUpdateOptions opts)Update an existing DCA plan.
-
-
-
Method Detail
-
create
public static DcaContext create(Config config)
Create a DcaContext object.- Parameters:
config- Config object- Returns:
- A new DcaContext instance
-
close
public void close() throws Exception- Specified by:
closein interfaceAutoCloseable- Throws:
Exception
-
createDca
public CompletableFuture<DcaCreateResult> createDca(DcaCreateOptions opts) throws OpenApiException
Create a new DCA plan.- Parameters:
opts- Creation options (symbol, amount, frequency, etc.)- Returns:
- A Future resolving to the updated plan list
- Throws:
OpenApiException- If an error occurs
-
updateDca
public CompletableFuture<DcaCreateResult> updateDca(DcaUpdateOptions opts) throws OpenApiException
Update an existing DCA plan.- Parameters:
opts- Update options (planId, amount, frequency, etc.)- Returns:
- A Future resolving to the result containing the plan ID
- Throws:
OpenApiException- If an error occurs
-
list
public CompletableFuture<DcaList> list(DcaListOptions opts) throws OpenApiException
List DCA plans, optionally filtered by status and/or symbol.- Parameters:
opts- Query options (status, symbol)- Returns:
- A Future resolving to the list of DCA plans
- Throws:
OpenApiException- If an error occurs
-
stats
public CompletableFuture<DcaStats> stats(String symbol) throws OpenApiException
Get DCA statistics, optionally scoped to a single security.- Parameters:
symbol- Security symbol, ornullfor all securities- Returns:
- A Future resolving to DCA statistics
- Throws:
OpenApiException- If an error occurs
-
checkSupport
public CompletableFuture<DcaSupportList> checkSupport(String[] symbols) throws OpenApiException
Check DCA support for a batch of securities.- Parameters:
symbols- Array of security symbols to check- Returns:
- A Future resolving to the support status list
- Throws:
OpenApiException- If an error occurs
-
history
public CompletableFuture<DcaHistoryResponse> history(DcaHistoryOptions opts) throws OpenApiException
Get execution history for a DCA plan.- Parameters:
opts- Query options (planId, page, limit)- Returns:
- A Future resolving to the execution history
- Throws:
OpenApiException- If an error occurs
-
pause
public CompletableFuture<Void> pause(String planId) throws OpenApiException
Pause a DCA plan.- Parameters:
planId- ID of the plan to pause- Returns:
- A Future resolving to the updated plan list
- Throws:
OpenApiException- If an error occurs
-
resume
public CompletableFuture<Void> resume(String planId) throws OpenApiException
Resume a suspended DCA plan.- Parameters:
planId- ID of the plan to resume- Returns:
- A Future that completes when the plan is resumed
- Throws:
OpenApiException- If an error occurs
-
stop
public CompletableFuture<Void> stop(String planId) throws OpenApiException
Stop (permanently finish) a DCA plan.- Parameters:
planId- ID of the plan to stop- Returns:
- A Future that completes when the plan is stopped
- Throws:
OpenApiException- If an error occurs
-
calcDate
public CompletableFuture<DcaCalcDateResult> calcDate(DcaCalcDateOptions opts) throws OpenApiException
Calculate the next projected trade date for a DCA plan with the given schedule parameters.- Parameters:
opts- Calculation options (symbol, frequency, dayOfWeek, dayOfMonth)- Returns:
- A Future resolving to the calculated date result
- Throws:
OpenApiException- If an error occurs
-
setReminder
public CompletableFuture<Void> setReminder(String hours) throws OpenApiException
Update the advance reminder hours for DCA execution notifications.hoursmust be one of"1","6", or"12".- Parameters:
hours- Number of hours before execution to send the reminder- Returns:
- A Future that completes when the reminder setting is updated
- Throws:
OpenApiException- If an error occurs
-
-