updating historical value after post scan

This commit is contained in:
Manuel Simon Hirsig
2016-03-18 11:37:51 +01:00
parent 786e0f96d2
commit 11a0f8aa0f
2 changed files with 12 additions and 6 deletions
+3 -3
View File
@@ -88,7 +88,7 @@ function public.value(item_key)
local weighted_values = {}
local total_weight = 0
for _, data_point in item_record.data_points do
local weight = 0.95^Aux.round((data_point.time - item_record.data_points[1].time)/(60*60*24))
local weight = 0.95^Aux.round((data_point.time - item_record.data_points[1].time) / (60*60*24))
total_weight = total_weight + weight
tinsert(weighted_values, {value = data_point.market_value, weight = weight})
end
@@ -97,8 +97,8 @@ function public.value(item_key)
end
value = private.weighted_median(weighted_values)
-- not seen in the last week or not ignoring at least two high and low outliers
unreliable = item_record.data_points[1].time < time() - 60 * 60 * 24 * 7 or not weighted_values[2] or weighted_values[1].weight + weighted_values[2].weight >= 0.5
-- not seen at least 3 times in the last two weeks or not ignoring at least two high and low outliers
unreliable = not weighted_values[3] or item_record.data_points[3].time < time() - 60*60*24*7*2 or weighted_values[1].weight + weighted_values[2].weight >= 0.5
else
value = private.market_value(item_record)
unreliable = true
+9 -3
View File
@@ -799,6 +799,12 @@ function private.unit_vendor_price(item_key)
end
end
function private.update_historical_value_button()
local historical_value = Aux.history.value(selected_item.key)
private.historical_value_button.amount = historical_value
private.historical_value_button:SetText(Aux.money.to_string(historical_value or 0, true, nil, 3))
end
function private.set_item(item)
local settings = private.read_settings(item.key)
@@ -831,9 +837,7 @@ function private.set_item(item)
private.set_unit_start_price(settings.start_price)
private.set_unit_buyout_price(settings.buyout_price)
local historical_value = Aux.history.value(selected_item.key)
private.historical_value_button.amount = historical_value
private.historical_value_button:SetText(Aux.money.to_string(historical_value or 0, true, nil, 3))
private.update_historical_value_button()
if not existing_auctions[selected_item.key] then
private.refresh_entries()
@@ -935,11 +939,13 @@ function private.refresh_entries()
end,
on_abort = function()
existing_auctions[item_key] = nil
private.update_historical_value_button()
private.status_bar:update_status(100, 100)
private.status_bar:set_text('Done Scanning')
end,
on_complete = function()
existing_auctions[item_key] = existing_auctions[item_key] or {}
private.update_historical_value_button()
private.update_recommendation()
refresh = true
private.status_bar:update_status(100, 100)