Beispiel #1
0
  /**
   * tells the market that the model is starting up, and it would be a good idea to start the data
   * collector. It also schedules a final cleanup step to update gui if needed
   *
   * @param model
   */
  public void start(MacroII model) {

    marketData.start(model, this);

    if (priceSeries != null) {
      Steppable guiUpdater =
          new Steppable() {
            @Override
            public void step(SimState simState) {
              if (!marketData.isActive()) return;
              final Double newPrice = marketData.getLatestObservation(MarketDataType.CLOSING_PRICE);
              final Double newVolume =
                  marketData.getLatestObservation(MarketDataType.VOLUME_TRADED);
              final Double day = new Double(marketData.getLastObservedDay());

              // if(newPrice >=0
              Platform.runLater(
                  new Runnable() {
                    @Override
                    public void run() {
                      System.out.println(
                          newPrice + "--- " + day + ", " + priceSeries.getData().size());
                      priceSeries.getData().add(new XYChart.Data<Number, Number>(day, newPrice));
                      volumeSeries.getData().add(new XYChart.Data<Number, Number>(day, newVolume));
                    }
                  });
              model.scheduleTomorrow(ActionOrder.CLEANUP_DATA_GATHERING, this, Priority.FINAL);
              panel.repaint();
            }
          };

      model.scheduleSoon(ActionOrder.CLEANUP_DATA_GATHERING, guiUpdater, Priority.FINAL);
    }
  }
Beispiel #2
0
 public int getLastObservedDay() {
   return marketData.getLastObservedDay() - 1;
 }
Beispiel #3
0
 /**
  * a method to check if, given the acceptor, the latest observation is valid
  *
  * @param acceptor
  * @return
  */
 public boolean isLastDayAcceptable(MarketData.MarketDataAcceptor acceptor) {
   return marketData.isLastDayAcceptable(acceptor);
 }
Beispiel #4
0
 /** return the latest price observed */
 public Double getLatestObservation(MarketDataType type) {
   return marketData.getLatestObservation(type);
 }
Beispiel #5
0
 /** utility method to analyze only a specific day */
 public double getObservationRecordedThisDay(MarketDataType type, int day) {
   return marketData.getObservationRecordedThisDay(type, day);
 }
Beispiel #6
0
 /** utility method to analyze only specific days */
 public double[] getObservationsRecordedTheseDays(
     MarketDataType type, int beginningDay, int lastDay) {
   return marketData.getObservationsRecordedTheseDays(type, beginningDay, lastDay);
 }
Beispiel #7
0
 /** utility method to analyze only specific days */
 public double[] getObservationsRecordedTheseDays(MarketDataType type, int[] days) {
   return marketData.getObservationsRecordedTheseDays(type, days);
 }
Beispiel #8
0
 /** returns a copy of all the observed last prices so far! */
 public double[] getAllRecordedObservations(MarketDataType type) {
   return marketData.getAllRecordedObservations(type);
 }
Beispiel #9
0
 /** check which days have observations that are okay with the acceptor! */
 public int[] getAcceptableDays(int[] days, MarketData.MarketDataAcceptor acceptor) {
   return marketData.getAcceptableDays(days, acceptor);
 }
Beispiel #10
0
 /** how many days worth of observations are here? */
 public int getNumberOfObservations() {
   if (marketData == null) return 0;
   return marketData.numberOfObservations();
 }
Beispiel #11
0
 public void turnOff() {
   // the game is over, tell the rest of the crew
   marketData.turnOff();
 }