Package com.caplin.trading
Interface TradeEvent
- All Known Subinterfaces:
TradeErrorEvent
public interface TradeEvent
A single event acting on a Trade.
The event may be client generated and received through the TradeListener
interface or it may be
generated by custom code to be sent to the client using the Trade.sendEvent(TradeEvent)
method.
A TradeEvent is created using the Trade
it relates to by calling the Trade.createEvent(String)
method of the appropriate Trade instance.
A TradeEvent typically represents a message received from the client or sent by the server. A
message contains a set of fields and values which can be accessed using the
getFields()
method.
A Typical message represented by a TradeEvent might be:
Field | Value |
MsgType | Execute |
MsgVersion | 5 |
RequestId | 123 |
TradeId | 456789 |
PriceVersion | 3 |
BuySell | BUY |
Price | 1.9950 |
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Adds a field to this TradeEvent.void
Adds a field to this TradeEvent.void
addLegAction
(LegAction action) Adds a leg action to the trade.Returns the source of this event: CLIENT, SERVER, or RESTOREGets the value of a field in this TradeEvent.Gets the fields of this TradeEvent as a MapGets the leg actions associated with this event.Gets the source of this TradeEvent.getTrade()
Gets theTrade
object that this TradeEvent belongs to.getType()
Gets the type of the TradeEvent.boolean
Confirms that the TradeEvent is of a certain typevoid
setInitialTimestamp
(Date date) Sets LTY_INIT_TS field to this TradeEvent.void
setRestorationId
(String restorationId) Sets an id that will identify a trade restoration message.
-
Method Details
-
getType
String getType()Gets the type of the TradeEvent.- Returns:
- The type of this event.
-
isType
Confirms that the TradeEvent is of a certain type- Parameters:
type
- The trade type to check.- Returns:
- True if the requested type matches the TradeEvent type.
-
getTrade
Trade getTrade()Gets theTrade
object that this TradeEvent belongs to. As long as your code executes on the thread in whichTradeListener.receiveEvent(TradeEvent)
was called, theTrade
's fields will not be updated by subsequent events, though its state may change.- Returns:
- The
Trade
object.
-
getSource
String getSource()Gets the source of this TradeEvent.- Returns:
- The name of the source of this TradeEvent.
-
setRestorationId
Sets an id that will identify a trade restoration message. A restoration id should be supplied for the first TradeEvent on a client opened trade. This identifier should be retreived from the system that the Trading DataSource is integrating with.- Parameters:
restorationId
- the system identifier for the trade.- See Also:
-
addField
Adds a field to this TradeEvent.- Parameters:
name
- The name of the field to add.value
- The value of the field to add.
-
addField
Adds a field to this TradeEvent.- Parameters:
name
- The name of the field to add.value
- The value of the field to add.
-
setInitialTimestamp
Sets LTY_INIT_TS field to this TradeEvent.- Parameters:
date
- The time the LTY_INIT_TS field will be set to.
-
getField
Gets the value of a field in this TradeEvent.- Parameters:
name
- The name of the field.- Returns:
- The value of the named field.
-
addLegAction
Adds a leg action to the trade. This method is typically used when leg changes need to be made from the server side.- Parameters:
action
- The leg action.
-
getLegActions
Gets the leg actions associated with this event. This method is typically used when the server receives a trade event from the client using theTradeListener
interface and needs to determine what leg actions the client has performed on the trade.- Returns:
- A list of leg actions.
-
getFields
Gets the fields of this TradeEvent as a Map- Returns:
- a map of the fields;
-
getEventSource
EventSource getEventSource()Returns the source of this event: CLIENT, SERVER, or RESTORE- Returns:
- a map of the fields;
-