Exemplo n.º 1
0
        /// <summary>
        /// Instrument Position Get the details of a single Instrument&#39;s Position in an Account. The Position may by open or not.
        /// </summary>
        /// <exception cref="GeriRemenyi.Oanda.V20.Client.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="accountID">Account identifier</param>
        /// <param name="instrument">Instrument name</param>
        /// <returns>ApiResponse of InstrumentPositionResponse</returns>
        public GeriRemenyi.Oanda.V20.Client.Client.ApiResponse <InstrumentPositionResponse> GetInstrumentPositionWithHttpInfo(string accountID, InstrumentName instrument)
        {
            // verify the required parameter 'accountID' is set
            if (accountID == null)
            {
                throw new GeriRemenyi.Oanda.V20.Client.Client.ApiException(400, "Missing required parameter 'accountID' when calling PositionApi->GetInstrumentPosition");
            }

            GeriRemenyi.Oanda.V20.Client.Client.RequestOptions localVarRequestOptions = new GeriRemenyi.Oanda.V20.Client.Client.RequestOptions();

            String[] _contentTypes = new String[] {
            };

            // to determine the Accept header
            String[] _accepts = new String[] {
                "application/json"
            };

            var localVarContentType = GeriRemenyi.Oanda.V20.Client.Client.ClientUtils.SelectHeaderContentType(_contentTypes);

            if (localVarContentType != null)
            {
                localVarRequestOptions.HeaderParameters.Add("Content-Type", localVarContentType);
            }

            var localVarAccept = GeriRemenyi.Oanda.V20.Client.Client.ClientUtils.SelectHeaderAccept(_accepts);

            if (localVarAccept != null)
            {
                localVarRequestOptions.HeaderParameters.Add("Accept", localVarAccept);
            }

            localVarRequestOptions.PathParameters.Add("accountID", GeriRemenyi.Oanda.V20.Client.Client.ClientUtils.ParameterToString(accountID));   // path parameter
            localVarRequestOptions.PathParameters.Add("instrument", GeriRemenyi.Oanda.V20.Client.Client.ClientUtils.ParameterToString(instrument)); // path parameter

            // authentication (PersonalAccessToken) required
            // bearer authentication required
            if (!String.IsNullOrEmpty(this.Configuration.AccessToken))
            {
                localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken);
            }

            // make the HTTP request
            var localVarResponse = this.Client.Get <InstrumentPositionResponse>("/accounts/{accountID}/positions/{instrument}", localVarRequestOptions, this.Configuration);

            if (this.ExceptionFactory != null)
            {
                Exception _exception = this.ExceptionFactory("GetInstrumentPosition", localVarResponse);
                if (_exception != null)
                {
                    throw _exception;
                }
            }

            return(localVarResponse);
        }
