"Price Spectre"
 All Data Structures Functions Pages
PS Class Reference

Public Member Functions

 performSearch ()
 
 getErrorMessage ()
 
 performSafeSearch ()
 
 performSelfSearch ()
 
 performSelfSafeSearch ()
 
 xLowestY ($x, $y)
 
 xLowestYPercent ($x, $y)
 
 averageX ($x)
 
 getMyAmazonPrice ()
 
 getCeilingPrice ()
 
 getFloorPrice ()
 
 getShippingHandling ()
 
 getSearchParameter ($key)
 
 setSearchParameter ($key, $value)
 
 getSiteCountry ()
 
 getResults ()
 
 getRealResults ()
 
 getNumResults ()
 
 getRealNumResults ()
 
 getRank ($price)
 
 getRealRank ($price)
 
 getNoCompetitionFound ()
 
 overrideNoCompetitionFound ()
 
 delete ($index)
 
 setPrice ($price)
 
 getCurrentPrice ()
 
 getLastPriceChangePrice ()
 
 getLastPriceChangeTime ()
 
 getSecondsSinceLastPriceChange ()
 
 getLastSaleTime ()
 
 getNumSales ($start=0, $end=2147483647)
 
 getNumSalesSince ($seconds)
 
 getData ()
 
 writeData ($str)
 
 getSecondsSinceStart ()
 
 getSecondsRemaining ()
 
 getQuantity ()
 
 getGoldBid ($currency, $unit)
 
 getGoldAsk ($currency, $unit)
 
 getSilverBid ($currency, $unit)
 
 getSilverAsk ($currency, $unit)
 

Detailed Description

A publicly available class that exposes Price Spectre functionality.

Member Function Documentation

averageX (   $x)

Performs pre-defined x Average algorithm.

Performs a search based on the current search parameters and then performs the "x Average" algorithm. Returns the total price based on "x Average".

Warning
This generates a new search and discards the results of any prior searches generated from PS::performSearch(), PS::xLowestY(), etc. or the one provided automatically by Price Spectre. This may result in usage of premium points.
Parameters
xSpecifies the number of search results to average.
Returns
The total price as computed by "x Average". Execution terminates on failure.
// Sets our price to y% lower than the average of the lowest X prices found.
price = ps.averageX(x) * (1 - y/100);
ps.setPrice(price);
delete (   $index)

Deletes a listing from the results set.

This function does not actually delete the listing but prevents Price Spectre from considering it in the final results (e.g. reporting, reprice history, etc.). Calling this function will affect the values returned by PS::getRealResults() and PS::getRealNumResults(). Calling this function also makes Listing::isDeleted() return TRUE.

This may be useful in situations where a search parameter is not sufficient to filter out a particular type of listing.

Warning
Since Price Spectre is limited to retrieving the first 100 matching results from eBay, search parameters should always be used as a filter instead whenever possible.
If all results are deleted Price Spectre will observe that no competitor listings were found. Deletion of a listing is not required to ignore it but may make the results easier to understand. Deletions are not carried over to subsequent searches.
Parameters
indexSpecifies which result to remove from the results set.
// Delete all non-new listings
results = ps.getResults();
numResults = ps.getNumResults();
for(i = 0; i < numResults; ++i)
{
// Delete if not new
if(results[i].getConditionID() != 1000)
{
ps.delete(i);
}
}
// Perform X lowest by $Y on remaining listings.
count = 0;
results = ps.getRealResults();
numResults = ps.getRealNumResults();
for(i = 0; i < numResults; ++i)
{
// if this is the listing to match against
count++;
if(count >= x)
{
ps.setPrice(results[i].getPrice() - y);
break;
}
}
getCeilingPrice ( )

Retrieves the total ceiling price of the seller's listing. This amount is inclusive of shipping charges unless shipping and handling charges are being ignored.

Returns
The total ceiling price.
getCurrentPrice ( )

Returns the current price of the listing.

Returns
The current price of the listing.
// Increases current price by 1%.
currentPrice = ps.getCurrentPrice();
ps.setPrice(currentPrice * 1.01);
getData ( )

