Price Spectre  1.0
Algorithm Editor

The algorithm editor consists of three components.

Script

This is where the pricing script is input. The script must be valid javascript code.

Algorithm Options

Name

Allows the user to specify a name of this algorithm.

Require Search Parameters

Allows the user to indicate whether search parameters (keywords or product code) are required.

Perform Search Automatically

Allows the user to specify whether a search is performed automatically at the start of the script without requiring a call to PS::performSearch() or PS::performSafeSearch().

If this is set, it counts towards the total search count for premium billing purposes.

If this is set, Require Search Parameters Require Search Parameters must be also checked.

X

Allows the user to define whether the variable x is defined in the algorithm along with its datatype.

Y

Allows the user to define whether the variable y is defined in the algorithm along with its datatype.

Description

Allows the user to specify a description for the algorithm.

Number of Searches

The calculated number of searches performed by the algorithm. This is calculated every time the algorithm is saved. If the number of searches exceeds 1 then premium points may be charged for using the algorithm. See your "Premium Points" page for details on billing.

Algorithm Simulator

The embedded search console allows the user to test their new algorithm against a live listing. The simulator uses the script as it is currently defined in the script section. It is not necessary to save the script between changes for them to take effect in the simulator.

Algorithm Simulator

Algorithm Parameters (x and y)

The custom algorithm editor allows the user to optionally enable two parameters, x and y. When enabled in the algorithm configuration screen, these values:

  • Are provided by the user in the UI
  • Are injected automatically into the JavaScript algorithm at runtime
  • Appear as ordinary global JavaScript numeric variables named x and y
  • Require no API calls (they are not returned by ps.getSearchParameter)
  • Can be used directly in expressions, comparisons, or arithmetic
  • Have the datatype selected by the user (integer or decimal)

Example usage inside an algorithm:

// Price ourselves y dollars below the x-th lowest competitor
var price = ps.xLowestY(x, y);
ps.setPrice(price);

These parameters are intended for user-configurable algorithm tuning such as timing thresholds, price offsets, discount percentages, or competitor depth controls. They are not part of the PS API class and do not appear under the method documentation.