new history almost done
This commit is contained in:
+1
-1
@@ -1,7 +1,7 @@
|
||||
## Interface: 11200
|
||||
## Title: Aux
|
||||
## Notes: A lightweight addon designed to help manage auctions
|
||||
## SavedVariablesPerCharacter: aux_recent_searches, aux_favorite_searches, aux_price_per_unit, aux_conservative_value, aux_scale
|
||||
## SavedVariablesPerCharacter: aux_recent_searches, aux_favorite_searches, aux_price_per_unit, aux_conservative_history, aux_scale
|
||||
## SavedVariables: aux_database, aux_auctionable_items
|
||||
|
||||
slash.lua
|
||||
|
||||
@@ -19,28 +19,25 @@ function Aux.on_load()
|
||||
local item_id, suffix_id = EnhTooltip.BreakLink(link)
|
||||
local item_key = (item_id or 0)..':'..(suffix_id or 0)
|
||||
|
||||
-- local auction_count, day_count, daily_market_value, median = Aux.history.price_data(item_key)
|
||||
local value = Aux.history.value(item_key)
|
||||
|
||||
-- if auction_count == 0 then
|
||||
-- EnhTooltip.AddLine('Never seen at auction', nil, true)
|
||||
-- EnhTooltip.LineColor(0.5, 0.8, 0.5)
|
||||
-- else
|
||||
-- EnhTooltip.AddLine('Seen '..auction_count..' '..Aux_PluralizeIf('time', auction_count)..' at auction', nil, true)
|
||||
-- EnhTooltip.LineColor(0.5, 0.8, 0.1)
|
||||
if value then
|
||||
local value_line = 'Value: '
|
||||
|
||||
local market_value = Aux.history.value(item_key)
|
||||
if market_value then
|
||||
local market_value_line = 'Value'..(aux_conservative_value and ' (Cons): ' or ': ')
|
||||
if count == 1 then
|
||||
market_value_line = market_value_line..Aux.money.to_string(market_value, nil, true, nil, '|cffffffff')
|
||||
else
|
||||
market_value_line = market_value_line..Aux.money.to_string(market_value * count, nil, true, nil, '|cffffffff')..' / '..Aux.money.to_string(market_value, nil, true, nil, '|cffffffff')
|
||||
end
|
||||
|
||||
EnhTooltip.AddLine(market_value_line, nil, true)
|
||||
EnhTooltip.LineColor(130/255,130/255,250/255)
|
||||
if count == 1 then
|
||||
value_line = value_line..EnhTooltip.GetTextGSC(value)
|
||||
else
|
||||
value_line = value_line..EnhTooltip.GetTextGSC(value * count)..' / '..EnhTooltip.GetTextGSC(value)
|
||||
end
|
||||
-- end
|
||||
|
||||
local _, _, _, market_values, max_bids = Aux.history.price_data()
|
||||
if getn(aux_conservative_history and max_bids or market_values) < 5 then
|
||||
value_line = value_line..' (?)'
|
||||
end
|
||||
|
||||
EnhTooltip.AddLine(value_line, nil, true)
|
||||
EnhTooltip.LineColor(0.1,0.8,0.5)
|
||||
end
|
||||
end)
|
||||
end
|
||||
|
||||
|
||||
+34
-67
@@ -22,8 +22,6 @@ function private.read_record(item_key)
|
||||
if data.item_records[item_key] then
|
||||
local fields = Aux.persistence.deserialize(data.item_records[item_key], '#')
|
||||
record = {
|
||||
-- auction_count = tonumber(record[1]),
|
||||
-- day_count = tonumber(record[2]),
|
||||
next_push = tonumber(fields[1]),
|
||||
daily_max_bid = tonumber(fields[2]),
|
||||
daily_min_buyout = tonumber(fields[3]),
|
||||
@@ -79,30 +77,49 @@ function public.process_auction(auction_info)
|
||||
private.write_record(auction_info.item_key, item_record)
|
||||
end
|
||||
|
||||
--function public.price_data(item_key)
|
||||
-- local item_record = private.read_record(item_key)
|
||||
-- return item_record.auction_count, item_record.day_count, private.daily_market_value(item_record.histogram), private.median(item_record.last_daily_values)
|
||||
--end
|
||||
function public.price_data(item_key)
|
||||
local item_record = private.read_record(item_key)
|
||||
return item_record.daily_max_bid, item_record.daily_min_buyout, item_record.daily_max_buyout, item_record.market_values, item_record.max_bids
|
||||
end
|
||||
|
||||
function public.value(item_key)
|
||||
function public.conservative_value(item_key)
|
||||
local item_record = private.read_record(item_key)
|
||||
|
||||
local past_market_values
|
||||
if aux_conservative_value then
|
||||
past_market_values = item_record.max_bids
|
||||
if getn(item_record.max_bids) > 0 then
|
||||
return private.median(item_record.max_bids)
|
||||
else
|
||||
past_market_values = item_record.market_values
|
||||
end
|
||||
|
||||
if getn(past_market_values) > 0 then
|
||||
return private.median(past_market_values)
|
||||
elseif aux_conservative_value then
|
||||
return item_record.daily_max_bid
|
||||
end
|
||||
end
|
||||
|
||||
function public.value(item_key)
|
||||
if aux_conservative_history then
|
||||
return private.conservative_historical_value(item_key)
|
||||
else
|
||||
return private.historical_value(item_key)
|
||||
end
|
||||
end
|
||||
|
||||
function private.historical_value(item_key)
|
||||
local item_record = private.read_record(item_key)
|
||||
|
||||
if getn(item_record.market_values) > 0 then
|
||||
return private.median(item_record.market_values)
|
||||
else
|
||||
return private.market_value(item_key)
|
||||
end
|
||||
end
|
||||
|
||||
function private.conservative_historical_value(item_key)
|
||||
local item_record = private.read_record(item_key)
|
||||
|
||||
if getn(item_record.max_bids) > 0 then
|
||||
return private.median(item_record.max_bids)
|
||||
else
|
||||
return item_record.daily_max_bid
|
||||
end
|
||||
end
|
||||
|
||||
function private.market_value(item_key)
|
||||
local item_record = private.read_record(item_key)
|
||||
|
||||
@@ -116,7 +133,7 @@ function private.market_value(item_key)
|
||||
estimate = item_record.daily_max_bid
|
||||
end
|
||||
|
||||
if item_record.daily_max_buyout then
|
||||
if item_record.daily_max_buyout and item_record.daily_max_buyout > estimate then
|
||||
estimate = min(ceil(estimate * 1.15), item_record.daily_max_buyout)
|
||||
end
|
||||
|
||||
@@ -158,54 +175,4 @@ function private.push_record(item_record)
|
||||
item_record.daily_min_buyout = nil
|
||||
item_record.daily_max_buyout = nil
|
||||
item_record.next_push = time() + private.PUSH_INTERVAL
|
||||
end
|
||||
|
||||
function private.snapshot(data)
|
||||
local self = {}
|
||||
|
||||
function self.add(signature, duration)
|
||||
local HOUR = 60 * 60 * 60
|
||||
local seconds
|
||||
if duration == 1 then
|
||||
seconds = HOUR / 2
|
||||
elseif duration == 2 then
|
||||
seconds = HOUR * 2
|
||||
elseif duration == 3 then
|
||||
seconds = HOUR * 8
|
||||
elseif duration == 4 then
|
||||
seconds = HOUR * 24
|
||||
end
|
||||
data[signature] = time() + seconds
|
||||
end
|
||||
|
||||
function self.contains(signature)
|
||||
return data[signature] ~= nil and data[signature] >= time()
|
||||
end
|
||||
|
||||
function self.compact()
|
||||
for signature, expiration in pairs(data) do
|
||||
if expiration < time() then
|
||||
data[signature] = nil
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function self.signatures()
|
||||
local signatures = {}
|
||||
for signature, _ in pairs(data) do
|
||||
if data[signature] >= time() then
|
||||
tinsert(signatures, signature)
|
||||
end
|
||||
end
|
||||
return signatures
|
||||
end
|
||||
|
||||
return self
|
||||
end
|
||||
|
||||
function public.load_snapshot()
|
||||
local dataset = public.load_dataset()
|
||||
dataset.snapshot = dataset.snapshot or {}
|
||||
local snapshot = private.snapshot(dataset.snapshot)
|
||||
return snapshot
|
||||
end
|
||||
@@ -130,7 +130,6 @@ function public.auction(index, type)
|
||||
hyperlink = hyperlink,
|
||||
itemstring = item_info.itemstring,
|
||||
item_key = item_id..':'..suffix_id,
|
||||
signature = Aux.util.join({item_id, suffix_id, unique_id, enchant_id, aux_quantity, start_price, buyout_price}, ':'), -- not unique!
|
||||
search_signature = Aux.util.join({item_id, suffix_id, enchant_id, start_price, buyout_price, bid_price, aux_quantity, duration, owner or ''}, ':'),
|
||||
|
||||
name = name,
|
||||
|
||||
+1
-1
@@ -293,7 +293,7 @@ function m.validator(filter)
|
||||
end
|
||||
if filter.max_percent and (record.unit_buyout_price == 0
|
||||
or not Aux.history.value(record.item_key)
|
||||
or record.unit_buyout_price / Aux.history.value(record.item_key) * 100 > filter.max_percent)
|
||||
or record.unit_buyout_price / Aux.history.conservative_value(record.item_key) * 100 > filter.max_percent)
|
||||
then
|
||||
return
|
||||
end
|
||||
|
||||
@@ -11,11 +11,11 @@ function SlashCmdList.AUX(parameter)
|
||||
elseif parameter == 'delete item cache' then
|
||||
aux_auctionable_items = nil
|
||||
Aux.log('Item cache deleted; falling back to the default.')
|
||||
elseif parameter == 'conservative value on' then
|
||||
aux_conservative_value = true
|
||||
Aux.log('Conservative value activated')
|
||||
elseif parameter == 'conservative value off' then
|
||||
aux_conservative_value = false
|
||||
Aux.log('Conservative value deactivated.')
|
||||
elseif parameter == 'history conservative' then
|
||||
aux_conservative_history = not aux_conservative_history
|
||||
Aux.log('Conservative history '..(aux_conservative_history and 'enabled.' or 'disabled.'))
|
||||
-- elseif parameter == 'percentage conservative' then
|
||||
-- aux_percentage_conservative = false
|
||||
-- Aux.log('Conservative value deactivated.')
|
||||
end
|
||||
end
|
||||
@@ -1,18 +1,6 @@
|
||||
local m = {}
|
||||
Aux.test = m
|
||||
|
||||
do
|
||||
local id = 0
|
||||
function m.test_history()
|
||||
for i=1,500 do
|
||||
for j=1, 100 do
|
||||
Aux.history.process_auction({item_key = id..':0', buyout_price = j, high_bid = j, aux_quantity=1})
|
||||
end
|
||||
id = id + 1
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
function m.key_count(table)
|
||||
local count = 0
|
||||
for _, _ in pairs(table) do
|
||||
@@ -21,23 +9,6 @@ function m.key_count(table)
|
||||
return count
|
||||
end
|
||||
|
||||
do
|
||||
|
||||
local table = {}
|
||||
|
||||
function m.insert()
|
||||
for i=1,1000000 do
|
||||
tinsert(table, i)
|
||||
end
|
||||
end
|
||||
function m.getn()
|
||||
for i=1,100 do
|
||||
snipe.log(getn(table))
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
--StaticPopupDialogs["CANCEL_AUCTION"] = {
|
||||
-- text = TEXT(CANCEL_AUCTION_CONFIRMATION),
|
||||
-- button1 = TEXT(ACCEPT),
|
||||
|
||||
Reference in New Issue
Block a user