Esempio n. 1
0
 private void SideUpdate() {
     if (m_currentSide != m_lastSide)
     {
         m_lastSide = m_currentSide;
         SetAnimations("BackWalk", "RightWalk", "FrontWalk", "LeftWalk");
     }
 }
Esempio n. 2
0
        public Rectangle PositionItem(Sides side, int dim)
        {
            Rectangle R;

            switch (side)
            {
                case Sides.North:
                    R = new Rectangle(CoverageArea.X, CoverageArea.Y, CoverageArea.Width, dim);
                    CoverageArea.Y += dim + Padding; CoverageArea.Height -= dim + Padding;
                    break;
                case Sides.East:
                    R = new Rectangle(CoverageArea.X + CoverageArea.Width - dim, CoverageArea.Y, dim, CoverageArea.Height);
                    CoverageArea.Width -= dim + Padding;
                    break;
                case Sides.South:
                    R = new Rectangle(CoverageArea.X, CoverageArea.Y + CoverageArea.Height - dim, CoverageArea.Width, dim);
                    CoverageArea.Height -= dim + Padding;
                    break;
                case Sides.West:
                    R = new Rectangle(CoverageArea.X, CoverageArea.Y, dim, CoverageArea.Height);
                    CoverageArea.X += dim + Padding; CoverageArea.Width -= dim + Padding;
                    break;
                case Sides.Center:
                    R = CoverageArea;
                    CoverageArea = new Rectangle(0, 0, 0, 0);
                    break;
                default :
                    R = new Rectangle(0, 0, 0, 0);
                    break;
            }

            return R;
        }
Esempio n. 3
0
		public void CheckForSlicing(Vector2D start, Vector2D end)
		{
			if (!sideStatus.HasFlag(Sides.Top) && CheckIfLineIntersectsLine(start, end, DrawArea.TopLeft, DrawArea.TopRight)) sideStatus |= Sides.Top;
			if (!sideStatus.HasFlag(Sides.Left) && CheckIfLineIntersectsLine(start, end, DrawArea.TopLeft, DrawArea.BottomLeft)) sideStatus |= Sides.Left;
			if (!sideStatus.HasFlag(Sides.Bottom) && CheckIfLineIntersectsLine(start, end, DrawArea.BottomLeft, DrawArea.BottomRight)) sideStatus |= Sides.Bottom;
			if (!sideStatus.HasFlag(Sides.Right) && CheckIfLineIntersectsLine(start, end, DrawArea.TopRight, DrawArea.BottomRight)) sideStatus |= Sides.Right;
		}
 //public Bullet(double x, double y, double vx, double vy) : this(Side.teki, x, y, vx, vy)
 //{
 //}
 public Bullet(Sides side, double x, double y, double vx, double vy)
 {
     this.side = side;   // teki, mikataの区別
     this.x = x;
     this.y = y;
     this.vx = vx;
     this.vy = vy;
 }
Esempio n. 5
0
 // Constructors
 public PickupPackage(GameObject body, GameObject brain, string text, bool attachNow, Sides who)
 {
     Body = body;
     Brain = brain;
     MessageText = text;
     AttachesImmediately = attachNow;
     WhoCanPickUp = who;
 }
Esempio n. 6
0
		internal Grip(int value, int width, int height, Sides side, System.Func<int> getCenterValue, System.Func<int> getMinValue , System.Func<int> getMaxValue)
		{
			Side = side;
			_getCenterValue = getCenterValue;
			_getMinValue = getMinValue;
			_getMaxValue = getMaxValue;
			/*not VALUE property!*/_value = value;
			Rectangle = new Rectangle(value, value, width, height);
		}
Esempio n. 7
0
		/// <summary>
		/// To get the synthetic position for the option.
		/// </summary>
		/// <param name="side">The main position direction.</param>
		/// <returns>The synthetic position.</returns>
		public KeyValuePair<Security, Sides>[] Position(Sides side)
		{
			var asset = Option.GetUnderlyingAsset(_provider);

			return new[]
			{
				new KeyValuePair<Security, Sides>(asset, Option.OptionType == OptionTypes.Call ? side : side.Invert()),
				new KeyValuePair<Security, Sides>(Option.GetOppositeOption(_provider), side)
			};
		}
Esempio n. 8
0
        public void IEquatableMembers_WorksCorrect_IfOneHasSomeDifferentSides(params Dir[] emptyDirs)
        {
            var other = new Sides();

            foreach (var dir in emptyDirs)
            {
                _sides[dir] = Side.Empty;
            }

            CustomAssert.IEquatableMembersWorkForDifferentObjects(_sides, other);
        }
Esempio n. 9
0
	// Use this for initialization
	void Start () {
        m_healthTimer = 0;
        m_isHealing = true;
        m_hasAttacked = false;
        m_currentSide = Sides.FRONT;
        m_lastSide = Sides.FRONT;
        
        m_animator = GetComponent<Animator>();

        m_health = 100;
        m_speed = 1.5f;
        InitTargetsList();
        SelectTarget();
	}
Esempio n. 10
0
        public LocationData(DataRow row)
        {
            this.id				= (byte)(long)row["ID"];
            this.order			= (int)(long)row["Order"];
            this.route			= (byte)(long)row["Route"];
            this.mapX			= (byte)((long)row["MapX"] + 1); // At first I made the map position 1 off to center on the location but I'm thinking I'll just highlight the grid location
            this.mapY			= (byte)((long)row["MapY"] + 1);
            this.side			= GetSideFromString(row["Side"] as string);
            this.type			= GetTypeFromString(row["Type"] as string);
            this.layout			= GetLayoutFromString(row["Layout"] as string);
            this.requirements	= row["Requirements"] as string;

            this.image			= LoadImage((byte[])row["Image"]);
        }
Esempio n. 11
0
        /// <summary>
        /// Construct a price level object which is a shallow copy of
        /// the original.
        /// </summary>
        /// <param name="copy">The MamdaOrderBookPriceLevel to copy.</param>
        public MamdaOrderBookPriceLevel(MamdaOrderBookPriceLevel copy)
        {
            mPrice      = copy.mPrice;
            mSize       = copy.mSize;
            mSizeChange = copy.mSizeChange;
            mNumEntries = copy.mNumEntries;
            mSide       = copy.mSide;
            mAction     = copy.mAction;
            mTime       = copy.mTime;

            for (int i = 0; i < copy.mEntries.Count; i++)
            {
                MamdaOrderBookEntry entry = new MamdaOrderBookEntry(
                    (MamdaOrderBookEntry)copy.mEntries[i]);
                mEntries.Add(entry);
            }
        }
