0
$\begingroup$

I buy and sell units at varying price and I always have a varying stock of units bought in different batches at different prices.
I always keep the current_price and the current_volume and I base my decissions of the current_price.

Every time I buy I recalculate current_price as:
current_price = (current_price * current_vol + batch_price*batch_vol) / (current_vol+batch_vol)

Every time I sell I simply subtract batch_vol from current_vol

Is this a sensible strategy? at any given time the current_price is not exactly equal to the last buy orders that match the volume but it seems like a good approximation.

Should I use something else? I am interested in simplicity, if this is not blatantly wrong I can live with it for external reasons.

$\endgroup$

1 Answer 1

0
$\begingroup$

What you are doing makes sense. It does track the average unit cost of the items in your inventory, diluting the old ones with the new ones. It assumes that each time you sell and item, it is part new one and part old one.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.