Retrieves user data for the listing.

A string of up to 255 characters can be stored containing any user-defined data or state information.

Examples of possible data could be information regarding the current or past state of the listing or additional variables.

Returns
A string containing user data that has been saved for the listing. If no data has been stored then returns an empty string.
// Example of pulling 3 variables from data.
// Previously a string of three comma-separated
// values was stored in data.
// Example: 1,2,3
var data = ps.getData(); // fetches data
var arr = data.split(","); // create array
// assign each variable x, y, and z.
x = arr[0];
y = arr[1];
z = arr[2];
if(x < 1)
throw 'x must be positive';
if(y < 1)
throw 'y must be positive';
if(z < 1)
throw 'z must be positive';
getErrorMessage ( )

Returns error message for last call to PS::performSearch().

Returns
Error message string if error exists. If no error message exists returns empty string.
// Performs search and terminates with error message on failure.
if(!ps.performSearch())
throw ps.getErrorMessage();
getFloorPrice ( )

Retrieves the total floor price of the seller's listing. This amount is inclusive of shipping charges unless shipping and handling charges are being ignored.

Returns
The total floor price.
// Perform X lowest by $Y on listings.
floorPrice = ps.getFloorPrice();
count = 0;
results = ps.getResults();
numResults = ps.getNumResults();
for(i = 0; i < numResults; ++i)
{
// ignore this listing if it is below our floor price.
if(results[i].getPrice() < floorPrice)
{
continue;
}
// if this is the listing to match against
count++;
if(count >= x)
{
ps.setPrice(results[i].getPrice() - y);
break;
}
}
getGoldAsk (   $currency,
  $unit 
)

Retrieves the current ask price for gold bullion.

Parameters
currencySpecifies the currency to retrieve price in. Possible values: 'USD', 'GBP', 'EUR', 'AUD', 'CAD'
unitSpecifies the mass unit. Possible values: 'kg', 'g', 'gr', 'ozt', 'troy'
Returns
The current ask price for gold bullion per the unit mass specified.
// Sets our price to 5% higher than gold.
// X specifies the weight in grains we are selling.
price = ps.getGoldAsk('USD', 'gr') * x * 1.05;
ps.setPrice(price);
getGoldBid (   $currency,
  $unit 
)

Retrieves the current bid price for gold bullion.

Parameters
currencySpecifies the currency to retrieve price in. Possible values: 'USD', 'GBP', 'EUR', 'AUD', 'CAD'
unitSpecifies the mass unit. Possible values: 'kg', 'g', 'gr', 'ozt', 'troy'
Returns
The current bid price for gold bullion per the unit mass specified.
// Sets our price to 5% higher than gold.
// X specifies the weight in troy ounces we are selling.
price = ps.getGoldBid('USD', 'ozt') * x * 1.05;
ps.setPrice(price);
getLastPriceChangePrice ( )

Retrieves the last price that the listing was set to. This should be equal to PS::getCurrentPrice();

Returns
The last price that the listing was set to.
getLastPriceChangeTime ( )

Retrieves the epoch time of the last price change for the listing.

Returns
The epoch time of the last price change. If no price changes then returns the timestamp when Price Spectre first became aware of the listing.
// Reduce price by y% every x days.
now = Math.round(Date.now() / 1000);
secondsPerDay = 86400;
lastPriceChange = ps.getLastPriceChangeTime();
daysSinceChange = (now - lastPriceChange) / secondsPerDay;
currentPrice = ps.getCurrentPrice();
if(daysSinceChange >= x)
ps.setPrice(currentPrice * (1 - y/100));
getLastSaleTime ( )

Retrieves the epoch time of the last time a sale was made for the listing.