Esempio n. 12
0
        public Bullet(Ugokikata ugokikata, Sides sides, int x_2, int y_2, double p, double p_2, double px, double py, double speed)
            : this(sides, x_2, y_2, p, p_2)
        {
            // TODO: Complete member initialization
            this.ugokikata = ugokikata;
            this.px = px;
            this.py = py;

            double hi = speed / Math.Sqrt((px - x) * (px - x) + (py - y) * (py - y));
            switch (ugokikata)
            {
                case Ugokikata.Concentric:
                    break;
                case Ugokikata.Sighting:
                    vx = hi * (px - x);
                    vy = hi * (py - y);
                    break;
                case Ugokikata.Drill:
                    vx = hi * (px - x); // 弾丸の初速
                    vy = hi * (py - y);
                    gx = x;             // 独自の重力源の座標
                    gy = y;
                    vgx = vx;           // 独自の重力源の不変速度
                    vgy = vy;
                    x = x + 10 * vy; // 進行方向とは垂直にずらした座標
                    y = y - 10 * vx;
                    break;
                default:
                    break;
            }

            //this.sides = sides;
            //this.x = x_2;
            //this.y = y_2;
            //this.vx = p;
            //this.vy = p_2;
        }
Esempio n. 13
0
        /// <summary>
        /// Add change into collection.
        /// </summary>
        /// <typeparam name="TMessage">Change message type.</typeparam>
        /// <typeparam name="TChange">Change type.</typeparam>
        /// <param name="message">Change message.</param>
        /// <param name="type">Change type.</param>
        /// <param name="value">Change value.</param>
        /// <returns>Change message.</returns>
        public static TMessage Add <TMessage, TChange>(this TMessage message, TChange type, Sides value)
            where TMessage : BaseChangeMessage <TMessage, TChange>, new()
        {
            if (message == null)
            {
                throw new ArgumentNullException(nameof(message));
            }

            message.Changes[type] = value;
            return(message);
        }
Esempio n. 14
0
 public void DrawRectangle(PDFPen pen, PDFPoint location, PDFSize size, Sides sides)
 {
     this.DrawRectangle(pen, location.X, location.Y, size.Width, size.Height, sides);
 }
Esempio n. 15
0
        private void DoOutputRoundRectangleWithSidesFill(PDFUnit x, PDFUnit y, PDFUnit width, PDFUnit height, PDFUnit cornerRadius, Sides sides)
        {
            PDFUnit handleoffset = (PDFUnit)(cornerRadius.PointsValue * CircularityFactor);

            //position cursor at left bottom
            if ((sides & Sides.Left) > 0 && (sides & Sides.Bottom) > 0)
            {
                //if we have a bottom edge then we are going to have an arc
                this.RenderMoveTo(x, y + height - cornerRadius);
            }
            else
            {
                this.RenderMoveTo(x, y + height);
            }

            //draw left vertical and optional arc
            if ((sides & Sides.Left) > 0 && (sides & Sides.Top) > 0)
            {
                //as we have a left and a top then we have an arc
                this.RenderLineTo(x, y + cornerRadius);
                //top left arc
                this.RenderBezierCurveTo(x + cornerRadius, y, x, y + cornerRadius - handleoffset, x + cornerRadius - handleoffset, y);
            }
            else
            {
                this.RenderLineTo(x, y);
            }

            //draw top horizontal and optional arc
            if ((sides & Sides.Top) > 0 && (sides & Sides.Right) > 0)
            {
                //as we have a top and a right then we have an arc
                this.RenderLineTo(x + width - cornerRadius, y);
                //top right arc
                this.RenderBezierCurveTo(x + width, y + cornerRadius, x + width - cornerRadius + handleoffset, y, x + width, y + cornerRadius - handleoffset);
            }
            else
            {
                this.RenderLineTo(x + width, y);
            }


            //draw right vertical and optional arc
            if ((sides & Sides.Right) > 0 && (sides & Sides.Bottom) > 0)
            {
                //right vertical
                this.RenderLineTo(x + width, y + height - cornerRadius);
                //bottomright arc
                this.RenderBezierCurveTo(x + width - cornerRadius, y + height, x + width, y + height - cornerRadius + handleoffset, x + width - cornerRadius + handleoffset, y + height);
            }
            else
            {
                this.RenderLineTo(x + width, y + height);
            }

            //draw bottom horizontal and optional arc
            if ((sides & Sides.Bottom) > 0 && (sides & Sides.Left) > 0)
            {
                //bottom line
                this.RenderLineTo(x + cornerRadius, y + height);
                //bottom left arc
                this.RenderBezierCurveTo(x, y + height - cornerRadius, x + cornerRadius - handleoffset, y + height, x, y + height - cornerRadius + handleoffset);
            }
            else
            {
                this.RenderLineTo(x, y + height);
            }
        }
Esempio n. 16
0
        public void FillRoundRectangle(PDFBrush brush, PDFUnit x, PDFUnit y, PDFUnit width, PDFUnit height, Sides sides, PDFUnit cornerRadius)
        {
            if (brush == null)
            {
                throw new ArgumentNullException("brush");
            }

            if (null != brush.UnderBrush)
            {
                this.FillRoundRectangle(brush.UnderBrush, x, y, width, height, sides, cornerRadius);
            }

            PDFRect bounds = new PDFRect(x, y, width, height);

            this.SaveGraphicsState();
            brush.SetUpGraphics(this, bounds);
            this.DoOutputRoundRectangleWithSidesFill(x, y, width, height, cornerRadius, sides);
            this.RenderFillPathOp();
            brush.ReleaseGraphics(this, bounds);
            this.RestoreGraphicsState();
        }
Esempio n. 17
0
        private void AddExecMsg(List <ExecutionMessage> diff, DateTimeOffset time, DateTimeOffset serverTime, QuoteChange quote, decimal volume, Sides side, bool isSpread)
        {
            if (volume > 0)
            {
                diff.Add(CreateMessage(time, serverTime, side, quote.Price, volume));
            }
            else
            {
                volume = volume.Abs();

                // matching only top orders (spread)
                if (isSpread && volume > 1 && _isMatch.Next())
                {
                    var tradeVolume = (int)volume / 2;

                    diff.Add(new ExecutionMessage
                    {
                        Side          = side,
                        TradeVolume   = tradeVolume,
                        ExecutionType = ExecutionTypes.Tick,
                        SecurityId    = SecurityId,
                        LocalTime     = time,
                        ServerTime    = serverTime,
                        TradePrice    = quote.Price,
                    });

                    // that tick will not affect on order book
                    //volume -= tradeVolume;
                }

                diff.Add(CreateMessage(time, serverTime, side, quote.Price, volume, true));
            }
        }
Esempio n. 18
0
 public static QuoteChange ToStockSharp(this double[] vp, Sides side)
 {
     return(new QuoteChange(side, (decimal)vp[0], (decimal)vp[1]));
 }
		private void OnOrderReply(Modes mode, uint transId, long orderId, string classCode, string secCode, double price, int balance, int volume, Sides side, OrderStates state)
		{
			this.AddDebugLog("Order: Mode {0} transId {1} orderId {2} classCode {3} secCode {4} price {5} balance {6} volume {7} side {8} state {9}", mode, transId, orderId, classCode, secCode, price, balance, volume, side, state);
		}
