The OECClient component serves as a gateway to the OEC Server, sending client requests and receiving server responses over the internet. Client session data are represented in form of objects tree available as OECClient instance properies: OECClient.Orders is an collection of orders, for example. See "Data model" section below for details
Client requests are sent by calling component methods, such as CancelOrder, and any changes or additions to session data are visible to client as events (like OnUserMessage)
Network transmission is asynchronous (performed in background), so all method calls do not return immediate results - in most cases client should wait for appropriate event to make sure that requested action succeeded (or failed).
Data Model
Primary object of OEC Data model is an Order. This object contains all information about order lifetime, such as Version, Command and State history, and order Fills - remained or cancelled. OEC API loads all orders from current trading session on logon. Accounting information can be accessed by Account objects. There are open/closed Position statistics and account cash Balance (or several balances for different currencies, if any). Trading environment objects, such as contracts, currencies, exchanges provided easy access to fundamental data. Some additional object types, like BaseContracts and ContractGroups were introduced to maintain structured access. Dynamic data like currency conversion rate, contract last price and depth of market updates are stored in corresponding objects - i.e. Currency and Contract. Theoretical profit/loss for open positions is updated in real-time, when the price feed is avaliable for given contract. All objects can be found in their respective collections by ID or name, or retrieved from another object properties - for example, an order contains references to its account and contract. Note that any date/time values provided by API are in UTC time zone, except the opening/closing times for contracts - which are local to contract exchange.
Getting started
To use the OEC system, first thing that client needs to do is to connect to the OEC Server:
After that, client app should need to wait for one of events: OnLoginComplete or OnLoginFailed In cause of succesfull login, all collections is already populated with session data (order states and fills, account positions), so application could display it on the GUI. If by some reason connection is dropped, OnDisconnected event would be fired immediately, notifying the client that requests couldn't be processed until connection is restored. On a successfull logon system is ready to process client requests: subscriptions to price feeds and order requests.
Example
This code creates and sends an order "Buy 1 ESZ6 MKT"
client will periodially receive OnPriceChanged event every time that market price data is updated, unless he will call OECClient.Unsubscribe method to cancel the subscription.