Results 1 to 3 of 3

Thread: Subscription

  1. #1

    Subscription

    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);
    }
    }

  2. #2
    Administrator
    Join Date
    Feb 2012
    Location
    Milano
    Posts
    505
    Hi Ahmed,

    Please consider that the code you have attached is a simulator used in our StockList Demo to generate simulated market data.

    That said I can confirm that the StockList Adapter java is a good starting point for real FX trading application.
    But you should remove the classes of the feed_simulator package and replace them with the code needed to retrive the information from your market source.
    Also you should adapt the Item names "item" + (i + 1) with the real item names you choose for your application like, usdgbp, usdjpy, ...

    Regards,
    Giuseppe

  3. #3
    Thank you

 

 

Similar Threads

  1. Push and Subscription Buffering
    By Cerogil in forum Adapter APIs
    Replies: 7
    Last Post: October 29th, 2010, 10:58 AM
  2. Subscription Problem, I think
    By jcroston in forum Client APIs
    Replies: 4
    Last Post: October 7th, 2008, 05:06 PM
  3. recommened usage - multiple item subscription
    By tstojano in forum Client APIs
    Replies: 1
    Last Post: August 13th, 2008, 05:12 PM
  4. subscription came to late
    By michaelvb in forum Adapter APIs
    Replies: 1
    Last Post: May 29th, 2008, 11:07 AM
  5. Replies: 6
    Last Post: May 30th, 2007, 12:47 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
All times are GMT +1. The time now is 08:46 AM.