Returns
The epoch time of the last time a sale was made for the listing. If no sales are recorded then returns 0.
// Reduce price by y% if sale hasn't been made in x days and price
// hasn't changed in 7 days.
now = Math.round(Date.now() / 1000);
secondsPerDay = 86400;
secondsPerXDay = secondsPerDay * x;
secondsSincePriceChange = ps.getSecondsSinceLastPriceChange();
daysSinceChange = secondsSincePriceChange / secondsPerDay;
lastSaleTime = ps.getLastSaleTime();
daysSinceLastSale = (now - lastSaleTime) / secondsPerDay;
currentPrice = ps.getCurrentPrice();
if(daysSinceLastSale >= x && daysSinceChange >= secondsPerXDay)
ps.setPrice(currentPrice * (1 - y/100));
getMyAmazonPrice ( )

Checks Amazon for the seller's own Amazon price based on ASIN.

Performs an ASIN search against the seller's own Amazon account. If a product is found return its price. Otherwise, throw an exception. The ASIN is retrieved from the Product Code or Keywords search parameter. Useful for maintaining price parity.

Returns
The total price of product from the Amazon seller account. Exception thrown on failure.
Warning
Amazon does not permit searching against a specific Amazon competitor. In order for this function to work the seller must have provided Amazon MWS access to Price Spectre.
// Sync our eBay price to our Amazon price.
// If no Amazon listing found perform xLowestY instead
try {
price = ps.getMyAmazonPrice();
} catch (err) {
price = ps.xLowestY(x,y);
}
ps.setPrice(price);
getNoCompetitionFound ( )

Checks whether no competitors were found during last search performed.

Returns
Returns TRUE if no competitor listings were found. Returns FALSE if competitor listings were found.
// Set price to X lowest Y with x = 1, y = 0.01.
// But terminates with an error if no competitors were found.
price = ps.xLowestY(1, 0.01);
if(ps.getNoCompetitionFound())
{
throw 'No competitors found';
}
getNumResults ( )

Retrieves the number of competitor listings found. Deleted listings are included in the count.

Returns
The count of competitor listings found.
// Perform X lowest by $Y on listings.
count = 0;
results = ps.getResults();
numResults = ps.getNumResults();
for(i = 0; i < numResults; ++i)
{
// if this is the listing to match against
count++;
if(count >= x)
{
ps.setPrice(results[i].getPrice() - y);
break;
}
}
getNumSales (   $start = 0,
  $end = 2147483647 
)

Retrieves the quantity sold between two epoch times.

Parameters
startSpecifies the epoch time to begin counting sales. If not specified a default of 0 is used.
endSpecifies the epoch time to stop counting sales. If not specified a default of 2147483647 is used.
Returns
The quantity sold during the specified period of time.
// Reduce price by y% if x sales haven't been made in 7 days and price hasn't
// changed in 7 days.
now = Math.round(Date.now() / 1000);
secondsPerDay = 86400;
secondsPerWeek = secondsPerDay * 7;
secondsSincePriceChange = ps.getSecondsSinceLastPriceChange();
daysSinceChange = secondsSincePriceChange / secondsPerDay;
numSales = ps.getNumSales(now - secondsPerWeek);
currentPrice = ps.getCurrentPrice();
if(numSales < x && daysSinceChange >= 7)
ps.setPrice(currentPrice * (1 - y/100));
getNumSalesSince (   $seconds)

Retrieves the quantity sold during the past number of seconds.

Parameters
secondsSpecifies the number of seconds in the past to begin counting sales.
Returns
The quantity sold during the past number of seconds.
// Reduce price by y% if x sales haven't been made in 7 days and price
// hasn't changed in 7 days.
now = Math.round(Date.now() / 1000);
secondsPerDay = 86400;
secondsPerWeek = secondsPerDay * 7;
secondsSincePriceChange = ps.getSecondsSinceLastPriceChange();
daysSinceChange = secondsSincePriceChange / secondsPerDay;
numSales = ps.getNumSalesSince(secondsPerWeek);
currentPrice = ps.getCurrentPrice();
if(numSales < x && daysSinceChange >= 7)
ps.setPrice(currentPrice * (1 - y/100));
getQuantity ( )

Retrieves the quantity available of the listing.

