Beispiel #1
0
 /// <summary>
 /// Log out
 /// </summary>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 /// <returns></returns>
 public void BeginLogOut(ReliableAsyncCallback callback, object state)
 {
     BeginRequest(RequestMethod.POST, "session", "/deleteSession?userName={userName}&session={session}",
                  new Dictionary <string, object>
     {
         { "userName", UserName },
         { "session", Session },
     }, ContentType.JSON, ContentType.JSON, TimeSpan.FromMilliseconds(0), 30000, 2, callback, state);
 }
        public ReliableAsyncResult(ReliableAsyncCallback cb, object state, bool completed, string responseText, ReliableHttpException error)
        {

            _id = Guid.NewGuid();
            _callback = cb;
            _asyncState = state;
            _completed = completed;
            _completedSynchronously = completed;
            ResponseText = responseText;
            _error = error;
            _status = RequestNotificationStatus.Continue;
            if (_completed && (_callback != null))
            {
                _callback(this);
            }
        }
Beispiel #3
0
 /// <summary>
 /// Log In
 /// </summary>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 /// <param name="userName">Username is case sensitive</param>
 /// <param name="password">Password is case sensitive</param>
 /// <returns></returns>
 public void BeginLogIn(String userName, String password, ReliableAsyncCallback callback,
                        object state)
 {
     UserName = userName;
     Session  = null;
     BeginRequest(RequestMethod.POST, "session", "/", new Dictionary <string, object>
     {
         { "apiLogOnRequest", new ApiLogOnRequestDTO()
           {
               UserName   = userName,
               Password   = password,
               AppKey     = AppKey,
               AppVersion = "CIAPI.CS"
                            // #TODO: stop putting version in this DTO - cannot record with versions changing. Version is available in headers
           } }
     }, ContentType.JSON, ContentType.JSON, TimeSpan.Zero, 30000, 2, callback, state);
 }
 public void BeginGetTestClassWithException(ReliableAsyncCallback callback, object state)
 {
     BeginRequest(
         RequestMethod.GET,
         _target,
         "/SampleClientHandler.ashx?throw={throw}",
         new Dictionary<string, string>(),
         new Dictionary<string, object>
             {
                 { "throw", "true" }
             },
         ContentType.TEXT,
         ContentType.JSON,
         TimeSpan.FromSeconds(1),
         3000,
         2,
         callback,
         state);
 }
        private RequestInfo CreateRequest(Uri uri, RequestMethod method, string body, Dictionary<string, string> headers,
                                          ContentType requestContentType, ContentType responseContentType,
                                          TimeSpan cacheDuration, int timeout, string target, string uriTemplate,
                                          int retryCount, Dictionary<string, object> parameters,
                                          ReliableAsyncCallback callback, object state)
        {
            RequestInfo info;


            info = RequestInfo.Create(method, target, uriTemplate, parameters, UserAgent, headers,
                                                  requestContentType, responseContentType, cacheDuration, timeout,
                                                  retryCount, uri, body, _requestFactory);

            info.BuildRequest(_requestFactory);
            info.AddCallback(ar =>
            {

                var info2 = (RequestInfo)ar.AsyncState;
                RequestInfoBase copy = info2.Copy();
                OnRequestCompleted(copy);
            }, info);


            info.ProcessingComplete += CompleteRequest;
            if (callback != null)
            {
                info.AddCallback(callback, state);
            }
            return info;
        }
