Minor fixes
- Fixed bug: sell order placement not working. - log the current_rate - indicate when max price-up/down has reached.
This commit is contained in:
parent
d3b27348ee
commit
9feef5bfe9
@ -67,7 +67,7 @@ function addSellOrder(floID, quantity, min_price) {
|
||||
return reject(INVALID(`Invalid quantity (${quantity})`));
|
||||
else if (typeof min_price !== "number" || min_price <= 0)
|
||||
return reject(INVALID(`Invalid min_price (${min_price})`));
|
||||
checkSellRequirement().then(_ => {
|
||||
checkSellRequirement(floID).then(_ => {
|
||||
DB.query("SELECT SUM(quantity) AS total FROM Vault WHERE floID=?", [floID]).then(result => {
|
||||
let total = result.pop()["total"] || 0;
|
||||
if (total < quantity)
|
||||
@ -91,7 +91,7 @@ function checkSellRequirement(floID) {
|
||||
DB.query("SELECT * FROM Tags WHERE floID=? AND tag=?", [floID, "MINER"]).then(result => {
|
||||
if (result.length)
|
||||
return resolve(true);
|
||||
DB.query("SELECT SUM(quantity) AS brought FROM Transactions WHERE floID=?", [floID]).then(result => {
|
||||
DB.query("SELECT SUM(quantity) AS brought FROM Transactions WHERE buyer=?", [floID]).then(result => {
|
||||
if (result[0].brought >= MINIMUM_BUY_REQUIREMENT)
|
||||
resolve(true);
|
||||
else
|
||||
|
||||
@ -87,6 +87,7 @@ fetchRates.USD_INR = function() {
|
||||
function getRates() {
|
||||
return new Promise((resolve, reject) => {
|
||||
loadRate().then(_ => {
|
||||
console.debug(cur_rate);
|
||||
let cur_time = Date.now();
|
||||
if (cur_time - lastTime < MIN_TIME) //Minimum time to update not crossed: No update required
|
||||
resolve(cur_rate);
|
||||
@ -102,7 +103,8 @@ function getRates() {
|
||||
if (tmp_val >= ratePast24hr * (1 - MAX_DOWN_PER_DAY)) {
|
||||
cur_rate = tmp_val;
|
||||
updateLastTime();
|
||||
}
|
||||
} else
|
||||
console.debug("Max Price down for the day has reached");
|
||||
resolve(cur_rate);
|
||||
} else if (noSellOrder) {
|
||||
//No Sell, But Buy available: Increase the price
|
||||
@ -112,7 +114,8 @@ function getRates() {
|
||||
if (tmp_val <= ratePast24hr * (1 + MAX_UP_PER_DAY)) {
|
||||
cur_rate = tmp_val;
|
||||
updateLastTime();
|
||||
}
|
||||
} else
|
||||
console.debug("Max Price up for the day has reached");
|
||||
}
|
||||
}).catch(error => console.error(error)).finally(_ => resolve(cur_rate));
|
||||
}
|
||||
|
||||
Loading…
Reference in New Issue
Block a user