Returns
The quantity available of the listing.
// Perform X Lowest By $Y algorithm
// But increases price 10x when only one remains.
quantity = ps.getQuantity();
if(quantity <= 1)
{
price = ps.getSearchParameter('binPrice') * 10;
}
else
{
price = ps.xLowestY(x, y);
}
ps.setPrice(price);
getRank (   $price)

Retrieves the rank achieved at a given price based on the competitors found.

Parameters
priceSpecifies the price to check rank against.
Returns
The rank at a given price. Returns 0 if no competitors were found.
// Sets our price 0.05 lower than the lowest price.
price = ps.xLowestY(1, 0.05);
rank = ps.getRank(price);
if(rank > 1)
throw 'FAILED: Could only achieve a ranking of ' + rank;
ps.setPrice(price);
getRealNumResults ( )

Retrieves the actual number of competitor listings found. Deleted listings are ignored in the count.

Returns
The count of competitor listings found excluding previously deleted listings.
// Delete all non-new listings
results = ps.getResults();
numResults = ps.getNumResults();
for(i = 0; i < numResults; ++i)
{
// delete if not new
if(results[i].getConditionID() != 1000)
{
ps.delete(i);
}
}
// Perform X lowest by $Y on remaining listings.
count = 0;
results = ps.getRealResults();
numResults = ps.getRealNumResults();
for(i = 0; i < numResults; ++i)
{
// if this is the listing to match against
count++;
if(count >= x)
{
ps.setPrice(results[i].getPrice() - y);
break;
}
}
getRealRank (   $price)

Retrieves the rank achieved at a given price based on the competitors found. Deleted listings are ignored in the count.

Parameters
priceSpecifies the price to check rank against.
Returns
The rank at a given price. Returns 0 if no competitors were found.
// Sets our price 0.05 lower than the lowest price.
price = ps.xLowestY(1, 0.05);
rank = ps.getRealRank(price);
if(rank > 1)
throw 'FAILED: Could only achieve a ranking of ' + rank;
ps.setPrice(price);
getRealResults ( )

Retrieves an array of class Listing representing the actual competitor listings found. Deleted listings are ignored.

Returns
Array of Listing objects.
// Delete all non-new listings
results = ps.getResults();
numResults = ps.getNumResults();
for(i = 0; i < numResults; ++i)
{
// Delete if not new
if(results[i].getConditionID() != 1000)
{
ps.delete(i);
}
}
// Perform X lowest by $Y on remaining listings.
count = 0;
results = ps.getRealResults();
numResults = ps.getRealNumResults();
for(i = 0; i < numResults; ++i)
{
// if this is the listing to match against
count++;
if(count >= x)
{
ps.setPrice(results[i].getPrice() - y);
break;
}
}
getResults ( )

Retrieves an array of class Listing representing the actual competitor listings found.

Returns
Array of Listing objects.
// Perform X lowest by $Y on listings.
count = 0;
results = ps.getResults();
numResults = ps.getNumResults();
for(i = 0; i < numResults; ++i)
{
// if this is the listing to match against
count++;
if(count >= x)
{
ps.setPrice(results[i].getPrice() - y);
break;
}
}
getSearchParameter (   $key)

Retrieves a specified search parameter.

Parameters
keySpecifies the search parameter to retrieve. Possible values: 'keywords', 'productCode', 'minFeedback', 'maxFeedback', 'minPrice', 'maxPrice', 'minQty', 'maxQty', 'maxHandlingTime', 'includeSellers', 'excludeSellers', 'exemptSellers', 'ebayFixedprice', 'ebayAuctions', 'findHalf', 'findAmazon', 'domestic', 'hideDuplicates', 'trs', 'returnsAccepted', 'restrictCategory', 'searchCategory', 'searchCondition', 'binPrice', 'floorPrice', 'ceilPrice', 'postalCodeUS', 'destination'
Returns
The current value of the search parameter.
// Retrieves the keywords specified for the listing.
keywords = ps.getSearchParameter('keywords');
getSecondsRemaining ( )

Retrieves the number of seconds before the listing will end.

