Class TradeContext

    • Constructor Detail

      • TradeContext

        public TradeContext()
    • Method Detail

      • setOnOrderChange

        public void setOnOrderChange​(OrderChangedHandler handler)
        Set order changed event callback, after receiving the order changed event, it will call back to this handler.
        Parameters:
        handler - A order changed handler
      • subscribe

        public CompletableFuture<Void> subscribe​(TopicType[] topics)
                                          throws OpenApiException
        Subscribe
         
         import com.longportwhale.*;
         import com.longportwhale.trade.*;
         import java.math.BigDecimal;
         
         class Main {
             public static void main(String[] args) throws Exception {
                 try (Config config = Config.fromEnv(); TradeContext ctx = TradeContext.create(config).get()) {
                     ctx.setOnOrderChange((order_changed) -> {
                         System.out.println(order_changed);
                     });
                     ctx.subscribe(new TopicType[] { TopicType.Private }).get();
         
                     Thread.sleep(3000);
                 }
             }
         }
         
         
        Parameters:
        topics - Topics
        Returns:
        A Future representing the result of the operation
        Throws:
        OpenApiException - If an error occurs