betfair-sports-api
Version:
Betfair Sports API for Node
61 lines (54 loc) • 2.92 kB
JavaScript
var newBetfairPrice = require('../lib/betfair_price.js').newBetfairPrice;
console.log("Betfair price extreme values:")
console.log('Price below 1.01 test: %s', newBetfairPrice(1.0).toString());
console.log('Price below above 1000 test: %s', newBetfairPrice(1001.0).toString());
console.log("Test rounding of betfair prices:")
console.log('Price 1.01-2.00 rounded to 0.01 %s', newBetfairPrice(1.1134567).toString());
console.log('Price 2.00-3.00 rounded to 0.02 %s', newBetfairPrice(2.2345678).toString());
console.log('Price 3.00-4.00 rounded to 0.05 %s', newBetfairPrice(3.2345678).toString());
console.log('Price 4.00-6.00 rounded to 0.1 %s', newBetfairPrice(4.1345678).toString());
console.log('Price 6.00-10.00 rounded to 0.2 %s', newBetfairPrice(7.2345678).toString());
console.log('Price 10.00-20.00 rounded to 0.5 %s', newBetfairPrice(11.678901).toString());
console.log('Price 20.00-30.00 rounded to 1 %s', newBetfairPrice(21.2345678).toString());
console.log('Price 30.00-50.00 rounded to 2 %s', newBetfairPrice(31.2345678).toString());
console.log('Price 50.00-100.00 rounded to 5 %s', newBetfairPrice(66.2345678).toString());
console.log('Price 100.00-1000.00 rounded to 10 %s', newBetfairPrice(123.2345678).toString());
console.log("Test spread:")
var price = newBetfairPrice(1.01);
console.log('Spread 1.01 to 1.01 is %s', price.spreadToPrice(1.01));
console.log('Spread 1.01 to 1.02 is %s', price.spreadToPrice(1.02));
console.log('Spread 1.01 to 1.10 is %s', price.spreadToPrice(1.10));
console.log('Spread 1.01 to 2.0 is %s', price.spreadToPrice(2.0));
console.log('Spread 1.01 to 1000 is %s', price.spreadToPrice(1000));
var price = newBetfairPrice(1000);
console.log('Spread 1000 to 1000 is %s', price.spreadToPrice(1000));
console.log('Spread 1000 to 990 is %s', price.spreadToPrice(990));
console.log('Spread 1000 to 500 is %s', price.spreadToPrice(500));
console.log('Spread 1000 to 1.02 is %s', price.spreadToPrice(1.02));
console.log('Spread 1000 to 1.01 is %s', price.spreadToPrice(1.01));
var price = newBetfairPrice(2.0);
console.log('Spread 2.0 to 2.0 is %s', price.spreadToPrice(2.0));
console.log('Spread 2.0 to 2.02 is %s', price.spreadToPrice(2.02));
console.log('Spread 2.0 to 1.99 is %s', price.spreadToPrice(1.99));
console.log('Spread 2.0 to 1.01 is %s', price.spreadToPrice(1.01));
console.log('Spread 2.0 to 1000 is %s', price.spreadToPrice(1000));
console.log("Test accending prices:")
var cnt = 0;
var price = newBetfairPrice(1.01);
while(true) {
console.log('index:%s price:%s',cnt,price.toString());
if(price.toString()==='1000.0')
break;
price.increasePrice();
++cnt;
}
console.log("Test decending prices:")
var cnt = 0;
var price = newBetfairPrice(1000.0);
while(true) {
console.log('index:%s price:%s',cnt,price.toString());
if(price.toString()==='1.01')
break;
price.decreasePrice();
++cnt;
}