Пример #1
0
 public void setShareID(int marketID, int shareID, String code, bool isIndex)
 {
     mFloorID = marketID;
     mShareID = shareID;
     mShare   = mContext.mShareManager.getShare(mShareID);
     mCode    = code;
     mIsIndex = isIndex;
     if (isIndex)
     {
         stPriceboardStateIndex p = mContext.mPriceboard.getIndexByCode(code);
         if (p != null)
         {
             mPriceRef = p.reference;///10;
         }
         //mFloor = p.floor_index;
     }
     else
     {
         stPriceboardState ps = mContext.mPriceboard.getPriceboard(code);
         if (ps != null)
         {
             mPriceRef = ps.getRef();
         }
         //mFloor = ps.getFloor();
     }
 }
Пример #2
0
        public stPriceboardStateIndex getPriceboardIndexOfMarket(int floor)
        {
            if (floor == 4)
            {
                int t = 0;
                t++;
            }
            stPriceboardStateIndex idx = null;

            for (int i = 0; i < mIndices.size(); i++)
            {
                idx = (stPriceboardStateIndex)mIndices.elementAt(i);
                if (idx.marketID == floor)
                {
                    return(idx);
                }
            }

            if (true)//createIfNotExist)
            {
                idx = new stPriceboardStateIndex();

                idx.marketID = floor;
                mIndices.addElement(idx);
            }

            return(idx);
        }
Пример #3
0
        public void setOnlineIndexData(xDataInput di)
        {
            String date = di.readUTF();

            mDate = parseDate(date);
            mTime = parseTime(date);

            int floor = di.readInt();
            int max   = 10;

            if (floor < 1 || floor > max)
            {
                return;
            }

            //=====================index===================
            stPriceboardStateIndex index = getPriceboardIndexOfMarket(floor);

            if (di.available() < 44)
            {
                mContext.err++;
                return;
            }
            if (index != null)
            {
                index.mDate = date;

                index.current_point   = di.readInt() / 100.0f;
                index.changed_point   = di.readInt() / 100.0f;
                index.changed_percent = di.readInt();
                index.total_volume    = di.readInt();

                index.inc_cnt   = di.readInt();
                index.ce_cnt    = di.readInt();
                index.dec_cnt   = di.readInt();
                index.floor_cnt = di.readInt();

                index.ref_num   = di.readInt();
                index.totalGTGD = di.readInt() / 10;                    //	dv 1tr

                index.market_status = di.readInt();

                index.update_time = date;

                index.reference = index.current_point - index.changed_point;
            }

            // set timing clock
            if (index != null && index.market_status == MARKET_STATUS_OPENNING)
            {
                //mContext.mClock.reset(mTime * 1000);
            }
            else
            {
                //mContext.mClock.reset();
            }
        }
Пример #4
0
        public void loadPriceboard()
        {
            if (true)
            {
                return;
            }
            if (!Context.mInvalidSavedFile)
            {
                return;
            }
            xDataInput di = xFileManager.readFile(PRICEBOARD_FILE, false);

            if (di != null)
            {
                int ver = di.readInt();
                if (ver < Context.FILE_VERSION_10)
                {
                    return;
                }

                int floor_count = di.readInt();

                int i = 0;
                //  indices
                mIndices.removeAllElements();
                for (i = 0; i < floor_count; i++)
                {
                    stPriceboardStateIndex idx = new stPriceboardStateIndex();
                    mIndices.addElement(idx);

                    idx.id              = di.readShort();
                    idx.code            = di.readUTF();
                    idx.marketID        = di.readInt();
                    idx.current_point   = di.readFloat(); //	*100
                    idx.changed_point   = di.readFloat(); //	*100
                    idx.changed_percent = di.readInt();   //	*100
                    idx.total_volume    = di.readInt();
                    idx.inc_cnt         = di.readInt();
                    idx.ce_cnt          = di.readInt();
                    idx.dec_cnt         = di.readInt();
                    idx.floor_cnt       = di.readInt();
                    idx.ref_num         = di.readInt();
                    idx.totalGTGD       = di.readInt();         //	*10000
                    idx.market_status   = di.readInt();
                    idx.reference       = di.readFloat();

                    idx.mDate = di.readUTF();
                }

                //  shares
                for (i = 0; i < floor_count; i++)
                {
                    stPriceboardState.load(di);
                }
            }
        }
