Information

Username: walter.claudius
Member since: 01 Dec 2023
Last login: 01 Dec 2023
Status: Active

Activity

Where Created Comments
Algorithms 0 1
Forum Topics 0 0
Jobs 0 0

Last Algorithm Comments

WA
walter.claudius · 7 months ago

What is the meaning behind these two functions?
It seems like he is offsetting the volume with the price. But doesn't that result in an information loss, or what exactly is the intended effect?




        protected double vol_weighted_price(cAlgo.API.Collections.IReadonlyList<cAlgo.API.MarketDepthEntry> mkentries)
        {
            double weightdiv = 0.0;
            double tsum = 0.0;
            for (int i = 0; i < mkentries.Count; i++)
            {
                var aent = mkentries[i];
                tsum += (double)aent.Price * (double)aent.Volume;
                weightdiv += (double)aent.Volume;
            }
            if (weightdiv == 0)
            {
                return 0;
            }
            else
            {
                return tsum / weightdiv;
            }
        }


        protected double vol_weighted_cnt(cAlgo.API.Collections.IReadonlyList<cAlgo.API.MarketDepthEntry> mkentries)
        {
            double weightdiv = 0.0;
            double tsum = 0.0;
            for (int i = 0; i < mkentries.Count; i++)
            {
                var aent = mkentries[i];
                tsum += (double)aent.Volume * (double)aent.Price;
                weightdiv += (double)aent.Price;
            }
            if (weightdiv == 0)
            {
                return 0;
            }
            else
            {
                return tsum / weightdiv;
            }
        }