Beispiel #6
0
 /// <summary>
 /// Queries for a specified trading account's active stop / limit orders. This URI is intended to support a grid in a UI. One usage pattern is to subscribe to streaming orders, call this for the initial data to display in the grid, and call the HTTP service [GetActiveStopLimitOrder](http://labs.cityindex.com/docs/Content/HTTP%20Services/GetActiveStopLimitOrder.htm) when you get updates on the order stream to get the updated data in this format. **Notes on Parameters** >**ClientAccountId** - this can be passed in order to retrieve all information on all trading accounts for which it is the parent. >**TradingAccountId** - this can be passed to retrieve information specific to a certain trading account *(the child of ClientAccount)*.  If *neither* ClientAccountId nor TradingAccountId is passed, then the information returned by default from the API is ClientAccount.
 /// </summary>
 /// <param name="TradingAccountId">The ID of the trading account to get orders for.</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public virtual void BeginListActiveStopLimitOrders(int TradingAccountId, ReliableAsyncCallback callback, object state)
 {
     string uriTemplate = "/activestoplimitorders?TradingAccountId={TradingAccountId}";
     _client.BeginRequest(RequestMethod.GET, "order", uriTemplate , 
     new Dictionary<string, object>
     {
         { "TradingAccountId", TradingAccountId}
     },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(0), 30000,2 ,callback, state);
 }
Beispiel #7
0
 /// <summary>
 /// Get the detail of the specific news story matching the story ID in the parameter.
 /// </summary>
 /// <param name="source">The news feed source provider. Valid options are **dj**|**mni**|**ci**.</param>
 /// <param name="storyId">The news story ID.</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public virtual void BeginGetNewsDetail(string source, string storyId, ReliableAsyncCallback callback, object state)
 {
     string uriTemplate = "/{source}/{storyId}";
     _client.BeginRequest(RequestMethod.GET, "news", uriTemplate , 
     new Dictionary<string, object>
     {
         { "source", source}, 
         { "storyId", storyId}
     },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(10000), 30000,2 ,callback, state);
 }
Beispiel #8
0
 /// <summary>
 /// Get Market Information for the single specified market supplied in the parameter.
 /// </summary>
 /// <param name="MarketId">The market ID.</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public virtual void BeginGetMarketInformation(string MarketId, ReliableAsyncCallback callback, object state)
 {
     string uriTemplate = "/{MarketId}/information";
     _client.BeginRequest(RequestMethod.GET, "market", uriTemplate , 
     new Dictionary<string, object>
     {
         { "MarketId", MarketId}
     },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(1000), 30000,2 ,callback, state);
 }
Beispiel #9
0
 /// <summary>
 /// Get historic price bars for the specified market in OHLC *(open, high, low, close)* format, suitable for plotting in candlestick charts. Returns price bars in ascending order up to the current time. When there are no prices for a particular time period, no price bar is returned. Thus, it can appear that the array of price bars has "gaps", i.e. the gap between the date &amp; time of each price bar might not be equal to interval x span.  Sample Urls: * /market/1234/history?interval=MINUTE&amp;span=15&amp;PriceBars=180 * /market/735/history?interval=HOUR&amp;span=1&amp;PriceBars=240 * /market/1577/history?interval=DAY&amp;span=1&PriceBars=10
 /// </summary>
 /// <param name="MarketId">The ID of the market.</param>
 /// <param name="interval">The pricebar interval.</param>
 /// <param name="span">The number of each interval per pricebar.</param>
 /// <param name="PriceBars">The total number of price bars to return.</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public virtual void BeginGetPriceBars(string MarketId, string interval, int span, string PriceBars, ReliableAsyncCallback callback, object state)
 {
     string uriTemplate = "/{MarketId}/barhistory?interval={interval}&span={span}&PriceBars={PriceBars}";
     _client.BeginRequest(RequestMethod.GET, "market", uriTemplate , 
     new Dictionary<string, object>
     {
         { "MarketId", MarketId}, 
         { "interval", interval}, 
         { "span", span}, 
         { "PriceBars", PriceBars}
     },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(0), 30000,2 ,callback, state);
 }