Esempio n. 20
0
        /// <summary>
        /// Gets the check image.
        /// </summary>
        /// <param name="side">The side.</param>
        /// <returns></returns>
        private BitmapImage GetCheckImage( Sides side )
        {
            ImageColorType colorType = RockConfig.Load().ImageColorType;

            int imageByteCount;
            imageByteCount = rangerScanner.GetImageByteCount( (int)side, (int)colorType );
            byte[] imageBytes = new byte[imageByteCount];

            // create the pointer and assign the Ranger image address to it
            IntPtr imgAddress = new IntPtr( rangerScanner.GetImageAddress( (int)side, (int)colorType ) );

            // Copy the bytes from unmanaged memory to managed memory
            Marshal.Copy( imgAddress, imageBytes, 0, imageByteCount );

            BitmapImage bitImage = new BitmapImage();

            bitImage.BeginInit();
            bitImage.StreamSource = new MemoryStream( imageBytes );
            bitImage.EndInit();

            return bitImage;
        }
        /// <summary>
        /// Offsets position of component relative to another component.
        /// </summary>
        /// <param name="component">Component to offset against.</param>
        /// <param name="side">The side of the component to offset from.</param>
        /// <param name="distance">Distance between offset components.</param>
        public void OffsetFrom(BaseScreenComponent component, Sides side, int distance)
        {
            // Exit if invalid offset
            if (component == null || side == Sides.None)
                return;

            // Get rectangles
            Rect myRect = Rectangle;
            Rect otherRect = component.Rectangle;

            // Offset based on side
            switch (side)
            {
                case Sides.Left:
                    position.x = otherRect.xMin - distance - myRect.width;
                    break;
                case Sides.Right:
                    position.x = otherRect.xMax + distance;
                    break;
                case Sides.Top:
                    position.y = otherRect.yMin - distance - myRect.height;
                    break;
                case Sides.Bottom:
                    position.y = otherRect.yMax + distance;
                    break;
            }
        }
		private int GetQuoteIndex(Sides direction, int depthLevel)
		{
			var isBidsOnTop = IsBidsOnTop;

			if (direction == Sides.Buy)
				return isBidsOnTop ? MaxDepth - 1 - depthLevel : MaxDepth + depthLevel;
			else
				return isBidsOnTop ? MaxDepth + depthLevel : MaxDepth - 1 - depthLevel;
		}
Esempio n. 23
0
		/// <summary>
		/// To calculate trade profitability. If the trade was already processed earlier, previous information returns.
		/// </summary>
		/// <param name="trade">Trade.</param>
		/// <returns>Information on new trade.</returns>
		public PnLInfo Process(ExecutionMessage trade)
		{
			if (trade == null)
				throw new ArgumentNullException(nameof(trade));

			var closedVolume = 0m;
			var pnl = 0m;
			var volume = trade.SafeGetVolume();
			var price = trade.GetTradePrice();

			_unrealizedPnL = null;

			lock (_openedTrades.SyncRoot)
			{
				if (_openedTrades.Count > 0)
				{
					var currTrade = _openedTrades.Peek();

					if (_openedPosSide != trade.Side)
					{
						while (volume > 0)
						{
							if (currTrade == null)
								currTrade = _openedTrades.Peek();

							var diff = currTrade.Second.Min(volume);
							closedVolume += diff;

							pnl += TraderHelper.GetPnL(currTrade.First, diff, _openedPosSide, price);

							volume -= diff;
							currTrade.Second -= diff;

							if (currTrade.Second != 0)
								continue;

							currTrade = null;
							_openedTrades.Pop();

							if (_openedTrades.Count == 0)
								break;
						}
					}
				}

				if (volume > 0)
				{
					_openedPosSide = trade.Side;
					_openedTrades.Push(RefTuple.Create(price, volume));
				}

				RealizedPnL += _multiplier * pnl;
			}

			return new PnLInfo(trade, closedVolume, pnl);
		}
Esempio n. 24
0
		private Order CreateOrder(Sides direction, decimal price = 0, OrderTypes type = OrderTypes.Market)
		{
			return new Order
			{
				Portfolio = Settings.Portfolio,
				Security = Settings.Security,
				Direction = direction,
				Price = price,
				Volume = Settings.Volume,
				Type = type,
			};
		}
Esempio n. 25
0
        private ExecutionMessage CreateMessage(DateTimeOffset localTime, DateTimeOffset serverTime, Sides side, decimal price, decimal volume, bool isCancelling = false, TimeInForce tif = TimeInForce.PutInQueue)
        {
            if (price <= 0)
            {
                throw new ArgumentOutOfRangeException(nameof(price), price, LocalizedStrings.Str1144);
            }

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

            if (volume == 0)
            {
                volume = _volumeRandom.Next(10, 100);
            }

            return(new ExecutionMessage
            {
                Side = side,
                OrderPrice = price,
                OrderVolume = volume,
                ExecutionType = ExecutionTypes.OrderLog,
                IsCancellation = isCancelling,
                SecurityId = SecurityId,
                LocalTime = localTime,
                ServerTime = serverTime,
                TimeInForce = tif,
            });
        }
		private void OnTradeReply(Modes mode, long tradeId, long orderId, string classCode, string secCode, double price, int balance, int volume, Sides side)
		{
			this.AddDebugLog("Trade: Mode {0} tradeId {1} orderId {2} classCode {3} secCode {4} price {5} balance {6} volume {7} side {8}", mode, tradeId, orderId, classCode, secCode, price, balance, volume, side);
		}
Esempio n. 27
0
    IEnumerator SpawnEnemy(GameObject spawnedObjectPrefab, float delay, bool _burst)
    {
        // Normal fast (yellow) enemies
        if (!_burst)
        {
            while (true)
            {
                yield return(new WaitForSeconds(spawnRate));

                Score++;

                side = (Sides)Random.Range(0, 4);

                switch (side)
                {
                case Sides.Left:
                    spawnPos = new Vector3(-0.1f, Random.value, 0);
                    break;

                case Sides.Right:
                    spawnPos = new Vector3(1.1f, Random.value, 0);
                    break;

                case Sides.Up:
                    spawnPos = new Vector3(Random.value, 1.1f, 0);
                    break;

                case Sides.Down:
                    spawnPos = new Vector3(Random.value, -0.1f, 0);
                    break;
                }

                Vector3 spawnX = Camera.main.ViewportToWorldPoint(spawnPos);

                Instantiate(spawnedObjectPrefab, spawnX, Quaternion.identity);
            }
        }
        else
        {
            // BURST

            side = (Sides)Random.Range(0, 4);

            switch (side)
            {
            case Sides.Left:
                spawnPos = new Vector3(-0.1f, Random.value, 0);
                break;

            case Sides.Right:
                spawnPos = new Vector3(1.1f, Random.value, 0);
                break;

            case Sides.Up:
                spawnPos = new Vector3(Random.value, 1.1f, 0);
                break;

            case Sides.Down:
                spawnPos = new Vector3(Random.value, -0.1f, 0);
                break;
            }


            Camera.main.GetComponent <CameraShake>().ShakeCamera(1.3f, 5);

            AudioManager.instance.PlaySound("WaveIn");

            yield return(new WaitForSeconds(1f));


            for (int i = 0; i < 15; i++)
            {
                Vector3 spawnX = Camera.main.ViewportToWorldPoint(spawnPos);

                if (side == Sides.Up || side == Sides.Down)
                {
                    spawnX.x += i;
                }
                else
                {
                    spawnX.y += i;
                }

                Instantiate(spawnedObjectPrefab, spawnX, Quaternion.identity);
            }

            burst = true;
        }
    }
