ahmedHalim
Hi, How can I use the below code for subscription ( USDGBP or USDJPY ... etc )
The code :
package stocklist_demo.feed_simulator;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.HashMap;
import java.util.Random;
import java.util.Timer;
import java.util.TimerTask;
/**
* Simulates an external data feed that supplies quote values for all the
* stocks needed for the demo.
*/
public class ExternalFeedSimulator {
private static final Timer dispatcher = new Timer();
private static final Random random = new Random();
/**
* Used to automatically generate the updates for the 30 stocks:
* mean and standard deviation of the times between consecutive
* updates for the same stock.
*/
private static final double[] updateTimeMeans = {30000, 500, 3000, 90000,
7000, 10000, 3000, 7000,
7000, 7000, 500, 3000,
20000, 20000, 20000, 30000,
500, 3000, 90000, 7000,
10000, 3000, 7000, 7000,
7000, 500, 3000, 20000,
20000, 20000, };
private static final double[] updateTimeStdDevs = {6000, 300, 1000, 1000,
100, 5000, 1000, 3000,
1000, 6000, 300, 1000,
1000, 4000, 1000, 6000,
300, 1000, 1000, 100,
5000, 1000, 3000, 1000,
6000, 300, 1000, 1000,
4000, 1000, };
/**
* Used to generate the initial field values for the 30 stocks.
*/
private static final double[] refprices = {3.04, 16.09, 7.19, 3.63, 7.61,
2.30, 15.39, 5.31, 4.86, 7.61,
10.41, 3.94, 6.79, 26.87, 2.27,
13.04, 6.09, 17.19, 13.63, 17.61,
11.30, 5.39, 15.31, 14.86, 17.61,
5.41, 13.94, 16.79, 6.87,
11.27, };
private static final double[] openprices = {3.10, 16.20, 7.25, 3.62, 7.65,
2.30, 15.85, 5.31, 4.97, 7.70,
10.50, 3.95, 6.84, 27.05, 2.29,
13.20, 6.20, 17.25, 13.62,
17.65, 11.30, 5.55, 15.31,
14.97, 17.70, 5.42, 13.95,
16.84, 7.05, 11.29, };
private static final double[] minprices = {3.09, 15.78, 7.15, 3.62, 7.53,
2.28, 15.60, 5.23, 4.89, 7.70,
10.36, 3.90, 6.81, 26.74, 2.29,
13.09, 5.78, 17.15, 13.62, 17.53,
11.28, 5.60, 15.23, 14.89, 17.70,
5.36, 13.90, 16.81, 6.74,
11.29, };
private static final double[] maxprices = {3.19, 16.20, 7.26, 3.71, 7.65,
2.30, 15.89, 5.31, 4.97, 7.86,
10.50, 3.95, 6.87, 27.05, 2.31,
13.19, 6.20, 17.26, 13.71, 17.65,
11.30, 5.89, 15.31, 14.97, 17.86,
5.50, 13.95, 16.87, 7.05,
11.31, };
private static final String[] stockNames = {"Anduct", "Ations Europe",
"Bagies Consulting", "BAY Corporation",
"CON Consulting", "Corcor PLC",
"CVS Asia", "Datio PLC",
"Dentems", "ELE Manufacturing",
"Exacktum Systems", "KLA Systems Inc",
"Lted Europe", "Magasconall Capital",
"MED", "Mice Investments",
"Micropline PLC", "Nologicroup Devices",
"Phing Technology", "Pres Partners",
"Quips Devices", "Ress Devices",
"Sacle Research", "Seaging Devices",
"Sems Systems, Inc", "Softwora Consulting",
"Systeria Develop", "Thewlec Asia",
"Virtutis", "Yahl" };
/**
* Used to keep the contexts of the 30 stocks.
*/
private final ArrayList stockGenerators = new ArrayList();
private ExternalFeedListener listener;
/**
* Starts generating update events for the stocks. Sumulates attaching
* and reading from an external broadcast feed.
*/
public void start() {
for (int i = 0; i < 30; i++) {
MyProducer myProducer = new MyProducer("item" + (i + 1), i);
stockGenerators.add(myProducer);
long waitTime = myProducer.computeNextWaitTime();
scheduleGenerator(myProducer, waitTime);
}
}