The Lab

The example requests below can be used to display the available Feeds related to an instance in addition to the available markets on individual Feeds.

Feeds


getFeeds()
    /**
     * After a successful connection is established, you may access the server's
     * list of _feeds, markets. If you have not yet _connected to the server this
     * will return empty.
     */
    public APIFeed[] getFeeds()
    {
        synchronized ( _cfglock ) {
            if ( _feeds.isEmpty() ) {
                _log.severe("Client is not ready for getting configuration.");
            }
            return _feeds.toArray(new APIFeed[_feeds.size()]);
        }
    }



getFeedByName(CharSequence name)
    /**
     * After a successful connection is established, you may access the server's
     * list of _feeds, markets. This method will return a pointer to the feed of
     * a given name if it exists and NULL if it does not. (this class maintains
     * ownership to the object so do not delete it).
     *
     * @return a pointer to the Feed of the given name or NULL if it does not exist.
     */
    public APIFeed getFeedByName(CharSequence name)
    {
        synchronized ( _cfglock ) {
            if ( _feedNameMap.isEmpty() ) {
                _log.severe("Client is not ready for getting configuration.");
            }
            recycleableName.reset();
            recycleableName.append(name);
            return _feedNameMap.get(recycleableName);
        }
    }



getFeedByID(int id)
    /**
     * After a successful connection is established, you may access the server's
     * list of _feeds, markets.  This method will return a pointer to the feed of
     * a given id if it exists and NULL if it does not. (this class maintains
     * ownership to the object so do not delete it).
     *
     *  @return a pointer to the Feed of the given id or NULL if it does not exist.
     */
    public APIFeed getFeedByID(int id)
    {
        synchronized ( _cfglock ) {
            if ( _feedIDMap.isEmpty() ) {
                _log.severe("Client is not ready for getting configuration.");
            }
            return _feedIDMap.get(id);
        }
    }



Markets - MarketID = SecurityID


getMarketByName(APIFeed feed, CharSequence name)
    /**
     * After a successful connection is established, you may access the server's
     * list of _feeds, markets.  This method will return a pointer to the market with
     * a given name within the specified feed if such market exists or NULL if there is
     * no market with the same name.
     *
     *  @return a pointer to the Market with the given name within the given feed or
     * NULL if it does not exist.
     */
    public APIMarket getMarketByName(APIFeed feed, CharSequence name)
    {
        if (feed != null) {
            synchronized ( _cfglock ) {
                recycleableMarketName.reset();
                recycleableMarketName.append(name);
                for (APIMarket m : feed.marketList) {
                    if (m.name.equals(recycleableMarketName)) {
                        return m;
                    }
                }
            }
        }
        return null;
    }



getMarketByID(APIFeed feed, int marketID)
    /**
     * After a successful connection is established, you may access the server's
     * list of _feeds, markets.  This method will return a pointer to the market with
     * a given id within the specified feed if such market exists or NULL if there is
     * no market with the same id.
     *
     *  @return a pointer to the Market with the given market id within the given feed or
     * NULL if it does not exist.
     */
    public APIMarket getMarketByID(APIFeed feed, int marketID)
    {
        synchronized ( _cfglock ) {
            for (APIMarket m : feed.marketList) {
                if (m.marketID == marketID) {
                    return m;
                }
            }
        }
        return null;
    }



  • No labels

1 Comment

  1. Unknown User (tmatsubayashi)

    API handbook and API doc do not have those commands.  In a real life, this may not be necessary much, but it will eliminate some interactions with our support desk.