Beispiel #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();
     }
 }
Beispiel #2
0
 public void copyFrom(stPriceboardState ps)
 {
     this.code    = ps.code;  //  10
     this.floorId = ps.floorId;
     this.state   = ps.state;
     for (int i = 0; i < 3; i++)
     {
         this.remain_sell_volume[i] = ps.remain_sell_volume[i];
         this.remain_buy_volume[i]  = ps.remain_buy_volume[i];
     }
     this.current_volume_1 = ps.current_volume_1;
     this.total_volume     = ps.total_volume;
     this.ce        = ps.ce;
     this.reference = ps.reference;
     this.floor     = ps.floor;
     this.max       = ps.max;
     this.min       = ps.min;
     for (int i = 0; i < 3; i++)
     {
         this.remain_buy_price[i]  = ps.remain_buy_price[i];
         this.remain_buy_volume[i] = ps.remain_buy_volume[i];
     }
     this.current_price_1 = ps.current_price_1;
     this.change          = ps.change;
     this.changePercent   = ps.changePercent;            //	1000	==	1%
     this.id = ps.id;
 }
Beispiel #3
0
        public static void addPriceboardStateOfIndex(stPriceboardState ps)
        {
            xVector v = (xVector)dataPriceboard.getValue(kVNIndices);

            if (v == null)
            {
                v = new xVector();
                dataPriceboard.setValue(kVNIndices, v);
            }

            bool added = false;

            for (int i = 0; i < v.size(); i++)
            {
                stPriceboardState _ps = (stPriceboardState)v.elementAt(i);
                if (_ps.code.Equals(ps.code))
                {
                    added = true;
                    _ps.copyFrom(ps);

                    break;
                }
            }

            if (!added)
            {
                v.addElement(ps);
            }
        }
Beispiel #4
0
        public stPriceboardState createNewPriceboardState(int shareID)
        {
            if (mPriceboardMap.ContainsKey(shareID))
            {
                return(mPriceboardMap[shareID]);
            }

            stPriceboardState ps = new stPriceboardState();

            ps.id = shareID;
            mPriceboardMap.Add(shareID, ps);

            return(ps);
        }
Beispiel #5
0
        public void setPriceboardDataOfGroup(xDataInput di)
        {
            int cnt = di.readInt();

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

            //printf("==c================================\n");
            for (int i = 0; i < cnt; i++)
            {
                int shareID         = di.readInt();
                stPriceboardState p = getPriceboard(shareID);

                if (p == null)
                {
                    break;
                }
                if (p.code.CompareTo("AAA") == 0)
                {
                    Utils.trace("----");
                }
                //==================================

                p.max = di.readInt() / 1000.0f;
                p.min = di.readInt() / 1000.0f;
                for (int k = 0; k < 3; k++)
                {
                    p.remain_buy_price[k]  = di.readInt() / 1000.0f;
                    p.remain_buy_volume[k] = di.readInt();
                }
                for (int k = 0; k < 3; k++)
                {
                    p.remain_sell_price[k]  = di.readInt() / 1000.0f;
                    p.remain_sell_volume[k] = di.readInt();
                }
                p.current_price_1  = di.readInt() / 1000.0f;
                p.current_volume_1 = di.readInt();
                p.change           = di.readInt() / 1000.0f;
                p.changePercent    = (int)((p.change * 100) / p.reference);
                p.total_volume     = di.readInt();

                p.state = 0x0fffffff;
            }
        }
Beispiel #6
0
        public static stPriceboardState getPriceboardStateOfIndexWithSymbol(String symbol)
        {
            xVector v = (xVector)dataPriceboard.getValue(kVNIndices);

            if (v == null)
            {
                return(null);
            }
            for (int i = 0; i < v.size(); i++)
            {
                stPriceboardState ps = (stPriceboardState)v.elementAt(i);
                if (ps.code.Equals(symbol))
                {
                    return(ps);
                }
            }

            return(null);
        }
Beispiel #7
0
        //  0: no alarm, -1: lower-price alarm; 1: upper-price alarm
        public int hasAlarm()
        {
            stPriceboardState ps = Context.getInstance().mPriceboard.getPriceboard(code);

            if (ps != null)
            {
                float price = ps.getCurrentPrice();
                if (price <= lowerPrice && lowerPrice > 0 && price > 0)
                {
                    return(-1);
                }
                if (price >= upperPrice && upperPrice > 0 && price > 0)
                {
                    return(1);
                }
            }

            return(0);
        }
Beispiel #8
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);
            }
        }