Esempio n. 28
0
		/// <summary>
		/// Отменить группу заявок на бирже по фильтру.
		/// </summary>
		/// <param name="transactionId">Идентификатор транзакции отмены.</param>
		/// <param name="isStopOrder"><see langword="true"/>, если нужно отменить только стоп-заявки, <see langword="false"/> - если только обычный и <see langword="null"/> - если оба типа.</param>
		/// <param name="portfolio">Портфель. Если значение равно <see langword="null"/>, то портфель не попадает в фильтр снятия заявок.</param>
		/// <param name="direction">Направление заявки. Если значение равно <see langword="null"/>, то направление не попадает в фильтр снятия заявок.</param>
		/// <param name="board">Торговая площадка. Если значение равно <see langword="null"/>, то площадка не попадает в фильтр снятия заявок.</param>
		/// <param name="security">Инструмент. Если значение равно <see langword="null"/>, то инструмент не попадает в фильтр снятия заявок.</param>
		protected override void OnCancelOrders(long transactionId, bool? isStopOrder = null, Portfolio portfolio = null, Sides? direction = null, ExchangeBoard board = null, Security security = null)
		{
			if (security != null && portfolio != null && security.Type == SecurityTypes.Future && !security.UnderlyingSecurityId.IsEmpty())
				base.OnCancelOrders(transactionId, isStopOrder, portfolio, direction, board, security);
			else
				this.CancelOrders(Orders, isStopOrder, portfolio, direction, board);
		}
Esempio n. 29
0
        /// <summary>
        /// Gets the doc image.
        /// </summary>
        /// <param name="side">The side.</param>
        /// <returns></returns>
        private byte[] GetImageBytesFromRanger( Sides side )
        {
            ImageColorType colorType = RockConfig.Load().ImageColorType;

            int imageByteCount;
            imageByteCount = batchPage.rangerScanner.GetImageByteCount( (int)side, (int)colorType );
            if ( imageByteCount > 0 )
            {
                byte[] imageBytes = new byte[imageByteCount];

                // create the pointer and assign the Ranger image address to it
                IntPtr imgAddress = new IntPtr( batchPage.rangerScanner.GetImageAddress( (int)side, (int)colorType ) );

                // Copy the bytes from unmanaged memory to managed memory
                Marshal.Copy( imgAddress, imageBytes, 0, imageByteCount );

                return imageBytes;
            }
            else
            {
                return null;
            }
        }
Esempio n. 30
0
		/// <summary>
		/// Convert order side into string.
		/// </summary>
		/// <param name="direction">Order side.</param>
		/// <returns>The formatted string.</returns>
		protected virtual string Format(Sides direction)
		{
			return direction == Sides.Buy ? LocalizedStrings.Str403 : LocalizedStrings.Str404;
		}
Esempio n. 31
0
 public void FillRoundRectangle(PDFBrush brush, PDFPoint pos, PDFSize size, Sides sides, PDFUnit cornerRadius)
 {
     this.FillRoundRectangle(brush, pos.X, pos.Y, size.Width, size.Height, sides, cornerRadius);
 }
Esempio n. 32
0
		public void CancelOrders(bool? isStopOrder, string portfolioName, Sides? side, SecurityId securityId, SecurityTypes? securityType)
		{
			_adapter.AddDebugLog("CancelOrders: stop={0}, portf={1}, side={2}, id={3}", isStopOrder, portfolioName, side, securityId);

			var isBuySell = (side == null) ? null : side.Value.ToAlfaDirect();
			var account = portfolioName.IsEmpty() ? null : portfolioName.AccountFromPortfolioName();
			var pCode = securityId.SecurityCode.IsEmpty() ? null : securityId.SecurityCode;

			var treaties = new List<string>();
			var treaty = account.IsEmpty() ? null : account.TreatyFromAccount();

			if (!treaty.IsEmpty())
				treaties.Add(treaty);
			else
			{
				var data = _tableAccounts.GetLocalDbData();
				treaties.AddRange(data.Select(row => FieldsAccounts.Treaty.GetStrValue(row.ToColumns())));
			}

			if (!treaties.Any())
				throw new InvalidOperationException(LocalizedStrings.Str2277Params.Put(portfolioName));

			string placeCode = null;
			if (!securityId.IsDefault())
			{
				placeCode = _adapter.SecurityClassInfo.GetSecurityClass(securityType, securityId.BoardCode);

				if (placeCode == null)
					throw new InvalidOperationException(LocalizedStrings.Str2278);
			}

			foreach (var t in treaties)
				_ad.DropOrder(null, isBuySell, t, account, placeCode, pCode, -1);
		}
Esempio n. 33
0
 public void DrawRectangle(PDFPen pen, PDFRect rect, Sides sides)
 {
     this.DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height, sides);
 }
Esempio n. 34
0
        public static void CreateCube(SurfaceTool st, float size, Vector3 position, Sides sides)
        {
            if (sides.HasFlag(Sides.North) ||
                sides.HasFlag(Sides.East) ||
                sides.HasFlag(Sides.South) ||
                sides.HasFlag(Sides.West))
            {
                Color white = new Color(1f, 1f, 1f, 1f);

                Vector3[] vertices = GetVerticesForCell(size, position);

                if (sides.HasFlag(Sides.North))
                {
                    st.AddUv(new Vector2(1, 1));
                    st.AddNormal(North);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Bot_NW]);
                    st.AddUv(new Vector2(0, 0));
                    st.AddNormal(North);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Top_NE]);
                    st.AddUv(new Vector2(1, 0));
                    st.AddNormal(North);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Top_NW]);

                    st.AddUv(new Vector2(1, 1));
                    st.AddNormal(North);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Bot_NW]);
                    st.AddUv(new Vector2(0, 1));
                    st.AddNormal(North);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Bot_NE]);
                    st.AddUv(new Vector2(0, 0));
                    st.AddNormal(North);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Top_NE]);
                }

                if (sides.HasFlag(Sides.East))
                {
                    st.AddUv(new Vector2(0, 0));
                    st.AddNormal(East);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Top_SE]);
                    st.AddUv(new Vector2(1, 0));
                    st.AddNormal(East);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Top_NE]);
                    st.AddUv(new Vector2(0, 1));
                    st.AddNormal(East);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Bot_SE]);

                    st.AddUv(new Vector2(1, 0));
                    st.AddNormal(East);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Top_NE]);
                    st.AddUv(new Vector2(1, 1));
                    st.AddNormal(East);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Bot_NE]);
                    st.AddUv(new Vector2(0, 1));
                    st.AddNormal(East);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Bot_SE]);
                }

                if (sides.HasFlag(Sides.South))
                {
                    st.AddUv(new Vector2(0, 0));
                    st.AddNormal(South);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Top_SW]);
                    st.AddUv(new Vector2(1, 0));
                    st.AddNormal(South);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Top_SE]);
                    st.AddUv(new Vector2(0, 1));
                    st.AddNormal(South);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Bot_SW]);

                    st.AddUv(new Vector2(1, 0));
                    st.AddNormal(South);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Top_SE]);
                    st.AddUv(new Vector2(1, 1));
                    st.AddNormal(South);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Bot_SE]);
                    st.AddUv(new Vector2(0, 1));
                    st.AddNormal(South);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Bot_SW]);
                }

                if (sides.HasFlag(Sides.West))
                {
                    st.AddUv(new Vector2(1, 1));
                    st.AddNormal(West);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Bot_SW]);
                    st.AddUv(new Vector2(0, 0));
                    st.AddNormal(West);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Top_NW]);
                    st.AddUv(new Vector2(1, 0));
                    st.AddNormal(West);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Top_SW]);

                    st.AddUv(new Vector2(1, 1));
                    st.AddNormal(West);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Bot_SW]);
                    st.AddUv(new Vector2(0, 1));
                    st.AddNormal(West);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Bot_NW]);
                    st.AddUv(new Vector2(0, 0));
                    st.AddNormal(West);
                    st.AddColor(white);
                    st.AddVertex(vertices[(int)CellVertexIndex.Top_NW]);
                }
            }
        }