Beispiel #10
0
 /// <summary>
 /// Get a list of current news headlines.
 /// </summary>
 /// <param name="source">The news feed source provider. Valid options are: **dj**|**mni**|**ci**.</param>
 /// <param name="category">Filter headlines by category. Valid categories depend on the source used:  for **dj**: *uk*|*aus*, for **ci**: *SEMINARSCHINA*, for **mni**: *ALL*.</param>
 /// <param name="maxResults">Specify the maximum number of headlines returned.</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public virtual void BeginListNewsHeadlinesWithSource(string source, string category, int maxResults, ReliableAsyncCallback callback, object state)
 {
     string uriTemplate = "/{source}/{category}?MaxResults={maxResults}";
     _client.BeginRequest(RequestMethod.GET, "news", uriTemplate , 
     new Dictionary<string, object>
     {
         { "source", source}, 
         { "category", category}, 
         { "maxResults", maxResults}
     },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(10000), 30000,2 ,callback, state);
 }
Beispiel #11
0
 /// <summary>
 /// Gets version information for a specific client application and *(optionally)* account operator.
 /// </summary>
 /// <param name="AppKey">A string to uniquely identify the application.</param>
 /// <param name="AccountOperatorId">An optional parameter to identify the account operator string to uniquely identify the application.</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public virtual void BeginGetVersionInformation(string AppKey, int AccountOperatorId, ReliableAsyncCallback callback, object state)
 {
     string uriTemplate = "?AppKey={AppKey}&AccountOperatorId={AccountOperatorId}";
     _client.BeginRequest(RequestMethod.GET, "clientapplication/versioninformation", uriTemplate , 
     new Dictionary<string, object>
     {
         { "AppKey", AppKey}, 
         { "AccountOperatorId", AccountOperatorId}
     },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(360000), 30000,2 ,callback, state);
 }
Beispiel #12
0
 /// <summary>
 /// Delete a session. This is how you "log off" from the CIAPI.
 /// </summary>
 /// <param name="UserName">Username is case sensitive. May be set as a service parameter or as a request header.</param>
 /// <param name="Session">The session token. May be set as a service parameter or as a request header.</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 internal virtual void BeginDeleteSession(string UserName, string Session, ReliableAsyncCallback callback, object state)
 {
     string uriTemplate = "/deleteSession?UserName={UserName}&session={session}";
     _client.BeginRequest(RequestMethod.POST, "session", uriTemplate , 
     new Dictionary<string, object>
     {
         { "UserName", UserName}, 
         { "Session", Session}
     },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(0), 30000,0 ,callback, state);
 }
Beispiel #13
0
        /// <summary>
        /// Gets all watchlists for the user account. There are no parameters for this call.
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="state"></param>
        public virtual void BeginGetWatchlists( ReliableAsyncCallback callback, object state)
        {
            string uriTemplate = "/";
            _client.BeginRequest(RequestMethod.GET, "watchlists", uriTemplate , 
            new Dictionary<string, object>
            {

            },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(0), 30000,2 ,callback, state);
        }
Beispiel #14
0
 /// <summary>
 /// Update an order *(for adding a stop/limit or attaching an OCO relationship)*.
 /// </summary>
 /// <param name="order">The update order request.</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public virtual void BeginUpdateOrder(UpdateStopLimitOrderRequestDTO order, ReliableAsyncCallback callback, object state)
 {
     string uriTemplate = "/updatestoplimitorder";
     _client.BeginRequest(RequestMethod.POST, "order", uriTemplate , 
     new Dictionary<string, object>
     {
         { "order", order}
     },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(0), 30000,0 ,callback, state);
 }
Beispiel #15
0
 /// <summary>
 /// Cancel an order.
 /// </summary>
 /// <param name="cancelOrder">The cancel order request.</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public virtual void BeginCancelOrder(CancelOrderRequestDTO cancelOrder, ReliableAsyncCallback callback, object state)
 {
     string uriTemplate = "/cancel";
     _client.BeginRequest(RequestMethod.POST, "order", uriTemplate , 
     new Dictionary<string, object>
     {
         { "cancelOrder", cancelOrder}
     },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(0), 30000,0 ,callback, state);
 }
