How to develop an External Connection |
ArthaChitra allow users to develop their own connection. The External Connection can be used for both order submission and appending data (real-time and historical).
The external connection has 3 (three) parts namely:
The configuration properties/parameters of the connection is defined in the the ExternalOptionsBase script. User can configure the parameters by designing xaml templates which we will discuss in the next section.
For more details please refer to the ExternalOptionsBase class definition.
Note: The ConnectionType of an External Options is set to ConnectionType.Live
An External Connection can have its own custom properties/parameter and user may desire to configure the properties/parameters from the GUI. The ExternalOptionsBase class inherits the ITemplate interface and user can design custom Xaml Templates to interact with the properties as defined in the ExternalOption class as created by the user. These user created Xaml Templates will appear in the Add/Edit Connection View while setting up a new External Connection (or while editing it).
If user do not define any template or if the TemplateType is NOT set to TemplateType.Blank then the default template is applied. Currently the default External Options Template is a blank template.
<DataTemplate x:Key="{x:Static bCommon:ResourceKey.DefaultExternalOptionsTemplate}"> </DataTemplate>
The ExternalConnectionBase defines the properties and methods which actually pulls data or submits orders etc. Which connection is associated with the ExternalOptionsBase class is defines by the property ExternalConnectionType.
For more details please refer to the ExternalConnectionBase class.
Note: Most of the methods of the ExternalConnectionBase class are asynchronous. If you consider to await then please set ConfigureAwait to false. The below code futher demonstrates it.
public override async Task SubmitOrder(IOrder order) { await CustomMethodAsync().ConfigureAwait(false); //Note: ConfigureAwait is set to false } private async Task CustomMethodAsync() { //more codes }