Esempio n. 35
0
        private void DoOutputRoundRectangleWithSidesPath(PDFUnit x, PDFUnit y, PDFUnit width, PDFUnit height, PDFUnit cornerRadius, Sides sides)
        {
            PDFUnit handleoffset = (PDFUnit)(cornerRadius.PointsValue * CircularityFactor);

            bool requiresmove = false;

            if ((sides & Sides.Left) > 0)
            {
                if ((sides & Sides.Bottom) == 0)
                {
                    this.RenderMoveTo(x, y + height);
                }
                else
                {
                    this.RenderMoveTo(x, y + height - cornerRadius);
                }

                //left vertical
                if ((sides & Sides.Top) == 0) //no top line so extend full height
                {
                    this.RenderLineTo(x, y);
                }
                else
                {
                    this.RenderLineTo(x, y + cornerRadius);
                }
            }
            else
            {
                requiresmove = true;
            }

            if ((sides & Sides.Top) > 0)
            {
                if (requiresmove)
                {
                    if ((sides & Sides.Left) == 0)//no left side
                    {
                        RenderMoveTo(x, y);
                    }
                    else
                    {
                        RenderMoveTo(x + cornerRadius, y);
                    }
                }
                else
                {
                    //topleft arc
                    this.RenderBezierCurveTo(x + cornerRadius, y, x, y + cornerRadius - handleoffset, x + cornerRadius - handleoffset, y);
                }

                //top horizontal
                if ((sides & Sides.Right) == 0)
                {
                    this.RenderLineTo(x + width, y);//no right line so extend full width
                }
                else
                {
                    this.RenderLineTo(x + width - cornerRadius, y);
                }
                requiresmove = false;
            }
            else
            {
                requiresmove = true;
            }

            if ((sides & Sides.Right) > 0)
            {
                if (requiresmove)
                {
                    if ((sides & Sides.Top) == 0)   //no top side
                    {
                        RenderMoveTo(x + width, y); //go to the top right corner
                    }
                    else
                    {
                        RenderMoveTo(x + width, y + cornerRadius);
                    }
                }
                else
                {
                    //topright arc
                    this.RenderBezierCurveTo(x + width, y + cornerRadius, x + width - cornerRadius + handleoffset, y, x + width, y + cornerRadius - handleoffset);
                }

                //right vertical
                if ((sides & Sides.Bottom) == 0)
                {
                    this.RenderLineTo(x + width, y + height);//no bottom line so extend to full height
                }
                else
                {
                    this.RenderLineTo(x + width, y + height - cornerRadius);
                }
                requiresmove = false;
            }
            else
            {
                requiresmove = true;
            }

            if ((sides & Sides.Bottom) > 0)
            {
                if (requiresmove)
                {
                    if ((sides & Sides.Right) == 0)          //no right side
                    {
                        RenderMoveTo(x + width, y + height); //go to the bottom left corner
                    }
                    else
                    {
                        RenderMoveTo(x + width, y + height - cornerRadius);
                    }
                }
                else
                {
                    //bottomright arc
                    this.RenderBezierCurveTo(x + width - cornerRadius, y + height, x + width, y + height - cornerRadius + handleoffset, x + width - cornerRadius + handleoffset, y + height);
                }
                //bottom line
                if ((sides & Sides.Left) == 0)
                {
                    this.RenderLineTo(x, y + height);
                }
                else
                {
                    this.RenderLineTo(x + cornerRadius, y + height);
                }

                //if we have the left and bottom sides we need to connect them
                if ((sides & Sides.Left) > 0)
                {
                    //bottom left arc
                    this.RenderBezierCurveTo(x, y + height - cornerRadius, x + cornerRadius - handleoffset, y + height, x, y + height - cornerRadius + handleoffset);
                }
            }
            else
            {
                requiresmove = true;
            }
        }
Esempio n. 36
0
 private void OnTradeReply(Modes mode, long tradeId, long orderId, string classCode, string secCode, double price, int balance, int volume, Sides side)
 {
     this.AddDebugLog("Trade: Mode {0} tradeId {1} orderId {2} classCode {3} secCode {4} price {5} balance {6} volume {7} side {8}", mode, tradeId, orderId, classCode, secCode, price, balance, volume, side);
 }
Esempio n. 37
0
        public void DrawRectangle(PDFPen pen, PDFUnit x, PDFUnit y, PDFUnit width, PDFUnit height, Sides sides)
        {
            if (pen == null)
            {
                throw new ArgumentNullException("pen");
            }

            PDFRect rect = new PDFRect(x, y, width, height);

            this.SaveGraphicsState();
            pen.SetUpGraphics(this, rect);

            //check to see if we are outputting all sides
            if (sides == (Sides.Top | Sides.Right | Sides.Left | Sides.Bottom))
            {
                this.RenderRectangle(x, y, width, height);
            }
            else
            {
                bool recalc = true; //flag to identifiy if the last op moved the cursor to the next correct position

                if ((sides & Sides.Top) > 0)
                {
                    this.RenderLine(x, y, x + width, y);
                    recalc = false;
                }
                else
                {
                    recalc = true;
                }

                if ((sides & Sides.Right) > 0)
                {
                    if (recalc == false)
                    {
                        this.RenderContinuationLine(x + width, y + height);
                    }
                    else
                    {
                        this.RenderLine(x + width, y, x + width, y + height);
                    }
                    recalc = false;
                }
                else
                {
                    recalc = true;
                }

                if ((sides & Sides.Bottom) > 0)
                {
                    if (recalc == false)
                    {
                        this.RenderContinuationLine(x, y + height);
                    }
                    else
                    {
                        this.RenderLine(x + width, y + height, x, y + height);
                    }
                    recalc = false;
                }
                else
                {
                    recalc = true;
                }

                if ((sides & Sides.Left) > 0)
                {
                    if (recalc == false)
                    {
                        this.RenderContinuationLine(x, y);
                    }
                    else
                    {
                        this.RenderLine(x, y + height, x, y);
                    }
                }
            }
            this.RenderStrokePathOp();
            pen.ReleaseGraphics(this, rect);

            this.RestoreGraphicsState();
        }
