예제 #1
0
        public CommandReply CancelOrder(Command command)
        {
            if (command == null)
            {
                throw new ArgumentNullException("command");
            }
            if (command.OrderId == 0)
            {
                throw new ArgumentException("OrderId");
            }

            command.Received = command.Remains = 0;
            command.Funds.Clear();

            var res = new CommandReply {
                Command = command
            };

            var args = "method=CancelOrder&order_id={0}".Put(command.OrderId);

            JsonConvert.PopulateObject(MakePrivateRequest(args), res);

            if (!res.Success)
            {
                throw new InvalidOperationException(res.ErrorText);
            }

            return(res);
        }
예제 #2
0
        public CommandReply MakeOrder(string instrument,
                                      string side,
                                      decimal price,
                                      decimal volume)
        {
            if (price < 0)
            {
                throw new ArgumentOutOfRangeException("price", price, LocalizedStrings.Str3343);
            }

            if (volume <= 0)
            {
                throw new ArgumentOutOfRangeException("volume", volume, LocalizedStrings.Str3344);
            }

            var instr = instrument.ToLower();

            //var dir = command.Direction.ToString().ToLower();

            //command.Received = command.Remains = 0;
            //command.Funds.Clear();

            if (_instruments == null)
            {
                throw new InvalidOperationException("Info about instruments not loaded yet.");
            }

            if (!_instruments.ContainsKey(instr))
            {
                throw new ArgumentException("Unknown instrument.");
            }

            var args = "method=Trade&pair={0}&type={1}&rate={2}&amount={3}".Put(
                instr, side,
                price.ToString("F" + _instruments[instr].DecimalDigits, NumberFormatInfo.InvariantInfo),
                volume.ToString("F8", NumberFormatInfo.InvariantInfo));

            var res = new CommandReply {
                Command = new Command()
            };

            JsonConvert.PopulateObject(MakePrivateRequest(args), res);

            if (!res.Success)
            {
                throw new InvalidOperationException(res.ErrorText);
            }

            return(res);
        }
예제 #3
0
		public CommandReply CancelOrder(Command command)
		{
			if (command == null)
				throw new ArgumentNullException("command");
			if (command.OrderId == 0)
				throw new ArgumentException("OrderId");

			command.Received = command.Remains = 0;
			command.Funds.Clear();

			var res = new CommandReply { Command = command };

			var args = "method=CancelOrder&order_id={0}".Put(command.OrderId);
			JsonConvert.PopulateObject(MakePrivateRequest(args), res);

			if (!res.Success)
				throw new InvalidOperationException(res.ErrorText);

			return res;
		}
예제 #4
0
		public CommandReply MakeOrder(string instrument,
			string side,
			decimal price,
			decimal volume)
		{
			if (price < 0)
				throw new ArgumentOutOfRangeException("price", price, LocalizedStrings.Str3343);

			if (volume <= 0)
				throw new ArgumentOutOfRangeException("volume", volume, LocalizedStrings.Str3344);

			var instr = instrument.ToLower();
			//var dir = command.Direction.ToString().ToLower();

			//command.Received = command.Remains = 0;
			//command.Funds.Clear();

			if (_instruments == null)
				throw new InvalidOperationException("Info about instruments not loaded yet.");

			if (!_instruments.ContainsKey(instr))
				throw new ArgumentException("Unknown instrument.");

			var args = "method=Trade&pair={0}&type={1}&rate={2}&amount={3}".Put(
				instr, side,
				price.ToString("F" + _instruments[instr].DecimalDigits, NumberFormatInfo.InvariantInfo),
				volume.ToString("F8", NumberFormatInfo.InvariantInfo));

			var res = new CommandReply { Command = new Command() };

			JsonConvert.PopulateObject(MakePrivateRequest(args), res);

			if (!res.Success)
				throw new InvalidOperationException(res.ErrorText);

			return res;
		}