Ejemplo n.º 1
0
        void calcBuySellRemains(int marketID, double[] buysell)
        {
            double buy   = 0;
            double sell  = 0;
            int    total = mContext.mShareManager.getTotalShareIDCount();

            int[] mid = { 0 };
            for (int i = 0; i < total; i++)
            {
                mid[0] = -1;
                int shareID = mContext.mShareManager.getShareIDAt(i, mid);
                if (shareID == 257)
                {
                    shareID = 257;
                }
                if (/*mid[0] == marketID && */ shareID != 0)
                {
                    stPriceboardState ps = mContext.mPriceboard.getPriceboard(shareID);
                    if (ps.getMarketID() == marketID)
                    {
                        buy += ps.getRemainBuyVolume0();
                        buy += ps.getRemainBuyVolume1();
                        buy += ps.getRemainBuyVolume2();

                        sell += ps.getRemainSellVolume0();
                        sell += ps.getRemainSellVolume1();
                        sell += ps.getRemainSellVolume2();
                    }
                }
            }
            buysell[0] = buy;
            buysell[1] = sell;
        }
Ejemplo n.º 2
0
        //  code | _ref | KL1 | G1 |= GiaKhop | KLKhop | TongKL =| KL1 | G1 |=== TB | Cao | Thap
        virtual protected void updateQuote()
        {
            if (getID() < 0)
            {
                return;
            }

            Context ctx = Context.getInstance();
            stCell  c;

            if (getID() == 0)
            {
                //  code
                setCellValue(0, "▼ Mã\nTC", C.COLOR_ORANGE);

                setCellValue(2, "M3/KL", C.COLOR_GRAY);
                setCellValue(3, "M2/KL", C.COLOR_GRAY);
                setCellValue(4, "M1/KL", C.COLOR_GRAY);

                setCellValue(5, "Khớp", C.COLOR_GRAY);
                setCellValue(6, "+/-", C.COLOR_GRAY);

                setCellValue(7, "B1/KL", C.COLOR_GRAY);
                setCellValue(8, "B2/KL", C.COLOR_GRAY);
                setCellValue(9, "B3/KL", C.COLOR_GRAY);

                setCellValue(10, "H/L", C.COLOR_GRAY);

                setCellValue(11, "TổngKL", C.COLOR_GRAY);

                /*
                 * c = getCellAt(11);
                 * if (c != null)
                 * {
                 *  c.text2 = "DưB";
                 *  c.textColor2 = C.COLOR_GRAY;
                 * }
                 */

                if (sortType == ShareSortUtils.SORT_DUMUA_DUBAN)
                {
                    setCellValue(12, "▼ Dư\nM/B", C.COLOR_ORANGE);
                }
                else
                {
                    setCellValue(12, "▼ " + ShareSortUtils.sortTypeToString(sortType), C.COLOR_ORANGE);
                }
            }

            if (getID() == 0)
            {
                return;
            }

            String code = (String)getUserData();

            if (code == null)
            {
                return;
            }
            stPriceboardState item = ctx.mPriceboard.getPriceboard(code);
            stPriceboardState ps   = item;

            if (item == null)
            {
                return;
            }

            Share share = ctx.mShareManager.getShare(ps.id);

            if (share == null)
            {
                return;
            }

            String s;

            //  code
            uint color;

            setCellValue(0, code, C.COLOR_WHITE);
            addCellValue1(0, String.Format("{0:F2}", item.getRef()), C.COLOR_YELLOW);
            float _ref = item.getRef();

            int   j = 0;
            float v;

            int[]   rbc = { 2, 3, 4 };  //	remain buy col
            float[] rb  = { ps.getRemainBuyPrice2(), ps.getRemainBuyPrice1(), ps.getRemainBuyPrice0() };
            int[]   rbv = { ps.getRemainBuyVolume2(), ps.getRemainBuyVolume1(), ps.getRemainBuyVolume0() };

            int[]   rsc = { 7, 8, 9 };
            float[] rs  = { ps.getRemainSellPrice0(), ps.getRemainSellPrice1(), ps.getRemainSellPrice2() };
            int[]   rsv = { ps.getRemainSellVolume0(), ps.getRemainSellVolume1(), ps.getRemainSellVolume2() };
            //	mua1, mua2, mua3

            for (j = 0; j < 3; j++)
            {
                //	price
                color = ctx.valToColorF(rb[j], item.getCe(), item.getRef(), item.getFloor());
                setCellValue(rbc[j], String.Format("{0:F2}", rb[j]), color);
                //	vol
                s = volumeToString(rbv[j]);

                addCellValue1(rbc[j], s);
            }

            //  Khop
            float currentPrice = item.getCurrentPrice();
            int   currentVol   = item.getCurrentVolume();

            color = ctx.valToColorF(currentPrice, item.getCe(), item.getRef(), item.getFloor());
            setCellValue(5, String.Format("{0:F2}", currentPrice), color);

            s = volumeToString(currentVol);

            addCellValue1(5, s);

            //  change +/-
            v = currentPrice - item.getRef();
            s = String.Format("{0:F2}", (float)v);
            if (currentPrice == 0)
            {
                s = "-";
            }
            setCellValue(6, s, color);

            //	sell1, sell2, sell3
            for (j = 0; j < 3; j++)
            {
                //	price
                color = ctx.valToColorF(rs[j], item.getCe(), item.getRef(), item.getFloor());
                setCellValue(rsc[j], String.Format("{0:F2}", rs[j]), color);
                //	vol
                s = volumeToString(rsv[j]);

                addCellValue1(rsc[j], s);
            }

            //  cao - thap
            setCellValue(10, String.Format("{0:F2}", item.getMax()), ctx.valToColorF(item.getMax(), item.getCe(), item.getRef(), item.getFloor()));
            addCellValue1(10, String.Format("{0:F2}", item.getMin()), ctx.valToColorF(item.getMin(), item.getCe(), item.getRef(), item.getFloor()));

            //  total volume
//            s = volumeToString(item.getTotalVolume());
//            setCellValue(11, s, C.COLOR_WHITE);
            mVolumeColumn = 11;

            //  cung - cau
            if (sortType == ShareSortUtils.SORT_DUMUA_DUBAN)
            {
                int    buy   = item.getRemainBuyVolume0() + item.getRemainBuyVolume1() + item.getRemainBuyVolume2();
                int    sell  = item.getRemainSellVolume0() + item.getRemainSellVolume1() + item.getRemainSellVolume2();
                String sbuy  = volumeToString(buy);
                String ssell = volumeToString(sell);
                setCellValue(12, sbuy, C.COLOR_ORANGE);
                c = getCellAt(12);
                if (c != null)
                {
                    c.text2      = ssell;
                    c.textColor2 = C.COLOR_ORANGE;
                }
            }
            else
            {
                setCellValue(12, share.mCompareText, C.COLOR_ORANGE);
                c = getCellAt(12);
                if (c != null)
                {
                    c.text2      = null;
                    c.textColor2 = C.COLOR_ORANGE;
                }
            }
        }