Beispiel #16
0
 /// <summary>
 /// Delete client preference key.
 /// </summary>
 /// <param name="clientPreferenceKey">The client preference key to delete.</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public virtual void BeginDelete(ClientPreferenceRequestDTO clientPreferenceKey, ReliableAsyncCallback callback, object state)
 {
     string uriTemplate = "/delete";
     _client.BeginRequest(RequestMethod.POST, "clientpreference", uriTemplate , 
     new Dictionary<string, object>
     {
         { "clientPreferenceKey", clientPreferenceKey}
     },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(0), 30000,0 ,callback, state);
 }
Beispiel #17
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="method"></param>
        /// <param name="target"></param>
        /// <param name="uriTemplate"></param>
        /// <param name="parameters"></param>
        /// <param name="requestContentType"></param>
        /// <param name="responseContentType"></param>
        /// <param name="cacheDuration"></param>
        /// <param name="timeout"></param>
        /// <param name="retryCount"></param>
        /// <param name="callback"></param>
        /// <param name="state"></param>
        /// <returns></returns>
        /// <exception cref="ObjectDisposedException"></exception>
        public Guid BeginRequest(RequestMethod method, string target, string uriTemplate, Dictionary <string, object> parameters, ContentType requestContentType, ContentType responseContentType, TimeSpan cacheDuration, int timeout, int retryCount, ReliableAsyncCallback callback, object state)
        {
            if (_disposed)
            {
                throw new ObjectDisposedException(GetType().FullName);
            }

            var param = new Dictionary <string, object>(parameters ?? new Dictionary <string, object>());

            MungeUrlParams(uriTemplate, param);
            target = PrepareUrl(_rootUri.AbsoluteUri, target);

            if (Http200ErrorsOnly)
            {
                uriTemplate = AppendQueryParameter(uriTemplate, "only200");
                param.Add("only200", "true");
            }
            Dictionary <string, string> headers = GetHeaders(target);

            return(base.BeginRequest(method, target, uriTemplate, headers, param, requestContentType, responseContentType, cacheDuration, timeout, retryCount, callback, state));
        }
Beispiel #18
0
 /// <summary>
 /// Delete a watchlist.
 /// </summary>
 /// <param name="deleteWatchlistRequestDto">The watchlist to delete.</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public virtual void BeginDeleteWatchlist(ApiDeleteWatchlistRequestDTO deleteWatchlistRequestDto, ReliableAsyncCallback callback, object state)
 {
     string uriTemplate = "/delete";
     _client.BeginRequest(RequestMethod.POST, "watchlist", uriTemplate , 
     new Dictionary<string, object>
     {
         { "deleteWatchlistRequestDto", deleteWatchlistRequestDto}
     },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(0), 30000,0 ,callback, state);
 }
Beispiel #19
0
 /// <summary>
 /// Queries for a specified trading account's stop / limit order history. The result set includes __only orders that were originally stop / limit orders__ that currently have one of the following statuses __(3 - Open, 4 - Cancelled, 5 - Rejected, 9 - Closed, 10 - Red Card)__.  There is currently no corresponding GetStopLimitOrderHistory *(as with [ListActiveStopLimitOrders](http://labs.cityindex.com/docs/Content/HTTP%20Services/ListActiveStopLimitOrders.htm))*. **Notes on Parameters** >**ClientAccountId** - this can be passed in order to retrieve all information on all trading accounts for which it is the parent. >**TradingAccountId** - this can be passed to retrieve information specific to a certain trading account *(the child of ClientAccount)*.  If *neither* ClientAccountId nor TradingAccountId is passed, then the information returned by default from the API is ClientAccount.
 /// </summary>
 /// <param name="TradingAccountId">The ID of the trading account to get orders for.</param>
 /// <param name="maxResults">The maximum number of results to return.</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public virtual void BeginListStopLimitOrderHistory(int TradingAccountId, int maxResults, ReliableAsyncCallback callback, object state)
 {
     string uriTemplate = "/stoplimitorderhistory?TradingAccountId={TradingAccountId}&MaxResults={maxResults}";
     _client.BeginRequest(RequestMethod.GET, "order", uriTemplate , 
     new Dictionary<string, object>
     {
         { "TradingAccountId", TradingAccountId}, 
         { "maxResults", maxResults}
     },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(0), 30000,2 ,callback, state);
 }