Esempio n. 38
0
        private void TryCreateOppositeOrder(List <ExecutionMessage> retVal, SortedDictionary <decimal, RefPair <LevelQuotes, QuoteChange> > quotes, DateTimeOffset localTime, DateTimeOffset serverTime, decimal tradePrice, decimal volume, Sides originSide)
        {
            if (HasDepth(localTime))
            {
                return;
            }

            var priceStep     = GetPriceStep();
            var oppositePrice = (tradePrice + _settings.SpreadSize * priceStep * (originSide == Sides.Buy ? 1 : -1)).Max(priceStep);

            var bestQuote = quotes.FirstOrDefault();

            if (bestQuote.Value == null || ((originSide == Sides.Buy && oppositePrice < bestQuote.Key) || (originSide == Sides.Sell && oppositePrice > bestQuote.Key)))
            {
                retVal.Add(CreateMessage(localTime, serverTime, originSide.Invert(), oppositePrice, volume));
            }
        }
Esempio n. 39
0
 private void OnOrderReply(Modes mode, uint transId, long orderId, string classCode, string secCode, double price, int balance, int volume, Sides side, OrderStates state)
 {
     this.AddDebugLog("Order: Mode {0} transId {1} orderId {2} classCode {3} secCode {4} price {5} balance {6} volume {7} side {8} state {9}", mode, transId, orderId, classCode, secCode, price, balance, volume, side, state);
 }
 private void SetSides(Sides mode, bool autoSave)
 {
     if (mode == Sides.OneSide && scanProfile.CurrentFeeder == FeederMode.Flatbed &&
         scanProfile.CurrentSides == Sides.BothSides)
         tempSides = Sides.BothSides;
     else
         tempSides = null;
     SetChecked(barButtonItemOneSide, mode == Sides.OneSide);
     SetChecked(barButtonItemBothSides, mode == Sides.BothSides);
     SetVisible(barButtonItemBack, mode == Sides.BothSides);
     if (autoSave)
         scanProfile.CurrentSides = mode;
 }
Esempio n. 41
0
 public Bishop(int position, Sides side, bool firstMove)
     : base(position, side, PieceType.BISHOP, firstMove)
 {
 }
Esempio n. 42
0
 private IEnumerable <QuoteChange> CreateQuoteChanges(IEnumerable <QuoteChange[]> pairs, Sides side)
 {
     return(pairs
            .Where(p => p.All(q => q != null))
            .Select(p => new QuoteChange
     {
         Side = side,
         Price = Calculate(p, true, item => item.Price),
         Volume = Calculate(p, false, item => item.Volume)
     })
            .ToArray());
 }
Esempio n. 43
0
        private IEnumerable <ExecutionMessage> IncreaseDepthVolume(DateTime time, DateTimeOffset serverTime, Sides orderSide, decimal leftVolume)
        {
            var quotes = orderSide == Sides.Buy ? _asks : _bids;
            var quote  = quotes.LastOrDefault();

            if (quote.Value == null)
            {
                yield break;
            }

            var side = orderSide.Invert();

            var lastVolume = quote.Value.Second.Volume;
            var lastPrice  = quote.Value.Second.Price;

            while (leftVolume > 0 && lastPrice != 0)
            {
                lastVolume *= 2;
                lastPrice  += GetPriceStep() * (side == Sides.Buy ? -1 : 1);

                leftVolume -= lastVolume;

                yield return(CreateMessage(time, serverTime, side, lastPrice, lastVolume));
            }
        }
Esempio n. 44
0
		public void ResetSlicing()
		{
			sideStatus = Sides.None;
		}
Esempio n. 45
0
		/// <summary>
		/// Отменить группу заявок на бирже по фильтру.
		/// </summary>
		/// <param name="transactionId">Идентификатор транзакции отмены.</param>
		/// <param name="isStopOrder"><see langword="true"/>, если нужно отменить только стоп-заявки, false - если только обычный и null - если оба типа.</param>
		/// <param name="portfolio">Портфель. Если значение равно null, то портфель не попадает в фильтр снятия заявок.</param>
		/// <param name="direction">Направление заявки. Если значение равно null, то направление не попадает в фильтр снятия заявок.</param>
		/// <param name="board">Торговая площадка. Если значение равно null, то площадка не попадает в фильтр снятия заявок.</param>
		/// <param name="security">Инструмент. Если значение равно null, то инструмент не попадает в фильтр снятия заявок.</param>
		protected override void OnCancelOrders(long transactionId, bool? isStopOrder = null, Portfolio portfolio = null, Sides? direction = null, ExchangeBoard board = null, Security security = null)
		{
			if (Version == SmartComVersions.V2 && isStopOrder == null && portfolio == null && direction == null && board == null && security == null)
				base.OnCancelOrders(transactionId);
			else
				this.CancelOrders(Orders, isStopOrder, portfolio, direction, board, security);
		}
Esempio n. 46
0
		public static QuoteChange ToStockSharp(this double[] vp, Sides side)
		{
			return new QuoteChange(side, (decimal)vp[0], (decimal)vp[1]);
		}
Esempio n. 47
0
 public void addNeighbor(Sides side, Tile tile)
 {
     neighbors [(int)side] = tile;
     CalculateAutotileID();
 }
Esempio n. 48
0
		/// <summary>
		/// To create the quote using random method.
		/// </summary>
		/// <param name="startPrice">The initial price, based on which a quote price shall be got using random method.</param>
		/// <param name="side">The quote direction.</param>
		/// <returns>The random quote.</returns>
		protected QuoteChange CreateQuote(decimal startPrice, Sides side)
		{
			var priceStep = SecurityDefinition.PriceStep ?? 0.01m;

			var price = startPrice + (side == Sides.Sell ? 1 : -1) * Steps.Next() * priceStep;

			if (price <= 0)
				price = priceStep;

			return new QuoteChange(side, price, Volumes.Next());
		}
Esempio n. 49
0
        private void CancelWorstQuote(List <ExecutionMessage> retVal, DateTimeOffset time, DateTimeOffset serverTime, Sides side, SortedDictionary <decimal, RefPair <LevelQuotes, QuoteChange> > quotes)
        {
            if (quotes.Count <= _settings.MaxDepth)
            {
                return;
            }

            var worst  = quotes.Last();
            var volume = worst.Value.First.Where(e => e.PortfolioName == null).Sum(e => e.OrderVolume.Value);

            if (volume == 0)
            {
                return;
            }

            retVal.Add(CreateMessage(time, serverTime, side, worst.Key, volume, true));
        }
 public bool MoveAllofOneSide(Sides side)
 {
     return true;
 }
