Пример #1
0
        /// <summary>
        /// Get a list of open trades
        /// </summary>
        /// <param name="instrument">Retrieve open trades for a specific instrument only</param>
        /// <param name="count">Maximum number of open trades to return. Default: 50 Max value: 500</param>
        /// <param name="maxId">The server will return trades with id less than or equal to this, in descending order (for pagination)</param>
        /// <param name="ids"> A (URL encoded) comma separated list of trades to retrieve. Maximum number of ids: 50. No other parameter may be specified with the ids parameter</param>
        /// <returns></returns>
        public async Task <List <Trade> > GetTrades(string instrument, int?count, long?maxId, string ids)
        {
            Dictionary <string, string> routeParams = new Dictionary <string, string>();

            routeParams.Add("accountId", _accountId.ToString());

            Dictionary <string, object> properties = new Dictionary <string, object>();

            properties.Add("instrument", instrument);
            if (count != null)
            {
                properties.Add("count", count);
            }
            if (maxId != null)
            {
                properties.Add("maxId", maxId);
            }
            if (!string.IsNullOrWhiteSpace(ids))
            {
                properties.Add("ids", ids);
            }

            TradesWrapper tradesWrapper = await Get <TradesWrapper>(routeParams, properties, _tradesRoute);

            return(tradesWrapper.Trades);
        }
Пример #2
0
        /// <summary>
        /// Get a list of open trades
        /// </summary>
        /// <returns></returns>
        public async Task <List <Trade> > GetTrades()
        {
            Dictionary <string, string> routeParams = new Dictionary <string, string>();

            routeParams.Add("accountId", _accountId.ToString());

            TradesWrapper tradesWrapper = await Get <TradesWrapper>(routeParams, null, _tradesRoute);

            return(tradesWrapper.Trades);
        }
Пример #3
0
        /// <summary>
        /// Get a list of open trades
        /// </summary>
        /// <param name="instrument">Retrieve open trades for a specific instrument only</param>
        /// <returns></returns>
        public async Task <List <Trade> > GetTrades(string instrument)
        {
            Dictionary <string, string> routeParams = new Dictionary <string, string>();

            routeParams.Add("accountId", _accountId.ToString());

            Dictionary <string, object> properties = new Dictionary <string, object>();

            properties.Add("instrument", instrument);

            TradesWrapper tradesWrapper = await Get <TradesWrapper>(routeParams, properties, _tradesRoute);

            return(tradesWrapper.Trades);
        }
Пример #4
0
        /// <summary>
        /// Get a list of open trades (especially usefull for closing trades in FIFO style)
        /// </summary>
        /// <param name="instrument">Retrieve open trades for a specific instrument only</param>
        /// <param name="side">Retrieve open trades for a specific side only</param>
        /// <param name="units">Retrieve open trades with a specific number of units</param>
        /// <returns></returns>
        public async Task <List <Trade> > GetTrades(string instrument, OandaTypes.Side side, int units)
        {
            Dictionary <string, string> routeParams = new Dictionary <string, string>();

            routeParams.Add("accountId", _accountId.ToString());

            Dictionary <string, object> properties = new Dictionary <string, object>();

            properties.Add("instrument", instrument);

            TradesWrapper tradesWrapper = await Get <TradesWrapper>(routeParams, properties, _tradesRoute);

            return(tradesWrapper.Trades.Where(x => x.Side == side && x.Units == units).OrderBy(x => x.Id).ToList());
        }