Beispiel #20
0
 /// <summary>
 /// Queries the specified trading account for all open positions and active orders. This URI is intended to support a grid in a UI. One usage pattern is to subscribe to streaming orders, call this for the initial data to display in the grid, and call the HTTP service [GetOpenPosition](http://labs.cityindex.com/docs/Content/HTTP%20Services/GetOpenPosition.htm) when you get updates on the order stream to get the updated data in this format. **Notes on Parameters** >**ClientAccountId** - this can be passed in order to retrieve all information on all trading accounts for which it is the parent. >**TradingAccountId** - this can be passed to retrieve information specific to a certain trading account *(the child of ClientAccount)*.  If *neither* ClientAccountId nor TradingAccountId is passed, then the information returned by default from the API is ClientAccount.
 /// </summary>
 /// <param name="requestDTO">Contains the request for a ListActiveOrders query.</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public virtual void BeginListActiveOrders(ListActiveOrdersRequestDTO requestDTO, ReliableAsyncCallback callback, object state)
 {
     string uriTemplate = "/activeorders";
     _client.BeginRequest(RequestMethod.POST, "order", uriTemplate , 
     new Dictionary<string, object>
     {
         { "requestDTO", requestDTO}
     },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(0), 30000,0 ,callback, state);
 }
Beispiel #21
0
 /// <summary>
 /// Queries for an order by a specific order ID. The current implementation only returns active orders *(i.e. those with a status of __1 - Pending, 2 - Accepted, 3 - Open, 6 - Suspended, 8 - Yellow Card, 11 - Triggered__)*.
 /// </summary>
 /// <param name="OrderId">The requested order ID.</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public virtual void BeginGetOrder(string OrderId, ReliableAsyncCallback callback, object state)
 {
     string uriTemplate = "/{OrderId}";
     _client.BeginRequest(RequestMethod.GET, "order", uriTemplate , 
     new Dictionary<string, object>
     {
         { "OrderId", OrderId}
     },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(0), 30000,2 ,callback, state);
 }
Beispiel #22
0
 /// <summary>
 /// Change a user's password.
 /// </summary>
 /// <param name="apiChangePasswordRequest">The change password request details.</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public virtual void BeginChangePassword(ApiChangePasswordRequestDTO apiChangePasswordRequest, ReliableAsyncCallback callback, object state)
 {
     string uriTemplate = "/changePassword";
     _client.BeginRequest(RequestMethod.POST, "session", uriTemplate , 
     new Dictionary<string, object>
     {
         { "apiChangePasswordRequest", apiChangePasswordRequest}
     },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(0), 30000,0 ,callback, state);
 }
Beispiel #23
0
 /// <summary>
 /// API call that allows a simulated new trade to be placed.
 /// </summary>
 /// <param name="Trade">The simulated trade request.</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public virtual void BeginSimulateTrade(NewTradeOrderRequestDTO Trade, ReliableAsyncCallback callback, object state)
 {
     string uriTemplate = "/simulate/newtradeorder";
     _client.BeginRequest(RequestMethod.POST, "order", uriTemplate , 
     new Dictionary<string, object>
     {
         { "Trade", Trade}
     },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(0), 30000,0 ,callback, state);
 }