Esempio n. 51
0
        private static IEnumerable <QuoteChange> DeserializeQuotes(BitArrayReader reader, QuoteMetaInfo metaInfo, Sides side)
        {
            if (reader == null)
            {
                throw new ArgumentNullException(nameof(reader));
            }

            if (metaInfo == null)
            {
                throw new ArgumentNullException(nameof(metaInfo));
            }

            var list = new List <QuoteChange>();

            var deltaCount = reader.ReadInt();

            if (deltaCount == 0)
            {
                return(list);
            }

            var prevPrice = metaInfo.FirstPrice;

            for (var i = 0; i < deltaCount; i++)
            {
                metaInfo.FirstPrice = reader.ReadPrice(metaInfo.FirstPrice, metaInfo);

                var volume = reader.ReadVolume(metaInfo);

                list.Add(new QuoteChange(side, metaInfo.FirstPrice, volume));
            }

            metaInfo.FirstPrice = prevPrice;

            return(list);
        }
        /// <summary>
        /// Checks distance to wall and returns the side  of the wall
        /// </summary>
        /// <param name="position"></param>
        /// <param name="widthBound"></param>
        /// <param name="heightBound"></param>
        /// <param name="distance"></param>
        /// <param name="side"></param>
        /// <returns></returns>
        public static bool NearestDistanceToWall(Vector2 position, float widthBound, float heightBound, float distance, out Sides side)
        {
            side = Sides.None;
            if (position.X < distance)
            {
                side = Sides.Left;
            }
            else if (position.X > widthBound - distance)
            {
                side = Sides.Right;
            }
            else if (position.Y < distance)
            {
                side = Sides.Up;
            }
            else if (position.Y > heightBound - distance)
            {
                side = Sides.Down;
            }
            if (position.X < distance || position.X > widthBound - distance || position.Y < distance ||
                position.Y > heightBound - distance)
            {
                return(true);
            }

            return(false);
        }
Esempio n. 53
0
 public bool MoveAllofOneSide(Sides side)
 {
     return(true);
 }
Esempio n. 54
0
 public void DrawRoundRectangle(PDFPen pen, PDFRect rect, Sides sides, PDFUnit cornerRadius)
 {
     this.DrawRoundRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height, sides, cornerRadius);
 }
Esempio n. 55
0
        private void GetDiff(List <ExecutionMessage> diff, DateTimeOffset time, DateTimeOffset serverTime, SortedDictionary <decimal, RefPair <LevelQuotes, QuoteChange> > from, IEnumerable <QuoteChange> to, Sides side, out decimal newBestPrice)
        {
            newBestPrice = 0;

            var canProcessFrom = true;
            var canProcessTo   = true;

            QuoteChange currFrom = null;
            QuoteChange currTo   = null;

            // TODO
            //List<ExecutionMessage> currOrders = null;

            var  mult     = side == Sides.Buy ? -1 : 1;
            bool?isSpread = null;

            using (var fromEnum = from.GetEnumerator())
                using (var toEnum = to.GetEnumerator())
                {
                    while (true)
                    {
                        if (canProcessFrom && currFrom == null)
                        {
                            if (!fromEnum.MoveNext())
                            {
                                canProcessFrom = false;
                            }
                            else
                            {
                                currFrom = fromEnum.Current.Value.Second;
                                isSpread = isSpread == null;
                            }
                        }

                        if (canProcessTo && currTo == null)
                        {
                            if (!toEnum.MoveNext())
                            {
                                canProcessTo = false;
                            }
                            else
                            {
                                currTo = toEnum.Current;

                                if (newBestPrice == 0)
                                {
                                    newBestPrice = currTo.Price;
                                }
                            }
                        }

                        if (currFrom == null)
                        {
                            if (currTo == null)
                            {
                                break;
                            }
                            else
                            {
                                AddExecMsg(diff, time, serverTime, currTo, currTo.Volume, side, false);
                                currTo = null;
                            }
                        }
                        else
                        {
                            if (currTo == null)
                            {
                                AddExecMsg(diff, time, serverTime, currFrom, -currFrom.Volume, side, isSpread.Value);
                                currFrom = null;
                            }
                            else
                            {
                                if (currFrom.Price == currTo.Price)
                                {
                                    if (currFrom.Volume != currTo.Volume)
                                    {
                                        AddExecMsg(diff, time, serverTime, currTo, currTo.Volume - currFrom.Volume, side, isSpread.Value);
                                    }

                                    currFrom = currTo = null;
                                }
                                else if (currFrom.Price * mult > currTo.Price * mult)
                                {
                                    AddExecMsg(diff, time, serverTime, currTo, currTo.Volume, side, isSpread.Value);
                                    currTo = null;
                                }
                                else
                                {
                                    AddExecMsg(diff, time, serverTime, currFrom, -currFrom.Volume, side, isSpread.Value);
                                    currFrom = null;
                                }
                            }
                        }
                    }
                }
        }
Esempio n. 56
0
 public void DrawRoundRectangle(PDFPen pen, PDFPoint pos, PDFSize size, Sides sides, PDFUnit cornerRadius)
 {
     this.DrawRoundRectangle(pen, pos.X, pos.Y, size.Width, size.Height, sides, cornerRadius);
 }
Esempio n. 57
0
        private void ProcessMarketOrder(List <ExecutionMessage> retVal, SortedDictionary <decimal, RefPair <LevelQuotes, QuoteChange> > quotes, DateTimeOffset time, DateTimeOffset localTime, Sides orderSide, decimal tradePrice, decimal volume)
        {
            // вычисляем объем заявки по рынку, который смог бы пробить текущие котировки.

            // bigOrder - это наша большая рыночная заявка, которая способствовала появлению tradeMessage
            var bigOrder  = CreateMessage(localTime, time, orderSide, tradePrice, 0, tif: TimeInForce.MatchOrCancel);
            var sign      = orderSide == Sides.Buy ? -1 : 1;
            var hasQuotes = false;

            foreach (var pair in quotes)
            {
                var quote = pair.Value.Second;

                if (quote.Price * sign > tradePrice * sign)
                {
                    bigOrder.OrderVolume += quote.Volume;
                }
                else
                {
                    if (quote.Price == tradePrice)
                    {
                        bigOrder.OrderVolume += volume;

                        //var diff = tradeMessage.Volume - quote.Volume;

                        //// если объем котиовки был меньше объема сделки
                        //if (diff > 0)
                        //	retVal.Add(CreateMessage(tradeMessage.LocalTime, quote.Side, quote.Price, diff));
                    }
                    else
                    {
                        if ((tradePrice - quote.Price).Abs() == _securityDefinition.PriceStep)
                        {
                            // если на один шаг цены выше/ниже есть котировка, то не выполняем никаких действий
                            // иначе добавляем новый уровень в стакан, чтобы не было большого расхождения цен.
                            hasQuotes = true;
                        }

                        break;
                    }

                    //// если котировки с ценой сделки вообще не было в стакане
                    //else if (quote.Price * sign < tradeMessage.TradePrice * sign)
                    //{
                    //	retVal.Add(CreateMessage(tradeMessage.LocalTime, quote.Side, tradeMessage.Price, tradeMessage.Volume));
                    //}
                }
            }

            retVal.Add(bigOrder);

            // если собрали все котировки, то оставляем заявку в стакане по цене сделки
            if (!hasQuotes)
            {
                retVal.Add(CreateMessage(localTime, time, orderSide.Invert(), tradePrice, volume));
            }
        }
Esempio n. 58
0
        public void DrawRoundRectangle(PDFPen pen, PDFUnit x, PDFUnit y, PDFUnit width, PDFUnit height, Sides sides, PDFUnit cornerRadius)
        {
            if (pen == null)
            {
                throw new ArgumentNullException("pen");
            }

            PDFRect bounds = new PDFRect(x, y, width, height);

            this.SaveGraphicsState();
            pen.SetUpGraphics(this, bounds);
            this.DoOutputRoundRectangleWithSidesPath(x, y, width, height, cornerRadius, sides);
            this.RenderStrokePathOp();
            pen.ReleaseGraphics(this, bounds);
            this.RestoreGraphicsState();
        }
