question

jamespnarseh avatar image
1 Like"
jamespnarseh asked ·

Screen Securities in Java using JSON template

import com.intrinio.api.*; 
import com.intrinio.models.*; 
import com.intrinio.invoker.*; 
import com.intrinio.invoker.auth.*; 
import java.util.*; 
import org.threeten.bp.*; 
import java.math.BigDecimal; 

public class Main { 
  public static void main(String[] args) {

    ApiClient defaultClient = Configuration.getDefaultApiClient();
    ApiKeyAuth auth = (ApiKeyAuth) 
    defaultClient.getAuthentication("ApiKeyAuth"); 
      auth.setApiKey("API_KEY"); 
    SecurityApi securityApi = new SecurityApi();

    SecurityScreenGroup logic = new SecurityScreenGroup( //HOW DO I ADD CONDITION
      WITHIN THE THIS INSTANCE METHOD. ); 
    Boolean Operator= true; // SecurityScreenGroup | The logic to screen with, 
      conisting of operators, clauses, and nested groups. See screener 
      documentatin [see - /documentation/screener_v2] for details on how to 
      construct conditions. 
    String orderColumn = "orderColumn_example"; // String | Results returned sorted
      by this column 
    String orderDirection = "asc"; // String | Sort order to use with the 
      order_column
    Boolean primaryOnly = false; // Boolean | Return only primary securities 
    Integer pageSize = 100; // Integer | The number of results to return. Maximum 
      for this endpoint is 50000. 

    try { 
      List result = securityApi.screenSecurities(logic,Operator, orderColumn, 
        orderDirection, primaryOnly, pageSize); 
      System.out.println(result); 
    } 
    catch (ApiException e) { 
      System.err.println("Exception when calling SecurityApi#screenSecurities"); 
      e.printStackTrace(); 
    } 
  } 
}


apiscreenerjavajdk
10 |600 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

1 Answer

· Write an Answer
mkelly avatar image
0 Likes"
mkelly answered ·

Hi, the Intrinio endpoint documentation will point you to an explanation about how to set up the logic for your securities screener found here. This will provide you a general sample of how to create your logic parameter. The following is a working sample of the Java securities screener.

import java.util.List;
import com.intrinio.api.*;
import com.intrinio.invoker.*;
import com.intrinio.invoker.auth.*;
import com.intrinio.models.*;

public class Main {
  public static void main(String[] args) {

    ApiClient defaultClient = Configuration.getDefaultApiClient();
    ApiKeyAuth auth = (ApiKeyAuth) defaultClient.getAuthentication("ApiKeyAuth");
    auth.setApiKey("YOUR_API_KEY");

    SecurityApi securityApi = new SecurityApi();

      SecurityScreenGroup logic = new SecurityScreenGroup(); // SecurityScreenGroup | The logic to screen with, consisting of operators, clauses, and nested groups.<br/> See <a href=\"/documentation/screener_v2\" target=\"_blank\">screener documentation</a> for details on how to construct conditions.
      String orderColumn = null; // String | Results returned sorted by this column
      String orderDirection = "asc"; // String | Sort order to use with the order_column
      Boolean primaryOnly = false; // Boolean | Return only primary securities
      Integer pageSize = 100; // Integer | The number of results to return. Maximum for this endpoint is 50000.

      logic.setOperator("OR");

      SecurityScreenClause clause1 = new SecurityScreenClause();
      clause1.setField("totalcommonequity");
      clause1.setOperator(SecurityScreenClause.OperatorEnum.GT);
      clause1.setValue("100000000");
      logic.addClausesItem(clause1);

      SecurityScreenClause clause2 = new SecurityScreenClause();
      clause2.setField("next_earnings_year");
      clause2.setOperator(SecurityScreenClause.OperatorEnum.EQ);
      clause2.setValue("2017");
      logic.addClausesItem(clause2);

      try{
      List<SecurityScreenResult> result = securityApi.screenSecurities(logic, orderColumn, orderDirection, primaryOnly, pageSize);
        System.out.println(result);

    } catch (ApiException e) {
      System.err.println("Exception when calling SecurityApigetSecurityStockPrices");
      e.printStackTrace();
    }
  }

All that is needed is to set up your operators, clauses, and groups before making your API call. I hope that helps!

· Share
10 |600 characters needed characters left characters exceeded

Up to 8 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MiB each and 10.0 MiB total.