MFMarketMaker (3.14.0 400 API)
Date: 2018-11-22

com.marketfactory.zerogc.api

## Class MFMarketMaker

- java.lang.Object
- - com.marketfactory.zerogc.api.MFMarketMaker

-     public class MFMarketMaker
      extends java.lang.Object

- - ### Constructor Summary

    Constructors
    Constructor and Description
    `MFMarketMaker(MFString _username, MFString _password, MFString _hostname1, int _port1)` A new client still needs to be connected (see connect()).
    `MFMarketMaker(MFString _username, MFString _password, MFString _hostname1, int _port1, MFString _hostname2, int _port2)` A new client still needs to be connected (see connect()).

  - ### Method Summary

    All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods
    Modifier and Type | Method and Description
    --- | ---
    `APIResult` | `acceptOrder(NewOrder order)` Note: if NewOrder.orderID/execID is not provided by the venue, you must generate one.
    `APIResult` | `acceptOrder(NewOrder order, MFFloat amount)` This method is for sending partial fills.
    `APIResult` | `cancelQuote(QuoteRequest request, MFString quoteID)`
    `APIResult` | `cancelQuoteForSymbol(QuoteRequest request)`
    `APIResult` | `cancelQuotes(QuoteRequest quoteRequest)`
    `APIResult` | `close()` Close the connection.
    `APIResult` | `connect()` Connect to the first available server with user credentials.
    `APIFeed` | `getFeedByID(int id)` After a successful connection is established, you may access the server's list of _feeds, markets.
    `APIFeed` | `getFeedByName(java.lang.CharSequence name)` After a successful connection is established, you may access the server's list of _feeds, markets.
    `APIFeed[]` | `getFeeds()` After a successful connection is established, you may access the server's list of _feeds, markets.
    `MFString` | `getHostname()`
    `java.util.List<PingTime>` | `getLastPingTimes()` Gets the list of most recently stored PingTime objects from oldest to most recent - if any.
    `APIMarket` | `getMarketByID(APIFeed feed, int marketID)` After a successful connection is established, you may access the server's list of _feeds, markets.
    `APIMarket` | `getMarketByName(APIFeed feed, java.lang.CharSequence name)` After a successful connection is established, you may access the server's list of _feeds, markets.
    `int` | `getPort()`
    `int` | `getSequenceID(int feedID)` Get the last received sequenceID.
    `MFString` | `getSignature()`
    `boolean` | `isConnected()`
    `boolean` | `isRunning()`
    `boolean` | `isStopRequested()`
    `APIResult` | `join()` Block until the client has exited the dispatch loop.
    `static MFMarketMaker` | `open(java.lang.String user, java.lang.String pass, java.lang.String host, int port)` A convenience method which creates a new client object, attempts to connect to Whisperer, and cleans up and throws an exception if we could not connect.
    `static MFMarketMaker` | `open(java.lang.String user, java.lang.String pass, java.lang.String _hostname1, int _port1, java.lang.String _hostname2, int _port2)` A convenience method which creates a new client object, attempts to connect to Whisperer, and cleans up and throws an exception if we could not connect.
    `APIResult` | `processEvents(MFMarketMakerHandler _handler)` Process all pending events in the reactor, and return as soon as reads/writes have been flushed.
    `APIResult` | `rejectOrder(NewOrder order, MFString text)` Note: if NewOrder.orderID/execID is not provided by the venue, you must generate one.
    `APIResult` | `rejectQuoteRequest(QuoteRequest clientQuoteRequest, QuoteRequestRejectReason reason, MFString text)`
    `APIResult` | `replay(int feedID, int fromSequenceID, int toSequenceID)` Request replay of order flow events in the range [fromSequenceID, toSequenceID=-1].
    `APIResult` | `run(MFMarketMakerHandler handler)` Run a loop that will continuously dispatch incoming messages to a _handler implementation.
    `void` | `setDebug(boolean debug)` Deprecated. MF devs only - set the mode using a JVM arg - `Options.MF_DEV_LOG_DEBUG_MESSAGES_JVM_ARG`
    `void` | `setStickySubscriptions(boolean sticky)` Enable/Disable sticky subscriptions.
    `void` | `setStickySubscriptions(boolean sticky, boolean clearSubscriptionsOnStop)`
    `void` | `setUseHeartbeat(boolean use)`
    `APIResult` | `stop()` Request to stop the event dispatch loop.
    `APIResult` | `submitQuotes(QuoteRequest request, MFQuote[] quotes)` Note: If QuoteRequest does not arrive with a valid amount, you must fill one in.
    `APIResult` | `subscribeOF(int feedID)` Subscribe to trading for a specific feed.
    `protected APIResult` | `subscribeOF(int feedID, MFString clSubID)` Subscribe to trading for a specific feed.
    `APIResult` | `subscribePricing(int feedID, MFString clSubID)`
    `APIResult` | `subscribeTrading(int feedID, MFString clSubID)`
    `APIResult` | `unsubscribeAll()` Unsubscribe all market data and trading subscriptions.
    `APIResult` | `unsubscribeOF(int feedID)` Unsubscribe to trading for a specific feed.
    `APIResult` | `unsubscribeOF(int feedID, MFString clSubID)` Unsubscribe to trading for a specific feed.
    `APIResult` | `unsubscribePricing(int feedID, MFString clSubID)`
    `APIResult` | `unsubscribeTrading(int feedID, MFString clSubID)`

    - ### Methods inherited from class java.lang.Object

      `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- - ### Constructor Detail

    - #### MFMarketMaker

          public MFMarketMaker(MFString _username,
                               MFString _password,
                               MFString _hostname1,
                               int _port1)

      A new client still needs to be connected (see connect()).
      Parameters:
        `_username` - -- username
        `_password` - -- password
        `_hostname1` - -- primary host
        `_port1` - -- primary port

    - #### MFMarketMaker

          public MFMarketMaker(MFString _username,
                               MFString _password,
                               MFString _hostname1,
                               int _port1,
                               MFString _hostname2,
                               int _port2)

      A new client still needs to be connected (see connect()).
      Parameters:
        `_username` - -- username
        `_password` - -- password
        `_hostname1` - -- primary host
        `_port1` - -- primary port
        `_hostname2` - -- secondary host
        `_port2` - -- secondary port

  - ### Method Detail

    - #### run

          public APIResult run(MFMarketMakerHandler handler)

      Run a loop that will continuously dispatch incoming messages to a _handler implementation. This method returns some time after a request to stop is made using stop(), or if an error occurs (e.g. the connection is broken). A zero return value indicates a normal exit via a stop request. If the connection is broken and the client succesfully fails over to a secondary server, this dispatcher does not return; onDisconnect() and onConnect() are invoked to let the handler know that this occurred. If the reconnection attempt is not successful, the dispatcher will return an error code. Every call to run() must be preceded by a successful connect() -- this call is made for you, but only once, when a client is obtained via open(). Note: this should not be invoked by _handler.
      Parameters:
        `handler` - to be run
      Returns:
        the result of running the handler

    - #### open

          public static MFMarketMaker open(java.lang.String user,
                                           java.lang.String pass,
                                           java.lang.String host,
                                           int port)
                                    throws java.io.IOException

      A convenience method which creates a new client object, attempts to connect to Whisperer, and cleans up and throws an exception if we could not connect. Otherwise the new client object is returned;
      Parameters:
        `user` - -- username
        `pass` - -- password
        `host` - -- primary host
        `port` - -- primary port
      Returns:
        the connected market maker
      Throws:
        `java.io.IOException` - when connection fails

    - #### open

          public static MFMarketMaker open(java.lang.String user,
                                           java.lang.String pass,
                                           java.lang.String _hostname1,
                                           int _port1,
                                           java.lang.String _hostname2,
                                           int _port2)
                                    throws java.io.IOException

      A convenience method which creates a new client object, attempts to connect to Whisperer, and cleans up and throws an exception if we could not connect. Otherwise the new client object is returned;
      Parameters:
        `user` - -- username
        `pass` - -- password
        `_hostname1` - -- primary host
        `_port1` - -- primary port
        `_hostname2` - -- secondary host
        `_port2` - -- secondary port
      Returns:
        the connected market maker
      Throws:
        `java.io.IOException` - when connection fails

    - #### subscribeOF

          protected APIResult subscribeOF(int feedID,
                                          MFString clSubID)

      Subscribe to trading for a specific feed. onSubscriptionEvent() will be called to notify that the order gateway is ready. If the subscription is valid, it will be possible to submit and cancel orders and receive trading events.
      Parameters:
        `feedID` - the feed id
        `clSubID` - the client subscription id
      Returns:
        APIResult.OK if the subscription request has been sent, APIResult.SOCKERR_WRITING on error.

    - #### unsubscribeOF

          public APIResult unsubscribeOF(int feedID,
                                         MFString clSubID)

      Unsubscribe to trading for a specific feed.
      Parameters:
        `feedID` - the feed id
        `clSubID` - the client subscription id
      Returns:
        APIResult.OK if the unsubscription request has been sent, APIResult.SOCKERR_WRITING on error.

    - #### subscribeOF

          public APIResult subscribeOF(int feedID)

      Subscribe to trading for a specific feed. onSubscriptionEvent() will be called to notify that the order gateway is ready. If the subscription is valid, it will be possible to submit and cancel orders and receive trading events.
      Parameters:
        `feedID` - the feed id
      Returns:
        APIResult.OK if the subscription request has been sent, APIResult.SOCKERR_WRITING on error.

    - #### unsubscribeOF

          public APIResult unsubscribeOF(int feedID)

      Unsubscribe to trading for a specific feed.
      Parameters:
        `feedID` - the feed id
      Returns:
        APIResult.OK if the unsubscription request has been sent, APIResult.SOCKERR_WRITING on error.

    - #### subscribeTrading

          public APIResult subscribeTrading(int feedID,
                                            MFString clSubID)

    - #### unsubscribeTrading

          public APIResult unsubscribeTrading(int feedID,
                                              MFString clSubID)

    - #### subscribePricing

          public APIResult subscribePricing(int feedID,
                                            MFString clSubID)

    - #### unsubscribePricing

          public APIResult unsubscribePricing(int feedID,
                                              MFString clSubID)

    - #### unsubscribeAll

          public APIResult unsubscribeAll()

      Unsubscribe all market data and trading subscriptions. Call this if you want to stop receiving callbacks but don't want to disconnect.
      Returns:
        APIResult.OK if the unsubscription request has been sent, APIResult.SOCKERR_WRITING on error.

    - #### rejectQuoteRequest

          public APIResult rejectQuoteRequest(QuoteRequest clientQuoteRequest,
                                              QuoteRequestRejectReason reason,
                                              MFString text)

    - #### cancelQuotes

          public APIResult cancelQuotes(QuoteRequest quoteRequest)

    - #### cancelQuote

          public APIResult cancelQuote(QuoteRequest request,
                                       MFString quoteID)

    - #### cancelQuoteForSymbol

          public APIResult cancelQuoteForSymbol(QuoteRequest request)

    - #### submitQuotes

          public APIResult submitQuotes(QuoteRequest request,
                                        MFQuote[] quotes)

      Note: If QuoteRequest does not arrive with a valid amount, you must fill one in.
      Parameters:
        `request` - -- the quote request
        `quotes` - -- 0 or more quotes to be submitted
      Returns:
        the result of sending this message

    - #### rejectOrder

          public APIResult rejectOrder(NewOrder order,
                                       MFString text)

      Note: if NewOrder.orderID/execID is not provided by the venue, you must generate one.
      Parameters:
        `order` - -- the order being rejected
        `text` - -- why
      Returns:
        the result of sending the reject

    - #### acceptOrder

          public APIResult acceptOrder(NewOrder order)

      Note: if NewOrder.orderID/execID is not provided by the venue, you must generate one.
      Parameters:
        `order` - -- the accepted order
      Returns:
        the result of sending the order

    - #### acceptOrder

          public APIResult acceptOrder(NewOrder order,
                                       MFFloat amount)

      This method is for sending partial fills. Put the partial amount in the amount field. Note: if NewOrder.orderID/execID is not provided by the venue, you must generate one.
      Parameters:
        `order` - -- order that is accepted
        `amount` - -- the amount
      Returns:
        the result of sending the accepted order msg.

    - #### setUseHeartbeat

          public void setUseHeartbeat(boolean use)

    - #### setDebug

          public void setDebug(boolean debug)

      Deprecated. MF devs only - set the mode using a JVM arg - `Options.MF_DEV_LOG_DEBUG_MESSAGES_JVM_ARG`
      Sets debug mode. Intended for Internal MF Devs only.
      Parameters:
        `debug` - debug mode true or false.

    - #### getLastPingTimes

          public java.util.List<PingTime> getLastPingTimes()

      Gets the list of most recently stored PingTime objects from oldest to most recent - if any.
      Note:You must have heartbeats turned on to have pings calculated.

      Refer to `PingHandler.getLastPingTimes()`

      Returns:
        received PingTime objects in order of oldest to most recent

    - #### setStickySubscriptions

          public void setStickySubscriptions(boolean sticky)

      Enable/Disable sticky subscriptions. Set clearSubscriptionsOnStop=false if subscriptions should persist on disconnect/stop/start.
      Parameters:
        `sticky` - - sticky subscription. or ot

    - #### setStickySubscriptions

          public void setStickySubscriptions(boolean sticky,
                                             boolean clearSubscriptionsOnStop)

    - #### isConnected

          public boolean isConnected()

      Returns:
        true if the _channel is _connected.

    - #### connect

          public APIResult connect()

      Connect to the first available server with user credentials.
      Returns:
        APIResult.OK if the connection attempt succeeded. Note: this should not be invoked by _handler.

    - #### close

          public APIResult close()

      Close the connection. (This can only be called this when you're not dispatching.) Note: this should not be invoked by _handler.
      Returns:
        the result of closing the connection.

    - #### isRunning

          public boolean isRunning()

      Returns:
        true if the client is currently dispatching events (i.e., you called run()).

    - #### stop

          public APIResult stop()

      Request to stop the event dispatch loop. Does not disconnect the client from the server.
      Returns:
        the call result

    - #### isStopRequested

          public boolean isStopRequested()

    - #### join

          public APIResult join()

      Block until the client has exited the dispatch loop. Note: this should not be invoked by _handler.
      Returns:
        the call result

    - #### processEvents

          public APIResult processEvents(MFMarketMakerHandler _handler)

      Process all pending events in the reactor, and return as soon as reads/writes have been flushed. This can be used to integrate our API within a GUI toolkit's event processing loop without having to create a secondary thread.
      Parameters:
        `_handler` - -- the handler to be run
      Returns:
        the result of running the handler

    - #### getSignature

          public MFString getSignature()

      Returns:
        Get protocol api signature.

    - #### getSequenceID

          public int getSequenceID(int feedID)

      Get the last received sequenceID.
      Parameters:
        `feedID` - the feed id
      Returns:
        -2 if not connected; -1 if there are no OF messages for the client on the feed.

    - #### getFeeds

          public APIFeed[] 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.
      Returns:
        the feeds

    - #### getFeedByName

          public APIFeed getFeedByName(java.lang.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).
      Parameters:
        `name` - -- the feed name
      Returns:
        a pointer to the Feed of the given name or NULL if it does not exist.

    - #### getFeedByID

          public APIFeed 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).
      Parameters:
        `id` - -- the feed id
      Returns:
        a pointer to the Feed of the given id or NULL if it does not exist.

    - #### getMarketByName

          public APIMarket getMarketByName(APIFeed feed,
                                           java.lang.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.
      Parameters:
        `feed` - -- the feed
        `name` - -- the market name
      Returns:
        a pointer to the Market with the given name within the given feed or NULL if it does not exist.

    - #### getMarketByID

          public APIMarket 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.
      Parameters:
        `feed` - -- feed id
        `marketID` - -- market id
      Returns:
        a pointer to the Market with the given market id within the given feed or NULL if it does not exist.

    - #### getHostname

          public MFString getHostname()

      Returns:
        the primary/secondary server hostname (whichever one is being used). Does not indicate whether a connection is in progress or successfully established.

    - #### getPort

          public int getPort()

      Returns:
        the primary/secondary server port (whichever one is being used). Does not indicate whether a connection is in progress or successfully established.

    - #### replay

          public APIResult replay(int feedID,
                                  int fromSequenceID,
                                  int toSequenceID)

      Request replay of order flow events in the range [fromSequenceID, toSequenceID=-1]. Only open-ended requests are accepted by the server.
      Parameters:
        `feedID` - -- the feed id
        `fromSequenceID` - -- starting sequence id
        `toSequenceID` - -- end sequence id
      Returns:
        APIResult.OK if the replay request has been sent, APIResult.SOCKERR_WRITING on error.