Beispiel #24
0
 /// <summary>
 /// Get historic price ticks for the specified market. Returns price ticks in ascending order up to the current time. The length of time that elapses between each tick is usually different.
 /// </summary>
 /// <param name="MarketId">The market ID.</param>
 /// <param name="PriceTicks">The total number of price ticks to return.</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public virtual void BeginGetPriceTicks(string MarketId, string PriceTicks, ReliableAsyncCallback callback, object state)
 {
     string uriTemplate = "/{MarketId}/tickhistory?PriceTicks={PriceTicks}";
     _client.BeginRequest(RequestMethod.GET, "market", uriTemplate , 
     new Dictionary<string, object>
     {
         { "MarketId", MarketId}, 
         { "PriceTicks", PriceTicks}
     },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(0), 30000,2 ,callback, state);
 }
Beispiel #25
0
        /// <summary>
        /// Returns the User's ClientAccountId and a list of their TradingAccounts. There are no parameters for this call.
        /// </summary>
        /// <param name="callback"></param>
        /// <param name="state"></param>
        public virtual void BeginGetClientAndTradingAccount( ReliableAsyncCallback callback, object state)
        {
            string uriTemplate = "/ClientAndTradingAccount";
            _client.BeginRequest(RequestMethod.GET, "useraccount", uriTemplate , 
            new Dictionary<string, object>
            {

            },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(0), 30000,2 ,callback, state);
        }
Beispiel #26
0
 /// <summary>
 /// Get a list of current news headlines.
 /// </summary>
 /// <param name="request">Object specifying the various request parameters.</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public virtual void BeginListNewsHeadlines(ListNewsHeadlinesRequestDTO request, ReliableAsyncCallback callback, object state)
 {
     string uriTemplate = "/headlines";
     _client.BeginRequest(RequestMethod.POST, "news", uriTemplate , 
     new Dictionary<string, object>
     {
         { "request", request}
     },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(0), 30000,0 ,callback, state);
 }
Beispiel #27
0
 /// <summary>
 /// Saves the users account information.
 /// </summary>
 /// <param name="saveAccountInformationRequest">Saves the users account information.</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public virtual void BeginSaveAccountInformation(ApiSaveAccountInformationRequestDTO saveAccountInformationRequest, ReliableAsyncCallback callback, object state)
 {
     string uriTemplate = "/Save";
     _client.BeginRequest(RequestMethod.POST, "useraccount", uriTemplate , 
     new Dictionary<string, object>
     {
         { "saveAccountInformationRequest", saveAccountInformationRequest}
     },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(0), 30000,0 ,callback, state);
 }
Beispiel #28
0
 /// <summary>
 /// Returns a list of Spread Betting markets filtered by market name and/or market code. Leave the market name and code parameters empty to return all markets available to the User.
 /// </summary>
 /// <param name="searchByMarketName">The characters that the Spread market name starts with. *(Optional)*.</param>
 /// <param name="searchByMarketCode">The characters that the Spread market code starts with, normally this is the RIC code for the market. *(Optional)*.</param>
 /// <param name="ClientAccountId">The logged on user's ClientAccountId. *(This only shows you markets that you can trade on.)*</param>
 /// <param name="maxResults">The maximum number of markets to return.</param>
 /// <param name="useMobileShortName">True if the market name should be in short form. Helpful when displaying data on a small screen.</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public virtual void BeginListSpreadMarkets(string searchByMarketName, string searchByMarketCode, int ClientAccountId, int maxResults, bool useMobileShortName, ReliableAsyncCallback callback, object state)
 {
     string uriTemplate = "?MarketName={searchByMarketName}&MarketCode={searchByMarketCode}&ClientAccountId={ClientAccountId}&MaxResults={maxResults}&UseMobileShortName={useMobileShortName}";
     _client.BeginRequest(RequestMethod.GET, "spread/markets", uriTemplate , 
     new Dictionary<string, object>
     {
         { "searchByMarketName", searchByMarketName}, 
         { "searchByMarketCode", searchByMarketCode}, 
         { "ClientAccountId", ClientAccountId}, 
         { "maxResults", maxResults}, 
         { "useMobileShortName", useMobileShortName}
     },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(0), 30000,2 ,callback, state);
 }
