|
typedef struct ctl_trade_s | ctl_trade |
| Opaque handle representing a trade. More...
|
|
|
const char * | ctl_trade_get_field (ctl_provider *provider, ctl_channel *channel, ctl_trade *trade, const char *fieldname) |
| Get a field that is stored on the trade. More...
|
|
const char * | ctl_trade_get_protocol (ctl_provider *provider, ctl_channel *channel, ctl_trade *trade) |
| Get the name of the trade model that is in use for the specified trade. More...
|
|
const char * | ctl_trade_get_requestid (ctl_provider *provider, ctl_channel *channel, ctl_trade *trade) |
| Get the client generated identifier that is in use for the specified trade. More...
|
|
const char * | ctl_trade_get_state (ctl_provider *provider, ctl_channel *channel, ctl_trade *trade) |
| Get the current state of the specified trade. More...
|
|
void * | ctl_trade_get_user_pointer (ctl_provider *provider, ctl_channel *channel, ctl_trade *trade) |
| Gets the user pointer on the ctl_trade object. More...
|
|
ctl_error | ctl_trade_process_event (ctl_provider *provider, ctl_channel *channel, ctl_trade *trade, ctl_tradeevent *tradeevent) |
| Process an event for the specified trade. More...
|
|
void | ctl_trade_set_listener (ctl_provider *provider, ctl_channel *channel, ctl_trade *trade, ctl_trade_listener *listener, void *context) |
| Set the listener for the specified trade. More...
|
|
void | ctl_trade_set_user_pointer (ctl_provider *provider, ctl_channel *channel, ctl_trade *trade, void *ptr) |
| Set a user pointer on the ctl_trade object. More...
|
|
A Trade represents single Trade active in the system.
A Trade is initiated by a client and is tied to a ctl_channel. The lifecycle of a Trade consists of a number of messages, represented by TradeEvents, being sent between the client and the Trading System in both directions. These messages cause the Trade to transition between a number of predefined states.
A Trade is uniquely identified in two ways: by RequestId set by the client and a TradeId set by the Trading System.
Opaque handle representing a trade.
Error codes used by the library.
See ctl_error_tostring() which returns a textual description of the logging level.
Enumerator |
---|
ctl_error_OK |
No error, operation successful
|
ctl_error_FAILED_SOURCE_GUARD |
The trade event supplied failed the source guard validation
|
ctl_error_INVALID_TRANSITION |
The trade event supplied is not valid for the current trade state
|
ctl_error_UNKNOWN_CHANNEL |
A trade event was received for an unknown trade channel
|
ctl_error_UNKNOWN_TRADE |
A trade event was received for an unknown trade
|
ctl_error_INVALID_PARAMETERS |
Invalid parameters have been given to the call
|
ctl_error_MISSING_REQUIRED_FIELD |
A required field in the trade event is missing
|
Get a field that is stored on the trade.
- Parameters
-
provider | - The trading provider |
channel | - The trade channel |
trade | - The trade to set the listener on |
fieldname | - The fieldname to obtain the value of |
- Returns
- The field value (or NULL should there be no field, or the trade or channel does not exist)
- Note
- The returned field value should not be freed.
-
The returned field value is only valid if this function is called from a Trading API callback.
Get the name of the trade model that is in use for the specified trade.
- Parameters
-
provider | - The trading provider |
channel | - The trade channel |
trade | - The trade to set the listener on |
- Returns
- The trade model (or NULL should the trade or channel not exist)
- Note
- The returned field value is only valid if this function is called from a Trading API callback.
Get the client generated identifier that is in use for the specified trade.
- Parameters
-
provider | - The trading provider |
channel | - The trade channel |
trade | - The trade to set the listener on |
- Returns
- The identifier (or NULL should the trade or channel not exist)
- Note
- The return value should not be freed.
Get the current state of the specified trade.
- Parameters
-
provider | - The trading provider |
channel | - The trade channel |
trade | - The trade to set the listener on |
- Returns
- The current trade state (or NULL should the trade or channel not exist)
- Note
- The return value should not be freed.
Gets the user pointer on the ctl_trade object.
- Parameters
-
provider | - The trading provider |
channel | - The trade channel |
trade | - The trade to set the listener on |
- Returns
- The previously set user pointer (or NULL should channel or trade not exist)
Process an event for the specified trade.
- Parameters
-
provider | - The trading provider |
channel | - The trade channel |
trade | - The trade to set the listener on |
tradeevent | - The trade event to process |
- Returns
- An error code
- Note
- The tradeevent is always freed by this function.
Set the listener for the specified trade.
- Parameters
-
provider | - The trading provider |
channel | - The trade channel |
trade | - The trade to set the listener on |
listener | - The listener to call |
context | - A context pointer for the listener |
The registered listener will be invoked when an event is received for the trade.
- Note
- To avoid race conditions or missed notifications, this function should be called within ctl_channel_listener::trade_created()
Set a user pointer on the ctl_trade object.
- Parameters
-
provider | - The trading provider |
channel | - The trade channel |
trade | - The trade to set the listener on |
ptr | - the pointer to store |
This function can be called to stash a user pointer against a trade object. This is of use if this C API is being wrapped to present a C++ or Objective-C API to your application.