Calculate account age using a time function

Updated at:

In Fraud Detection, account age is a key factor in assessing account quality. It is a dynamic value calculated in real time based on the registration time and the current time. This topic shows how to use a time function in the decision engine to dynamically calculate account age.

Create an event

  1. Create an event and add registration time and operation time fields.

image

Create a variable

  1. Go to Variable Center > Variables and click Add Variable.

image

  1. Configure the associated variable.

    1. Select the built-in function variable Get the number of days difference based on the timestamp in seconds.

    2. Select the associated event.

    3. Enter a name for the function variable.

    4. Configure the parameters for the function variable. Map the time1 parameter to the operateTime field and the time2 parameter to the regTime field.

image

Use the variable

  1. Go to the Policy Management page and click Create Policy.

  2. For the left variable, select the function variable you created. This variable calculates the difference in days between the current time and the registration time.

image

  1. Select an operator and enter a value for the right variable. For example, a condition of > 30 triggers the policy if the account is more than 30 days old.

  2. Define the output variable. In this example, this variable represents the account age in days.

image

Verification

  1. To verify the configured event, use the Fraud Detection API in OpenAPI Explorer. The following example shows a test request.

  2. Input parameters: {"eventCode":"de_example","regTime":"1642649703","operateTime":"1671507303"}

  3. Output parameter: The response returns a regTimeDif value of 334, indicating an account age of 334 days.

image