Beispiel #1
0
        //更新成交均价
        private void DealAveragePrice(Deal deal)
        {
            string[] keys  = TradeRA.KeySearch("D_*_O_" + deal.order_no + "_U_*");
            decimal  money = 0;
            int      count = 0;

            foreach (string key in keys)
            {
                Deal dl = DealRA.Get(key);
                money += dl.price * dl.count;
                count += dl.count;
            }
            string[] keys_order = TradeRA.KeySearch("O_" + deal.order_no + "_*_U_" + deal.unit_id);
            if (keys_order.Length > 0)
            {
                decimal deal_average_price = (money + deal.price * deal.count) / (count + deal.count);
                OrderRA.UpdateAverageOrice(Math.Round(deal_average_price, 3), keys_order[0]);
            }
        }