A TradeEvent represents a single event acting on a Trade.
The event may be client generated and received through the ctl_trade_listener interface or it may be generated by custom code to be sent to the client using the ctl_trade_process_event() method.
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 ctl_tradeevent_get_field() and ctl_tradeevent_get_fields() methods.
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 |
Opaque handle representing a trade event.
Create a new trade event.
- Parameters
-
provider | - The trading provider |
channel | - The trade channel |
trade | - The trade to set the listener on |
type | - The type of tradeevent to create (for example Open, Ack etc) |
- Returns
- A new trade event (or NULL should the trade or channel not exist)
- Note
- This function can be called from any thread within your application.
void ctl_tradeevent_add_field |
( |
ctl_tradeevent * |
ev, |
|
|
const char * |
name, |
|
|
const char * |
value |
|
) |
| |
Add a field to a trade event.
- Parameters
-
ev | - The trade event to add the field to. |
name | - The name of the field to add. |
value | - The value of the field to add |
Free up the trade event.
- Parameters
-
const char* ctl_tradeevent_get_field |
( |
ctl_tradeevent * |
ev, |
|
|
const char * |
name |
|
) |
| |
Gets the value of a field on the tradeevent.
- Parameters
-
ev | - The tradeevent to query |
name | - The name of the field to get |
- Returns
- The field value or NULL if the field isn't present
- Note
- The return value should not be freed.
char const** ctl_tradeevent_get_fields |
( |
ctl_tradeevent * |
ev, |
|
|
int * |
num_ptr |
|
) |
| |
Gets all fields on the trade event.
- Parameters
-
ev | - The tradeevent to query |
num_ptr | - Pointer to integer that will hold the number of fields on the event |
- Returns
- An array of fields.
The fields are stored as fields[0] = fieldname0, fields[1] = fieldvalue0, fields[2]=fieldname1, fields[3]=fieldvalue1.
The returned value should be freed with ctl_free()
Get the type of the trade event.
- Parameters
-
ev | - The tradeevent to query |
- Returns
- The type of the trade event
- Note
- The return value should not be freed.