Beispiel #29
0
 /// <summary>
 /// Use the message lookup service to get localised text names for the various status codes &amp; IDs returned by the API. For example, a query for **OrderStatusReason** will contain text names for all the possible values of **OrderStatusReason** in the [ApiOrderResponseDTO](http://labs.cityindex.com/docs/Content/Data%20Types/ApiOrderResponseDTO.htm). You should only request the list once per session *(for each entity you're interested in)*.
 /// </summary>
 /// <param name="LookupEntityName">The entity to lookup. For example: **OrderStatusReason**, **InstructionStatusReason**, **OrderApplicability**, **Currency**, **QuoteStatus**, **QuoteStatusReason** or **Culture**.</param>
 /// <param name="CultureId">The Culture ID used to override the translated text description. *(Optional)*.</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public virtual void BeginGetSystemLookup(string LookupEntityName, int CultureId, ReliableAsyncCallback callback, object state)
 {
     string uriTemplate = "/lookup?LookupEntityName={LookupEntityName}&CultureId={CultureId}";
     _client.BeginRequest(RequestMethod.GET, "message", uriTemplate , 
     new Dictionary<string, object>
     {
         { "LookupEntityName", LookupEntityName}, 
         { "CultureId", CultureId}
     },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(3600000), 30000,2 ,callback, state);
 }
Beispiel #30
0
 /// <summary>
 /// Returns a list of markets that meet the search criteria. The search can be performed by market code and/or market name, and can include CFDs and Spread Bet markets. Leave the query string empty to return all markets available to the user.
 /// </summary>
 /// <param name="searchByMarketCode">Sets the search to use market code.</param>
 /// <param name="searchByMarketName">Sets the search to use market Name.</param>
 /// <param name="spreadProductType">Sets the search to include spread bet markets.</param>
 /// <param name="cfdProductType">Sets the search to include CFD markets.</param>
 /// <param name="binaryProductType">Sets the search to include binary markets.</param>
 /// <param name="includeOptions">When set to true, the search captures and returns options markets. When set to false, options markets are excluded from the search results.</param>
 /// <param name="query">The text to search for. Matches part of market name / code from the start. *(Optional)*.</param>
 /// <param name="maxResults">The maximum number of results to return.</param>
 /// <param name="useMobileShortName">True if the market name should be in short form.  Helpful when displaying data on a small screen.</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public virtual void BeginListMarketSearch(bool searchByMarketCode, bool searchByMarketName, bool spreadProductType, bool cfdProductType, bool binaryProductType, bool includeOptions, string query, int maxResults, bool useMobileShortName, ReliableAsyncCallback callback, object state)
 {
     string uriTemplate = "/search?SearchByMarketCode={searchByMarketCode}&SearchByMarketName={searchByMarketName}&SpreadProductType={spreadProductType}&CfdProductType={cfdProductType}&BinaryProductType={binaryProductType}&IncludeOptions={includeOptions}&Query={query}&MaxResults={maxResults}&UseMobileShortName={useMobileShortName}";
     _client.BeginRequest(RequestMethod.GET, "market", uriTemplate , 
     new Dictionary<string, object>
     {
         { "searchByMarketCode", searchByMarketCode}, 
         { "searchByMarketName", searchByMarketName}, 
         { "spreadProductType", spreadProductType}, 
         { "cfdProductType", cfdProductType}, 
         { "binaryProductType", binaryProductType}, 
         { "includeOptions", includeOptions}, 
         { "query", query}, 
         { "maxResults", maxResults}, 
         { "useMobileShortName", useMobileShortName}
     },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(0), 30000,2 ,callback, state);
 }
