Skip to content

Commit

Permalink
slightly refined buy/sell strat
Browse files Browse the repository at this point in the history
  • Loading branch information
suddjian committed Oct 15, 2023
1 parent db06091 commit c042ec6
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/cookieclickermanager.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ function adjustStockPortfolio() {
});
}

function analyzeStockMarket(percentile=0.2) {
function analyzeStockMarket(buyPercentile=0.1, sellPercentile=0.3) {
// buy low sell high
var goods = Object.values(StockMarket.goods).filter(good => !good.hidden);
if (goods.length < 3) {
Expand All @@ -153,9 +153,9 @@ function analyzeStockMarket(percentile=0.2) {
var minVal = allVals.reduce(
(running, val) => val < running ? val : running
);
var range = (maxVal - minVal) * percentile;
var buyAt = minVal + range;
var sellAt = maxVal - range;
var range = maxVal - minVal;
var buyAt = minVal + (range * buyPercentile);
var sellAt = maxVal - (range * sellPercentile);
var toBuy = goods.filter(
good => good.val < buyAt && good.stock < StockMarket.getGoodMaxStock(good)
);
Expand Down

0 comments on commit c042ec6

Please sign in to comment.