Exemplo n.º 2
0
        /// <summary>
        /// List Positions List all Positions for an Account. The Positions returned are for every instrument that has had a position during the lifetime of an the Account.
        /// </summary>
        /// <exception cref="GeriRemenyi.Oanda.V20.Client.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="accountID">Account identifier</param>
        /// <returns>Task of ApiResponse (PositionsResponse)</returns>
        public async System.Threading.Tasks.Task <GeriRemenyi.Oanda.V20.Client.Client.ApiResponse <PositionsResponse> > GetPositionsAsyncWithHttpInfo(string accountID)
        {
            // verify the required parameter 'accountID' is set
            if (accountID == null)
            {
                throw new GeriRemenyi.Oanda.V20.Client.Client.ApiException(400, "Missing required parameter 'accountID' when calling PositionApi->GetPositions");
            }


            GeriRemenyi.Oanda.V20.Client.Client.RequestOptions localVarRequestOptions = new GeriRemenyi.Oanda.V20.Client.Client.RequestOptions();

            String[] _contentTypes = new String[] {
            };

            // to determine the Accept header
            String[] _accepts = new String[] {
                "application/json"
            };

            foreach (var _contentType in _contentTypes)
            {
                localVarRequestOptions.HeaderParameters.Add("Content-Type", _contentType);
            }

            foreach (var _accept in _accepts)
            {
                localVarRequestOptions.HeaderParameters.Add("Accept", _accept);
            }

            localVarRequestOptions.PathParameters.Add("accountID", GeriRemenyi.Oanda.V20.Client.Client.ClientUtils.ParameterToString(accountID)); // path parameter

            // authentication (PersonalAccessToken) required
            // bearer authentication required
            if (!String.IsNullOrEmpty(this.Configuration.AccessToken))
            {
                localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken);
            }

            // make the HTTP request

            var localVarResponse = await this.AsynchronousClient.GetAsync <PositionsResponse>("/accounts/{accountID}/positions", localVarRequestOptions, this.Configuration);

            if (this.ExceptionFactory != null)
            {
                Exception _exception = this.ExceptionFactory("GetPositions", localVarResponse);
                if (_exception != null)
                {
                    throw _exception;
                }
            }

            return(localVarResponse);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Current Account Prices Get pricing information for a specified list of Instruments within an Account.
        /// </summary>
        /// <exception cref="GeriRemenyi.Oanda.V20.Client.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="accountID">Account identifier</param>
        /// <param name="instruments">List of Instruments to get pricing for.</param>
        /// <param name="acceptDatetimeFormat">Format of DateTime fields in the request and response. (optional)</param>
        /// <param name="since">Date/Time filter to apply to the response. Only prices and home conversions (if requested) with a time later than this filter (i.e. the price has changed after the since time) will be provided, and are filtered independently. (optional)</param>
        /// <param name="includeUnitsAvailable">Flag that enables the inclusion of the unitsAvailable field in the returned Price objects. (optional)</param>
        /// <param name="includeHomeConversions">Flag that enables the inclusion of the homeConversions field in the returned response. An entry will be returned for each currency in the set of all base and quote currencies present in the requested instruments list. (optional)</param>
        /// <returns>Task of ApiResponse (PricingResponse)</returns>
        public async System.Threading.Tasks.Task <GeriRemenyi.Oanda.V20.Client.Client.ApiResponse <PricingResponse> > GetPricingAsyncWithHttpInfo(string accountID, List <InstrumentName> instruments, DateTimeFormat?acceptDatetimeFormat = default(DateTimeFormat?), string since = default(string), bool?includeUnitsAvailable = default(bool?), bool?includeHomeConversions = default(bool?))
        {
            // verify the required parameter 'accountID' is set
            if (accountID == null)
            {
                throw new GeriRemenyi.Oanda.V20.Client.Client.ApiException(400, "Missing required parameter 'accountID' when calling PricingApi->GetPricing");
            }

            // verify the required parameter 'instruments' is set
            if (instruments == null)
            {
                throw new GeriRemenyi.Oanda.V20.Client.Client.ApiException(400, "Missing required parameter 'instruments' when calling PricingApi->GetPricing");
            }


            GeriRemenyi.Oanda.V20.Client.Client.RequestOptions localVarRequestOptions = new GeriRemenyi.Oanda.V20.Client.Client.RequestOptions();

            String[] _contentTypes = new String[] {
            };

            // to determine the Accept header
            String[] _accepts = new String[] {
                "application/json"
            };

            foreach (var _contentType in _contentTypes)
            {
                localVarRequestOptions.HeaderParameters.Add("Content-Type", _contentType);
            }

            foreach (var _accept in _accepts)
            {
                localVarRequestOptions.HeaderParameters.Add("Accept", _accept);
            }

            localVarRequestOptions.PathParameters.Add("accountID", GeriRemenyi.Oanda.V20.Client.Client.ClientUtils.ParameterToString(accountID)); // path parameter
            localVarRequestOptions.QueryParameters.Add(GeriRemenyi.Oanda.V20.Client.Client.ClientUtils.ParameterToMultiMap("csv", "instruments", instruments));
            if (since != null)
            {
                localVarRequestOptions.QueryParameters.Add(GeriRemenyi.Oanda.V20.Client.Client.ClientUtils.ParameterToMultiMap("", "since", since));
            }
            if (includeUnitsAvailable != null)
            {
                localVarRequestOptions.QueryParameters.Add(GeriRemenyi.Oanda.V20.Client.Client.ClientUtils.ParameterToMultiMap("", "includeUnitsAvailable", includeUnitsAvailable));
            }
            if (includeHomeConversions != null)
            {
                localVarRequestOptions.QueryParameters.Add(GeriRemenyi.Oanda.V20.Client.Client.ClientUtils.ParameterToMultiMap("", "includeHomeConversions", includeHomeConversions));
            }
            if (acceptDatetimeFormat != null)
            {
                localVarRequestOptions.HeaderParameters.Add("Accept-Datetime-Format", GeriRemenyi.Oanda.V20.Client.Client.ClientUtils.ParameterToString(acceptDatetimeFormat)); // header parameter
            }

            // authentication (PersonalAccessToken) required
            // bearer authentication required
            if (!String.IsNullOrEmpty(this.Configuration.AccessToken))
            {
                localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken);
            }

            // make the HTTP request

            var localVarResponse = await this.AsynchronousClient.GetAsync <PricingResponse>("/accounts/{accountID}/pricing", localVarRequestOptions, this.Configuration);

            if (this.ExceptionFactory != null)
            {
                Exception _exception = this.ExceptionFactory("GetPricing", localVarResponse);
                if (_exception != null)
                {
                    throw _exception;
                }
            }

            return(localVarResponse);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Close Position Closeout the open Position for a specific instrument in an Account.
        /// </summary>
        /// <exception cref="GeriRemenyi.Oanda.V20.Client.Client.ApiException">Thrown when fails to make API call</exception>
        /// <param name="accountID">Account identifier</param>
        /// <param name="instrument">Instrument name</param>
        /// <param name="closePositionRequest">Representation of how to close the position</param>
        /// <param name="acceptDatetimeFormat">Format of DateTime fields in the request and response. (optional)</param>
        /// <returns>Task of ApiResponse (ClosePositionResponse)</returns>
        public async System.Threading.Tasks.Task <GeriRemenyi.Oanda.V20.Client.Client.ApiResponse <ClosePositionResponse> > ClosePositionAsyncWithHttpInfo(string accountID, InstrumentName instrument, ClosePositionRequest closePositionRequest, DateTimeFormat?acceptDatetimeFormat = default(DateTimeFormat?))
        {
            // verify the required parameter 'accountID' is set
            if (accountID == null)
            {
                throw new GeriRemenyi.Oanda.V20.Client.Client.ApiException(400, "Missing required parameter 'accountID' when calling PositionApi->ClosePosition");
            }

            // verify the required parameter 'closePositionRequest' is set
            if (closePositionRequest == null)
            {
                throw new GeriRemenyi.Oanda.V20.Client.Client.ApiException(400, "Missing required parameter 'closePositionRequest' when calling PositionApi->ClosePosition");
            }


            GeriRemenyi.Oanda.V20.Client.Client.RequestOptions localVarRequestOptions = new GeriRemenyi.Oanda.V20.Client.Client.RequestOptions();

            String[] _contentTypes = new String[] {
                "application/json"
            };

            // to determine the Accept header
            String[] _accepts = new String[] {
                "application/json"
            };

            foreach (var _contentType in _contentTypes)
            {
                localVarRequestOptions.HeaderParameters.Add("Content-Type", _contentType);
            }

            foreach (var _accept in _accepts)
            {
                localVarRequestOptions.HeaderParameters.Add("Accept", _accept);
            }

            localVarRequestOptions.PathParameters.Add("accountID", GeriRemenyi.Oanda.V20.Client.Client.ClientUtils.ParameterToString(accountID));   // path parameter
            localVarRequestOptions.PathParameters.Add("instrument", GeriRemenyi.Oanda.V20.Client.Client.ClientUtils.ParameterToString(instrument)); // path parameter
            if (acceptDatetimeFormat != null)
            {
                localVarRequestOptions.HeaderParameters.Add("Accept-Datetime-Format", GeriRemenyi.Oanda.V20.Client.Client.ClientUtils.ParameterToString(acceptDatetimeFormat)); // header parameter
            }
            localVarRequestOptions.Data = closePositionRequest;

            // authentication (PersonalAccessToken) required
            // bearer authentication required
            if (!String.IsNullOrEmpty(this.Configuration.AccessToken))
            {
                localVarRequestOptions.HeaderParameters.Add("Authorization", "Bearer " + this.Configuration.AccessToken);
            }

            // make the HTTP request

            var localVarResponse = await this.AsynchronousClient.PutAsync <ClosePositionResponse>("/accounts/{accountID}/positions/{instrument}/close", localVarRequestOptions, this.Configuration);

            if (this.ExceptionFactory != null)
            {
                Exception _exception = this.ExceptionFactory("ClosePosition", localVarResponse);
                if (_exception != null)
                {
                    throw _exception;
                }
            }

            return(localVarResponse);
        }