Returns
The number of seconds that before the listing will end if it was listed on eBay. Returns 2147483647, otherwise.
results = ps.getResults();
numResults = ps.getNumResults();
secondsPerDay = 86400;
// Delete all results that will end in less than one day.
for(i = 0; i < numResults; ++i)
{
timeleft = results[i].getSecondsRemaining();
if(timeleft < secondsPerDay)
{
ps.delete(i);
}
}
getSecondsSinceLastPriceChange ( )

Retrieves the number of seconds since the last price change.

Returns
The number of seconds since the last price change.
// Reduce price by y% every x days.
secondsPerDay = 86400;
secondsSincePriceChange = ps.getSecondsSinceLastPriceChange();
daysSinceChange = secondsSincePriceChange / secondsPerDay;
currentPrice = ps.getCurrentPrice();
if(daysSinceChange >= x)
ps.setPrice(currentPrice * (1 - y/100));
getSecondsSinceStart ( )

Adds debug message. Append message to any previously debug messages.

If this is called at anytime during execution this will become an error message and may be reported the user.

Attention
This does not interrupt execution of the script but any price changes will be ignored. To immediately terminate execution of script with an error message use throw instead.
Parameters
messageDebug message that will be returned as an error once script ends.
// Perform X lowest by $Y on listings.
// if x is less than or equal to 0 generate an error but continue running.
if(x <= 0)
{
ps.debugMessage('Warning: Invalid value for x ' + x + '.');
}
count = 0;
results = ps.getResults();
numResults = ps.getNumResults();
for(i = 0; i < numResults; ++i)
{
// if this is the listing to match against
count++;
if(count >= x)
{
price = results[i].getPrice() - y;
// if we are trying to set a price of $0 or less generate warning but continue.
if(price <= 0)
{
item = results[i].getListingID();
ps.debugMessage('Warning: Price attempted set to ' + price + ' item = ' + item + '.');
continue;
}
ps.setPrice(price);
break;
}
}

Retrieves the number of seconds since the listing has started.

Returns
The number of seconds that have elapsed since the listing started if it was listed on eBay. Otherwise, returns 0.
results = ps.getResults();
numResults = ps.getNumResults();
secondsPerDay = 86400;
// Delete all results that have been listed less than one day.
for(i = 0; i < numResults; ++i)
{
age = results[i].getSecondsSinceStart();
if(age < secondsPerDay)
{
ps.delete(i);
}
}
getShippingHandling ( )

Retrieves the shipping and handling charges for the seller's listing.

Returns
The shipping and handling charges. If shipping and handling charges are being ignored then returns 0.
getSilverAsk (   $currency,
  $unit 
)

Retrieves the current ask price for silver bullion.

Parameters
currencySpecifies the currency to retrieve price in. Possible values: 'USD', 'GBP', 'EUR', 'AUD', 'CAD'
unitSpecifies the mass unit. Possible values: 'kg', 'g', 'gr', 'ozt', 'troy'
Returns
The current ask price for silver bullion per the unit mass specified.
// Sets our price to 5% higher than silver.
// X specifies the weight in kilograms we are selling.
price = ps.getSilverAsk('USD', 'kg') * x * 1.05;
ps.setPrice(price);
getSilverBid (   $currency,
  $unit 
)

Retrieves the current bid price for silver bullion.

Parameters
currencySpecifies the currency to retrieve price in. Possible values: 'USD', 'GBP', 'EUR', 'AUD', 'CAD'
unitSpecifies the mass unit. Possible values: 'kg', 'g', 'gr', 'ozt', 'troy'
Returns
The current bid price for silver bullion per the unit mass specified.
// Sets our price to 5% higher than silver.
// X specifies the weight in grams we are selling.
price = ps.getSilverBid('USD', 'g') * x * 1.05;
ps.setPrice(price);
getSiteCountry ( )

Retrieves the country associated with the eBay site the item was listed to.

Returns
Two-letter ISO 3166 country code to indicate the country of the eBay site where the item is listed (e.g., "US" for the eBay.com or "GB" for the eBay.co.uk).
results = ps.getResults();
numResults = ps.getNumResults();
myCountry = ps.getSiteCountry();
// Delete all international results.
for(i = 0; i < numResults; ++i)
{
theirCountry = results[i].getLocation();
if(myCountry != theirCountry)
{
ps.delete(i);
}
}
overrideNoCompetitionFound ( )

