Exemple #1
0
 /** @see cmdCore.ICommand#doIt() */
 public UCommandStatus doIt() {
   try {
     fSpotArray.clear();
     fStatus = fUMart.doSpotPrice(fSpotArray, fBrandName, fNoOfSteps);
     if (fStatus.getStatus()) {
       fAgent.sendMessage("+ACCEPT");
       Iterator itr = fSpotArray.iterator();
       while (itr.hasNext()) {
         HashMap hm = (HashMap) itr.next();
         String result = "";
         result += hm.get(STRING_BRAND_NAME).toString();
         result += " " + hm.get(INT_DAY).toString();
         result += ":" + hm.get(INT_BOARD_NO).toString();
         result += ":" + hm.get(INT_STEP).toString();
         result += " " + hm.get(LONG_PRICE).toString();
         fAgent.sendMessage(result);
       }
     } else {
       fAgent.sendMessage("+ERROR " + fStatus.getErrorCode());
       fAgent.sendMessage(fStatus.getErrorMessage());
     }
   } catch (Exception e) {
     fAgent.sendMessage("+ERROR " + ICommand.INVALID_ARGUMENTS);
     fAgent.sendMessage("USAGE: ORDERCANCEL <ORDERID>");
   }
   fAgent.flushMessage();
   return fStatus;
 }
Exemple #2
0
 public void initAgents(ArrayList machineAgentArray) {
   fUGeneralStrategy = new UBaseAgent("su", "supasswd", "Super User", 0);
   fServer.appendStrategy(fUGeneralStrategy);
   fCProtocol = fUGeneralStrategy.getUmcp();
   fCommandHashMap = fCProtocol.getCommandHashMap();
   Iterator iter = machineAgentArray.iterator();
   while (iter.hasNext()) {
     fServer.appendStrategy((UBaseAgent) iter.next());
   }
 }