Пример #5
0
        public bool isShareIndex(int shareID)
        {
            for (int i = 0; i < getIndicesCount(); i++)
            {
                stPriceboardStateIndex pi = getPriceboardIndexAt(i);
                if (pi.id == shareID)
                {
                    return(true);
                }
            }

            return(false);
        }
Пример #6
0
        public bool isMarketClosed()
        {
            for (int i = 1; i <= 2; i++)
            {
                stPriceboardStateIndex pb = getPriceboardIndexOfMarket(i);
                if (pb != null && pb.market_status <= MARKET_STATUS_ATC)
                {
                    return(false);
                }
            }

            return(true);
        }
Пример #7
0
        public stPriceboardStateIndex getIndexByCode(String code)
        {
            stPriceboardStateIndex idx = null;

            for (int i = 0; i < mIndices.size(); i++)
            {
                idx = (stPriceboardStateIndex)mIndices.elementAt(i);
                if (idx != null && idx.code != null && idx.code.Equals(code))
                {
                    return(idx);
                }
            }

            return(null);
        }
Пример #8
0
        public void savePriceboard()
        {
            xDataOutput o = new xDataOutput(10000);

            o.writeInt(Context.FILE_VERSION);
            //  indices
            o.writeInt(mIndices.size());
            int i = 0;

            for (i = 0; i < mIndices.size(); i++)
            {
                stPriceboardStateIndex idx = (stPriceboardStateIndex)mIndices.elementAt(i);
                o.writeShort(idx.id);
                o.writeUTF(idx.code);
                o.writeInt(idx.marketID);
                o.writeFloat(idx.current_point);        //	*100
                o.writeFloat(idx.changed_point);        //	*100
                o.writeInt(idx.changed_percent);        //	*100
                o.writeInt((int)idx.total_volume);
                o.writeInt(idx.inc_cnt);
                o.writeInt(idx.ce_cnt);
                o.writeInt(idx.dec_cnt);
                o.writeInt(idx.floor_cnt);
                o.writeInt(idx.ref_num);
                o.writeInt(idx.totalGTGD);              //	*10000
                o.writeInt(idx.market_status);
                o.writeFloat(idx.reference);

                o.writeUTF(idx.mDate);
            }
            //  shares
            for (i = 0; i < mIndices.size(); i++)
            {
                stPriceboardStateIndex idx = (stPriceboardStateIndex)mIndices.elementAt(i);
                stPriceboardState.flush(o, idx.marketID);
            }

            xFileManager.saveFile(o, PRICEBOARD_FILE);
        }
Пример #9
0
        public void copyFrom(stPriceboardStateIndex ps)
        {
            this.id              = ps.id;
            this.code            = ps.code;
            this.marketID        = ps.marketID;
            this.current_point   = ps.current_point;
            this.changed_point   = ps.changed_point;
            this.changed_percent = ps.changed_percent;
            this.status_changed  = ps.status_changed;

            this.total_volume  = ps.total_volume;
            this.inc_cnt       = ps.inc_cnt;
            this.ce_cnt        = ps.ce_cnt;
            this.dec_cnt       = ps.dec_cnt;
            this.floor_cnt     = ps.floor_cnt;
            this.ref_num       = ps.ref_num;
            this.totalGTGD     = ps.totalGTGD;
            this.reference     = ps.reference;
            this.update_time   = ps.update_time;
            this.market_status = ps.market_status;
            this.mDate         = ps.mDate;
            this.du_ban        = ps.du_ban;
            this.du_mua        = ps.du_mua;
        }