Tells Price Spectre to not apply its own logic during the "No competition found" situation.

By default Price Spectre will override any prices set if the last search performed results in no competitor listings being found. The price set can be configured via the "No competition found" behavior.

Make a call to this function if you wish to provide your own logic for handling this situation and prevent Price Spectre from applying its own. This can be called at any time.

// Set price to X lowest Y with x = 1, y = 0.01.
// But decrease price 5% if no results.
price = ps.xLowestY(1, 0.01);
if(ps.getNoCompetitionFound())
{
price = ps.getCurrentPrice() * 0.95;
}
ps.setPrice(price);
ps.overrideNoCompetitionFound();
performSafeSearch ( )

Performs a search based on the given search parameters.

This function differs from PS::performSearch() in that if a failure occurs execution of algorithm will immediately terminate with the appropriate error message.

After the search is performed make a call to PS::getResults() and PS::getNumResults() to retrieve the search results and number of results found.

Warning
This generates a new search and discards the results of any prior searches generated from PS::performSearch(), PS::xLowestY(), etc. or the one provided automatically by Price Spectre. This may result in usage of premium points.
Returns
TRUE on success. Execution terminates on failure.
performSearch ( )

Performs a search based on the given search parameters.

After the search is performed make a call to PS::getResults() and PS::getNumResults() to retrieve the search results and number of results found.

The user must make their own accommodations in the case that the search fails. See PS::performSafeSearch() for an identical function that doesn't have this requirement.

Warning
This generates a new search and discards the results of any prior searches generated from PS::performSearch(), PS::xLowestY(), etc. or the one provided automatically by Price Spectre. This may result in usage of premium points.
Returns
TRUE on success or FALSE on search failure. Make call to PS::getErrorMessage() to retrieve error messages.
// Performs search and terminates on failure.
if(!ps.performSearch())
throw ps.getErrorMessage();
performSelfSafeSearch ( )

Performs a self search on Amazon.

This function differs from PS::performSelfSearch() in that if a failure occurs execution of algorithm will immediately terminate with the appropriate error message.

After the search is performed make a call to PS::getResults() and PS::getNumResults() to retrieve the search results and number of results found.

Warning
This generates a new search and discards the results of any prior searches generated from PS::performSearch(), PS::xLowestY(), etc. or the one provided automatically by Price Spectre. This may result in usage of premium points.
Returns
TRUE on success. Execution terminates on failure.
// Sync our eBay price to our Amazon price.
ps.performSelfSafeSearch();
results = ps.getResults();
numResults = ps.getNumResults();
if(numResults >= 1)
{
price = results[0].getPrice();
ps.setPrice(price);
}
performSelfSearch ( )

Performs a self search on Amazon.

After the search is performed make a call to PS::getResults() and PS::getNumResults() to retrieve the search results and number of results found.

The user must make their own accommodations in the case that the search fails. See PS::performSelfSafeSearch() for an identical function that doesn't have this requirement.

Warning
This generates a new search and discards the results of any prior searches generated from PS::performSearch(), PS::xLowestY(), etc. or the one provided automatically by Price Spectre. This may result in usage of premium points.
Returns
TRUE on success or FALSE on search failure. Make call to PS::getErrorMessage() to retrieve error messages.
// Sync our eBay price to our Amazon price.
// Performs search and terminates on failure.
if(!ps.performSelfSearch())
throw ps.getErrorMessage();
results = ps.getResults();
numResults = ps.getNumResults();
if(numResults >= 1)
{
price = results[0].getPrice();
ps.setPrice(price);
}
setPrice (   $price)

Sets the total price of the listing.

If this function is not called within the algorithm the final price will remain at its current level.

Warning
The listing's final price may or may not be equal to the price specified. Once your algorithm finishes Price Spectre may perform additional changes to ensure the final price fits within the constraints of your floor and ceiling prices along with performing BaƄa pricing.