Exemple #3
0
  public void dataUpdate() {
    // 日付関係はUGUIUpdateManager経由で取得するように変更.
    int date = UGUIUpdateManager.getDate();
    int boardNo = UGUIUpdateManager.getBoard();
    int step = UGUIUpdateManager.getStep();
    int now = UGUIUpdateManager.getMarketStatus();

    if (now != fCurrentStatus) {
      fIsUpdated = true;
    }

    if (step <= fCurrentStep) {
      // Exchange X-Y がセットされている場合の処理.フラグ処理はあまりきれいではないが
      // X-Y の入れ換え自体が???なので勘弁してもらおう.
      if (fIsUpdated == false) {
        return;
      } else {
        fIsUpdated = false;
      }
    }

    if (boardNo == 1) {
      fDay.setText(String.valueOf(date - 1));
      fBoard.setText(String.valueOf(fParam.getBoardPerDay()));
    } else {
      fDay.setText(String.valueOf(date));
      if (now == fCurrentStatus) {
        fBoard.setText(String.valueOf(boardNo - 1));
      } else {
        fBoard.setText(String.valueOf(boardNo));
      }
    }
    fCurrentStep = step;
    fCurrentStatus = now;

    UCBoardDataCore cBoardData = (UCBoardDataCore) fCProtocol.getCommand(UCBoardDataCore.CMD_NAME);
    UCommandStatus status = cBoardData.doIt();
    ArrayList array;
    HashMap boardDataInfo;
    long maxPrice, minPrice, totalBuyVolume;
    Vector printData = new Vector();
    if (status.getStatus()) {
      array = cBoardData.getBoardDataArray();
      boardDataInfo = cBoardData.getBoardDataInfo();
      maxPrice = ((Long) boardDataInfo.get(UCBoardDataCore.LONG_MAX_PRICE)).longValue();
      minPrice = ((Long) boardDataInfo.get(UCBoardDataCore.LONG_MIN_PRICE)).longValue();
      totalBuyVolume =
          ((Long) boardDataInfo.get(UCBoardDataCore.LONG_TOTAL_BUY_VOLUME)).longValue();
      if (fIsExchangeXY == false) {
        fBoardGraph.setFixedMaxX(maxPrice);
        fBoardGraph.setFixedMinX(minPrice);
        fBoardGraph.setFixedMaxY(totalBuyVolume);
        fBoardGraph.setFixedMinY(0);
      } else {
        fBoardGraph.setFixedMaxX(totalBuyVolume);
        fBoardGraph.setFixedMinX(0);
        fBoardGraph.setFixedMaxY(maxPrice);
        fBoardGraph.setFixedMinY(minPrice);
      }
    } else {
      return;
    }
    long contractPrice =
        ((Long) boardDataInfo.get(UCBoardDataCore.LONG_CONTRACT_PRICE)).longValue();
    long contractVolume =
        ((Long) boardDataInfo.get(UCBoardDataCore.LONG_CONTRACT_VOLUME)).longValue();
    fContractPriceTextField.setText(String.valueOf(contractPrice));
    fContractVolumeTextField.setText(String.valueOf(contractVolume));
    ArrayList tmpSellData = new ArrayList();
    ArrayList tmpBuyData = new ArrayList();
    ArrayList tmpContractData = new ArrayList();
    if (fIsExchangeXY == false) {
      tmpContractData.add(new Point2D.Double(minPrice, contractVolume));
      tmpContractData.add(new Point2D.Double(contractPrice, contractVolume));
      tmpContractData.add(new Point2D.Double(contractPrice, 0));
      fBoardGraph.setXLableName("price");
      fBoardGraph.setYLableName("volume");
    } else {
      tmpContractData.add(new Point2D.Double(contractVolume, minPrice));
      tmpContractData.add(new Point2D.Double(contractVolume, contractPrice));
      tmpContractData.add(new Point2D.Double(0, contractPrice));
      fBoardGraph.setXLableName("volume");
      fBoardGraph.setYLableName("price");
    }
    Iterator iter = array.iterator();
    double tmpPrice, tmpVolume, currentSellVolume = 0, currentBuyVolume = totalBuyVolume;
    while (iter.hasNext()) {
      HashMap os = (HashMap) iter.next();
      String s = (String) os.get(UCBoardDataCore.STRING_SELL_BUY);
      if (s.equals("sell")) {
        tmpPrice = ((Long) os.get(UCBoardDataCore.LONG_PRICE)).doubleValue();
        tmpVolume = ((Long) os.get(UCBoardDataCore.LONG_VOLUME)).doubleValue();
        if (fIsExchangeXY == false) {
          tmpSellData.add(new Point2D.Double(tmpPrice, currentSellVolume));
          tmpSellData.add(new Point2D.Double(tmpPrice, currentSellVolume + tmpVolume));
        } else {
          tmpSellData.add(new Point2D.Double(currentSellVolume, tmpPrice));
          tmpSellData.add(new Point2D.Double(currentSellVolume + tmpVolume, tmpPrice));
        }
        currentSellVolume += tmpVolume;
      } else if (s.equals("buy")) {
        tmpPrice = ((Long) os.get(UCBoardDataCore.LONG_PRICE)).doubleValue();
        tmpVolume = ((Long) os.get(UCBoardDataCore.LONG_VOLUME)).doubleValue();
        if (fIsExchangeXY == false) {
          tmpBuyData.add(new Point2D.Double(tmpPrice, currentBuyVolume));
          tmpBuyData.add(new Point2D.Double(tmpPrice, currentBuyVolume - tmpVolume));
        } else {
          tmpBuyData.add(new Point2D.Double(currentBuyVolume, tmpPrice));
          tmpBuyData.add(new Point2D.Double(currentBuyVolume - tmpVolume, tmpPrice));
        }
        currentBuyVolume -= tmpVolume;
      }
    }
    ((UGraphData) fBoardGraph.getGraph().get(0)).setData(tmpSellData);
    ((UGraphData) fBoardGraph.getGraph().get(1)).setData(tmpBuyData);
  }