Пример #10
0
        /*
         *  public void setRefPrice(xDataInput di) {
         *      if (true)   //  invalid method and not used anymore
         *          return;
         *      int floor = di.readInt();
         *      int cnt = di.readInt();
         *      if (cnt < 0) {
         *          return;
         *      }
         *      if (cnt > 5000) {
         *          return;
         *      }
         *
         *      if (floor < 1 || floor > 2) {
         *          return;
         *      }
         *
         *      stPriceboardState.alloc_buffer(floor, cnt);
         *
         *      mHasRefvalue = true;
         *      int j = 0;
         *      //====================================================================
         *      byte[] data = di.getBytes();
         *      int off = di.getCurrentOffset();
         *
         *      for (int i = 0; i < cnt; i++) {
         *          j = 0;
         *          stPriceboardState p = stPriceboardState.seekPriceboard(floor, data, off);
         *          //	code
         *          p.setRef(data, off);
         *          off += 8 + 3 * 4;
         *      }
         *  }
         *
         */
        /*
         * public void setZeroPriceboard(xDataInput di)
         * {
         *  String nextfile = di.readUTF();
         *  //nextfile = "0"; //  CHEAT
         *
         *  String date = di.readUTF();
         *  mDate = parseDate(date);
         *
         *  int floor = di.readInt();
         *  int max = 10;
         *  if (floor < 1 || floor > max)
         *  {
         *      return;
         *  }
         *
         *  mNextfile[floor - 1] = nextfile;
         *
         *  //=====================index===================
         *  stPriceboardStateIndex index = getPriceboardIndexOfMarket(floor);
         *  int oldStatus = index.market_status;
         *  index.current_point = di.readInt()/100.0f;
         *  index.changed_point = di.readInt()/100.0f;
         *  index.changed_percent = di.readInt();
         *  index.total_volume = di.readInt();
         *  index.inc_cnt = di.readInt();
         *  index.ce_cnt = di.readInt();
         *  index.dec_cnt = di.readInt();
         *  index.floor_cnt = di.readInt();
         *  index.ref_num = di.readInt();
         *  index.totalGTGD = di.readInt() / 10;			//	dv 1tr
         *  index.market_status = di.readInt();
         *  index.update_time = date;
         *  index.reference = index.current_point - index.changed_point;
         *
         *  index.status_changed = oldStatus != index.market_status ? true : false;
         *  //=====================end of index===================
         *
         *  int cnt = di.readInt();
         *  if (cnt < 0 || cnt > 5000)
         *  {
         *      return;
         *  }
         *
         *  byte[] data = di.getBytes();
         *
         *  int j = 0;
         *  for (int i = 0; i < cnt; i++)
         *  {
         *      stPriceboardState p = getPriceboard(floor, data, di.getCurrentOffset());
         *
         *      //Utils.trace("=====" + c0 + c1 + c2);
         *
         *      if (p == null)
         *      {
         *          di.skip(Share.SHARE_CODE_LENGTH + 54);
         *          continue;
         *      }
         *      di.skip(Share.SHARE_CODE_LENGTH);
         *
         *      p.setZero(di);
         *  }
         * }
         */

        public void setZeroPriceboard2016(xDataInput di)
        {
            String nextfile = di.readUTF();
            //nextfile = "0"; //  CHEAT

            String date = di.readUTF();

            mDate = parseDate(date);

            int floor = di.readInt();
            int max   = 10;

            if (floor < 1 || floor > max)
            {
                return;
            }

            mNextfile[floor - 1] = nextfile;

            //=====================index===================
            stPriceboardStateIndex index = getPriceboardIndexOfMarket(floor);
            int oldStatus = index.market_status;

            index.current_point   = di.readInt() / 100.0f;
            index.changed_point   = di.readInt() / 100.0f;
            index.changed_percent = di.readInt();
            index.total_volume    = di.readInt();
            index.inc_cnt         = di.readInt();
            index.ce_cnt          = di.readInt();
            index.dec_cnt         = di.readInt();
            index.floor_cnt       = di.readInt();
            index.ref_num         = di.readInt();
            index.totalGTGD       = di.readInt() / 10;                  //	dv 1tr
            index.market_status   = di.readInt();
            index.update_time     = date;
            index.reference       = index.current_point - index.changed_point;

            index.status_changed = oldStatus != index.market_status ? true : false;

            //=====================end of index===================

            int cnt = di.readInt();

            if (cnt < 0 || cnt > 5000)
            {
                return;
            }

            byte[] data = di.getBytes();

            int j = 0;

            for (int i = 0; i < cnt; i++)
            {
                //stPriceboardState p = getPriceboard(floor, data, di.getCurrentOffset());

                String            scode = Utils.bytesNullTerminatedToString(data, di.getCurrentOffset(), 20);
                stPriceboardState p     = getPriceboard(scode);

                if (p == null)
                {
                    di.skip(Share.SHARE_CODE_LENGTH + 72);
                    continue;
                }

                p.code = scode;

                //Utils.trace("=====" + c0 + c1 + c2);


                di.skip(Share.SHARE_CODE_LENGTH);

                p.setZero(di);
            }
        }