By default if no competitor listings are found with the last search performed then the final price would also be overridden based on "No competition found" behavior that was set. This can be avoided by making a call to PS::overrideNoCompetitionFound().

Parameters
priceSpecifies the total price to set the listing to.
Returns
The current price of the listing.
// Increases current price by 1%.
currentPrice = ps.getCurrentPrice();
ps.setPrice(currentPrice * 1.01);
setSearchParameter (   $key,
  $value 
)

Sets a specified search parameter.

Parameters
keySpecifies the search parameter to set. Possible values: 'keywords', 'productCode', 'minFeedback', 'maxFeedback', 'minPrice', 'maxPrice', 'minQty', 'maxQty', 'maxHandlingTime', 'includeSellers', 'excludeSellers', 'exemptSellers', 'ebayFixedprice', 'ebayAuctions', 'findHalf', 'findAmazon', 'domestic', 'hideDuplicates', 'trs', 'returnsAccepted', 'restrictCategory', 'searchCategory', 'searchCondition', 'binPrice', 'floorPrice', 'ceilPrice', 'postalCodeUS', 'destination'
valueSpecifies the new value for the search parameter.
Returns
FALSE on failure. TRUE on success.
// Disables TRS filter and retries search if no competition found.
price = ps.xLowestY(x,y);
// if no competitor listings found
if(ps.getNoCompetitionFound())
{
trs = ps.getSearchParameter('trs');
// if we had TRS set unset and make us 5th lowest price.
if(trs)
{
ps.setSearchParameter('trs', false);
price = ps.xLowestY(5, 0.01);
}
}
ps.setPrice(price);
writeData (   $str)

Writes user data to the database for the listing.

A string of up to 255 characters can be stored containing any user-defined data or state information.

Examples of possible data could be information regarding the current or past state of the listing or additional variables.

Parameters
strSpecifies a string to store as data for the listing.
Returns
TRUE on success or FALSE on failure.
// Example of writing an array to the database.
var arr = [1, 0.01, 3]; // our array which represents three variables.
var str = arr.toString(); // a string representation of that array.
ps.writeData(str); // write the data to the DB
xLowestY (   $x,
  $y 
)

Performs pre-defined "x lowest by $y" algorithm

Performs a search based on the current search parameters and then performs the "x lowest by $y" algorithm. Returns the total price based on "x lowest by $y".

Warning
This generates a new search and discards the results of any prior searches generated from PS::performSearch(), PS::xLowestY(), etc. or the one provided automatically by Price Spectre. This may result in usage of premium points.
Parameters
xSpecifies which search result to match against. ex: 1 matches against the lowest price, 2 matches against the second lowest price, etc.
ySpecifies the amount to discount the Xth lowest price. Positive values of Y result in pricing below the Xth lowest price. A zero value of Y results in matching the Xth lowest price. Negative values of Y result in pricing above the Xth lowest price.
Returns
The total price as computed by "x lowest by $y". Execution terminates on failure.
// Sets our price 0.05 lower than the lowest price.
price = ps.xLowestY(1, 0.05);
ps.setPrice(price);
xLowestYPercent (   $x,
  $y 
)

Performs pre-defined "x lowest y%" algorithm.

Performs a search based on the current search parameters and then performs the "x lowest y%" algorithm. Returns the total price based on "x lowest y%".

Warning
This generates a new search and discards the results of any prior searches generated from PS::performSearch(), PS::xLowestY(), etc. or the one provided automatically by Price Spectre. This may result in usage of premium points.
Parameters
xSpecifies which search result to match against. ex: 1 matches against the lowest price, 2 matches against the second lowest price, etc.
ySpecifies the percentage to discount the Xth lowest price. Positive values of Y result in pricing below the Xth lowest price. A zero value of Y results in matching the Xth lowest price. Negative values of Y result in pricing above the Xth lowest price.
Returns
The total price as computed by "x lowest y%". Execution terminates on failure.
// Sets our price 5% lower than the lowest price.
price = ps.xLowestYPercent(1, 5);
ps.setPrice(price);