Esempio n. 59
0
    private void AddRiverTile(Sides riverSides, RiverTile riverTile, Vector3 vert1, Vector2 biome, float north, float east, float south, float west)
    {
        Vector3[,] verts = new Vector3[4,4];

        int waterLevel = int.MaxValue;

        if (riverTile.north.min_pos >= 0)
            waterLevel = Mathf.Min(riverTile.north.elevation, waterLevel);
        if (riverTile.east.min_pos >= 0)
            waterLevel = Mathf.Min(riverTile.east.elevation, waterLevel);
        if (riverTile.south.min_pos >= 0)
            waterLevel = Mathf.Min(riverTile.south.elevation, waterLevel);
        if (riverTile.west.min_pos >= 0)
            waterLevel = Mathf.Min(riverTile.west.elevation, waterLevel);

        //setup a few vertices that are used everywhere.
        verts[0, 0] = vert1;
        verts[3, 3] = vert1 + new Vector3(48 * GameMap.tileWidth, 0, -48 * GameMap.tileWidth);
        verts[0, 3] = new Vector3(verts[0, 0].x, verts[0, 0].y, verts[3, 3].z);
        verts[3, 0] = new Vector3(verts[3, 3].x, verts[0, 0].y, verts[0, 0].z);

        verts[1, 0] = verts[0, 0] + new Vector3(riverTile.north.min_pos * GameMap.tileWidth, 0, 0);
        verts[2, 0] = verts[0, 0] + new Vector3((riverTile.north.max_pos + 1) * GameMap.tileWidth, 0, 0);

        verts[1, 3] = verts[0, 3] + new Vector3(riverTile.south.min_pos * GameMap.tileWidth, 0, 0);
        verts[2, 3] = verts[0, 3] + new Vector3((riverTile.south.max_pos + 1) * GameMap.tileWidth, 0, 0);

        verts[0, 1] = verts[0, 0] + new Vector3(0, 0, -riverTile.west.min_pos * GameMap.tileWidth);
        verts[0, 2] = verts[0, 0] + new Vector3(0, 0, -(riverTile.west.max_pos + 1) * GameMap.tileWidth);

        verts[3, 1] = verts[3, 0] + new Vector3(0, 0, -riverTile.east.min_pos * GameMap.tileWidth);
        verts[3, 2] = verts[3, 0] + new Vector3(0, 0, -(riverTile.east.max_pos + 1) * GameMap.tileWidth);

        switch (riverSides)
        {
            case Sides.North | Sides.South:
                AddRiverStraight(verts[0, 0], verts[1, 0], verts[2, 0], verts[3, 0], verts[3, 3], verts[2, 3], verts[1, 3], verts[0, 3], biome, waterLevel, north, east, south, west, riverTile.north.elevation, riverTile.south.elevation);
                break;
            case Sides.East | Sides.West:
                AddRiverStraight(verts[3, 0], verts[3, 1], verts[3, 2], verts[3, 3], verts[0, 3], verts[0, 2], verts[0, 1], verts[0, 0], biome, waterLevel, east, south, west, north, riverTile.east.elevation, riverTile.west.elevation);
                break;
            case Sides.North:
                AddRiverEnd(verts[0, 0], verts[1, 0], verts[2, 0], verts[3, 0], verts[3, 3], verts[0, 3], biome, waterLevel, north, east, south, west);
                break;
            case Sides.East:
                AddRiverEnd(verts[3, 0], verts[3, 1], verts[3, 2], verts[3, 3], verts[0, 3], verts[0, 0], biome, waterLevel, east, south, west, north);
                break;
            case Sides.South:
                AddRiverEnd(verts[3, 3], verts[2, 3], verts[1, 3], verts[0, 3], verts[0, 0], verts[3, 0], biome, waterLevel, south, west, north, east);
                break;
            case Sides.West:
                AddRiverEnd(verts[0, 3], verts[0, 2], verts[0, 1], verts[0, 0], verts[3, 0], verts[3, 3], biome, waterLevel, west, north, east, south);
                break;
            case Sides.North | Sides.East:
                AddRiverCorner(verts[0, 0], verts[1, 0], verts[2, 0], verts[3, 0], verts[3, 1], verts[3, 2], verts[3, 3], verts[0, 3], biome, waterLevel, north, east, south, west);
                break;
            case Sides.East | Sides.South:
                AddRiverCorner(verts[3, 0], verts[3, 1], verts[3, 2], verts[3, 3], verts[2, 3], verts[1, 3], verts[0, 3], verts[0, 0], biome, waterLevel, east, south, west, north);
                break;
            case Sides.South | Sides.West:
                AddRiverCorner(verts[3, 3], verts[2, 3], verts[1, 3], verts[0, 3], verts[0, 2], verts[0, 1], verts[0, 0], verts[3, 0], biome, waterLevel, south, west, north, east);
                break;
            case Sides.West | Sides.North:
                AddRiverCorner(verts[0, 3], verts[0, 2], verts[0, 1], verts[0, 0], verts[1, 0], verts[2, 0], verts[3, 0], verts[3, 3], biome, waterLevel, west, north, east, south);
                break;
            case Sides.North | Sides.East | Sides.South:
                AddRiverTee(verts[0, 0], verts[1, 0], verts[2, 0], verts[3, 0], verts[3, 1], verts[3, 2], verts[3, 3], verts[2, 3], verts[1, 3], verts[0, 3], biome, waterLevel, north, east, south, west, riverTile.north.elevation, riverTile.east.elevation, riverTile.south.elevation);
                break;
            case Sides.East | Sides.South | Sides.West:
                AddRiverTee(verts[3, 0], verts[3, 1], verts[3, 2], verts[3, 3], verts[2, 3], verts[1, 3], verts[0, 3], verts[0, 2], verts[0, 1], verts[0, 0], biome, waterLevel, east, south, west, north, riverTile.east.elevation, riverTile.south.elevation, riverTile.west.elevation);
                break;
            case Sides.South | Sides.West | Sides.North:
                AddRiverTee(verts[3, 3], verts[2, 3], verts[1, 3], verts[0, 3], verts[0, 2], verts[0, 1], verts[0, 0], verts[1, 0], verts[2, 0], verts[3, 0], biome, waterLevel, south, west, north, east, riverTile.south.elevation, riverTile.west.elevation, riverTile.north.elevation);
                break;
            case Sides.West | Sides.North | Sides.East:
                AddRiverTee(verts[0, 3], verts[0, 2], verts[0, 1], verts[0, 0], verts[1, 0], verts[2, 0], verts[3, 0], verts[3, 1], verts[3, 2], verts[3, 3], biome, waterLevel, west, north, east, south, riverTile.west.elevation, riverTile.north.elevation, riverTile.east.elevation);
                break;
            case Sides.North | Sides.East | Sides.South | Sides.West:
                break;
            default:
                break;
        }
    }
Esempio n. 60
0
 public void FillRoundRectangle(PDFBrush brush, PDFRect rect, Sides sides, PDFUnit cornerRadius)
 {
     this.FillRoundRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height, sides, cornerRadius);
 }