Beispiel #31
0
 /// <summary>
 /// Use the message translation service to get client specific translated text strings.
 /// </summary>
 /// <param name="ClientApplicationId">Client application identifier. *(Optional)*</param>
 /// <param name="CultureId">Culture ID which corresponds to a culture code. *(Optional)*</param>
 /// <param name="AccountOperatorId">Account operator identifier. *(Optional)*</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public virtual void BeginGetClientApplicationMessageTranslation(int ClientApplicationId, int CultureId, int AccountOperatorId, ReliableAsyncCallback callback, object state)
 {
     string uriTemplate = "/translation?ClientApplicationId={ClientApplicationId}&CultureId={CultureId}&AccountOperatorId={AccountOperatorId}";
     _client.BeginRequest(RequestMethod.GET, "message", uriTemplate , 
     new Dictionary<string, object>
     {
         { "ClientApplicationId", ClientApplicationId}, 
         { "CultureId", CultureId}, 
         { "AccountOperatorId", AccountOperatorId}
     },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(3600000), 30000,2 ,callback, state);
 }
        public Guid BeginRequest(Uri uri, RequestMethod method, string body, Dictionary<string, string> headers,
                                 ContentType requestContentType, ContentType responseContentType, TimeSpan cacheDuration,
                                 int timeout, string target, string uriTemplate, int retryCount,
                                 Dictionary<string, object> parameters, ReliableAsyncCallback callback, object state)
        {
            lock (_lockTarget)
            {
                RequestInfo info = null;

                if (cacheDuration == TimeSpan.Zero || (method == RequestMethod.PUT) || (method == RequestMethod.POST))
                {
                    // this item should not enter the cache
                    info = CreateRequest(uri, method, body, headers, requestContentType, responseContentType,
                                         cacheDuration, timeout, target, uriTemplate, retryCount, parameters, callback,
                                         state);

                    info.State = RequestItemState.Ready;
                    RequestQueue.Enqueue(info);
                }
                else
                {
                    // this item can enter the cache
                    if (!string.IsNullOrEmpty(body))
                    {
                        throw new Exception(
                            "a request with body cannot be cached. body is supported on PUT and POST only");
                    }

                    info = GetRequestInfo(uri);

                    if (info == null)
                    {
                        info = CreateRequest(uri, method, body, headers, requestContentType, responseContentType,
                                             cacheDuration, timeout, target, uriTemplate, retryCount, parameters,
                                             callback, state);

                        info.State = RequestItemState.Ready;
                        _requestCache.Add(info);
                        RequestQueue.Enqueue(info);
                        Log.Info(string.Format("Added {1} {0} to cache", info.Uri, info.Index));
                    }
                    else
                    {
                        if (info.State == RequestItemState.Complete)
                        {
                            // #FIXME: this should be elsewhere?
                            new ReliableAsyncResult(callback, state, true, info.ResponseText, info.Exception);
                        }
                        else
                        {
                            Log.Info(string.Format("Added callback to {1} {0}", info.Uri, info.Index));
                            info.AddCallback(callback, state);
                        }
                    }
                }
                return info.Id;
            }
        }
Beispiel #33
0
 /// <summary>
 /// Use the message translation service to get client specific translated textual strings for specific keys.
 /// </summary>
 /// <param name="apiClientApplicationMessageTranslationRequestDto">DTO of the required data for translation lookup.</param>
 /// <param name="callback"></param>
 /// <param name="state"></param>
 public virtual void BeginGetClientApplicationMessageTranslationWithInterestingItems(ApiClientApplicationMessageTranslationRequestDTO apiClientApplicationMessageTranslationRequestDto, ReliableAsyncCallback callback, object state)
 {
     string uriTemplate = "/translationWithInterestingItems";
     _client.BeginRequest(RequestMethod.POST, "message", uriTemplate , 
     new Dictionary<string, object>
     {
         { "apiClientApplicationMessageTranslationRequestDto", apiClientApplicationMessageTranslationRequestDto}
     },ContentType.JSON,ContentType.JSON, TimeSpan.FromMilliseconds(0), 30000,0 ,callback, state);
 }