Example #1
0
 protected BarFactoryItem(Instrument instrument, BarType barType, long barSize, BarInput barInput, TimeSpan session1, TimeSpan session2, int providerId = -1)
     : this(instrument, barType, barSize, barInput, providerId)
 {
     this.sessionEnabled = true;
     this.session1 = session1;
     this.session2 = session2;
 }
Example #2
0
        public void Add(Instrument instrument, BarType barType, long barSize, BarInput barInput, ClockType type,
                        TimeSpan session1, TimeSpan session2, int providerId = -1)
        {
            BarFactoryItem item;

            switch (barType)
            {
            case BarType.Time:
                item = new TimeBarFactoryItem(instrument, barSize, barInput, type, session1, session2, providerId);
                break;

            case BarType.Tick:
                item = new TickBarFactoryItem(instrument, barSize, barInput, session1, session2, providerId);
                break;

            case BarType.Volume:
                item = new VolumeBarFactoryItem(instrument, barSize, barInput, session1, session2, providerId);
                break;

            case BarType.Range:
                item = new RangeBarFactoryItem(instrument, barSize, barInput, session1, session2, providerId);
                break;

            case BarType.Session:
                item = new SessionBarFactoryItem(instrument, barInput, type, session1, session2, providerId);
                break;

            default:
                throw new ArgumentException($"Unknown bar type - {barType}");
            }
            Add(item);
        }
Example #3
0
        public void Remove(Instrument instrument, BarType barType, long barSize, BarInput barInput = BarInput.Trade,
                           ClockType type = ClockType.Local)
        {
            BarFactoryItem item;

            switch (barType)
            {
            case BarType.Time:
                item = new TimeBarFactoryItem(instrument, barSize, barInput, type, -1);
                break;

            case BarType.Tick:
                item = new TickBarFactoryItem(instrument, barSize, barInput, -1);
                break;

            case BarType.Volume:
                item = new VolumeBarFactoryItem(instrument, barSize, barInput, -1);
                break;

            case BarType.Range:
                item = new RangeBarFactoryItem(instrument, barSize, barInput, -1);
                break;

            case BarType.Session:
                throw new ArgumentException(
                          "BarFactory::Remove Can not create SessionBarFactoryItem without session parameters");

            default:
                throw new ArgumentException($"Unknown bar type - {barType}");
            }
            Remove(item);
        }
        private static void AddBar(FlatMeshBuilder meshBuilder, BarInput input)
        {
            var barRotationY = Quaternion.AngleAxis(input.angleY, Vector3.up);

            var v0 = -input.spike + input.offset;
            var v5 = input.height + input.spike + input.offset;

            var vertices = Squares.Vertices();

            for (int i1 = 0, i0 = vertices.Length - 1; i1 < vertices.Length; i0 = i1++)
            {
                var vertex0 = vertices[i0].X_Y();
                var vertex1 = vertices[i1].X_Y();

                var v1 = barRotationY * vertex0 * input.radius + input.offset;
                var v2 = barRotationY * vertex1 * input.radius + input.offset;
                var v3 = v1 + input.height;
                var v4 = v2 + input.height;

                meshBuilder.AddTriangle(v0, v2, v1);
                meshBuilder.AddTriangle(v1, v2, v4);
                meshBuilder.AddTriangle(v1, v4, v3);
                meshBuilder.AddTriangle(v3, v4, v5);
            }
        }
Example #5
0
 public void Add(InstrumentList instruments, BarType barType, long barSize, BarInput barInput = BarInput.Trade,
                 ClockType type = ClockType.Local, int providerId = -1)
 {
     foreach (var i in instruments)
     {
         Add(i, barType, barSize, barInput, type, providerId);
     }
 }
Example #6
0
 public void Add(string[] symbols, BarType barType, long barSize, BarInput barInput = BarInput.Trade,
                 ClockType type = ClockType.Local, int providerId = -1)
 {
     foreach (var symbol in symbols)
     {
         Add(this.framework.InstrumentManager.Get(symbol), barType, barSize, barInput, type, providerId);
     }
 }
Example #7
0
 protected BarFactoryItem(Instrument instrument, BarType barType, long barSize, BarInput barInput = BarInput.Trade, int providerId = -1)
 {
     this.instrument = instrument;
     this.barType    = barType;
     this.barSize    = barSize;
     this.barInput   = barInput;
     this.providerId = providerId;
 }
Example #8
0
 protected BarFactoryItem(Instrument instrument, BarType barType, long barSize, BarInput barInput = BarInput.Trade, int providerId = -1)
 {
     this.instrument = instrument;
     this.barType = barType;
     this.barSize = barSize;
     this.barInput = barInput;
     this.providerId = providerId;
 }
        public static FlatMeshBuilder Create(ref Input input)
        {
            var meshBuilder = new FlatMeshBuilder();

            var frameOffset       = new Vector3(input.width * 0.5f, 0.0f, 0.0f);
            var frameHeight       = new Vector3(0.0f, input.height, 0.0f);
            var frameSpike        = new Vector3(0.0f, input.barSpike, 0.0f);
            var frameLeftBarInput = new BarInput
            {
                angleY = input.frameAngleY,
                radius = input.barRadius,
                offset = -frameOffset,
                height = frameHeight,
                spike  = frameSpike
            };
            var frameRightBarInput = new BarInput
            {
                angleY = -input.frameAngleY,
                radius = input.barRadius,
                offset = frameOffset,
                height = frameHeight,
                spike  = frameSpike
            };

            AddBar(meshBuilder, frameLeftBarInput);
            AddBar(meshBuilder, frameRightBarInput);

            var topBoardsExtents = new Vector3(input.width, 0.0f, input.boardThickness * 0.5f);
            var topBoardsInput   = new BoardsInput
            {
                extents = topBoardsExtents,
                top     = frameHeight,
                height  = frameHeight,
                count   = input.boardsCount
            };

            AddBoards(meshBuilder, topBoardsInput);

            return(meshBuilder);
        }
Example #10
0
 public SessionBarFactoryItem(Instrument instrument, BarInput barInput, ClockType type, TimeSpan session1, TimeSpan session2, int providerId = -1)
     : base(instrument, BarType.Session, (long)(session2 - session1).TotalSeconds, barInput, session1, session2, providerId)
 {
     this.type = type;
 }
Example #11
0
 public void Add(string symbol, BarType barType, long barSize, BarInput barInput = BarInput.Trade,
                 ClockType type = ClockType.Local, int providerId = -1)
 {
     Add(this.framework.InstrumentManager[symbol], barType, barSize, barInput, type, providerId);
 }
Example #12
0
 public void Add(InstrumentList instruments, BarType barType, long barSize, BarInput barInput = BarInput.Trade,
     ClockType type = ClockType.Local, int providerId = -1)
 {
     foreach (var i in instruments)
         Add(i, barType, barSize, barInput, type, providerId);
 }
Example #13
0
 public VolumeBarFactoryItem(Instrument instrument, long barSize, BarInput barInput, TimeSpan session1, TimeSpan session2, int providerId = -1)
     : base(instrument, BarType.Tick, barSize, barInput, session1, session2, providerId)
 {
 }
Example #14
0
 public void Add(string symbol, BarType barType, long barSize, BarInput barInput, ClockType type,
                 TimeSpan session1, TimeSpan session2, int providerId = -1)
 {
     Add(this.framework.InstrumentManager[symbol], barType, barSize, barInput, type, session1, session2,
         providerId);
 }
        public static FlatMeshBuilder Create(Input input)
        {
            var meshBuilder = new FlatMeshBuilder();

            const float WINDOW_BAR_ANGLE_Y = 45.0f;

            var frameOffset       = new Vector3(input.width * 0.5f, 0.0f, 0.0f);
            var frameHeight       = new Vector3(0.0f, input.height, 0.0f);
            var frameSpike        = new Vector3(0.0f, input.frameBarSpike, 0.0f);
            var frameLeftBarInput = new BarInput
            {
                angleY = -input.frameBarAngleY,
                radius = input.frameBarRadius,
                offset = -frameOffset,
                height = frameHeight,
                spike  = frameSpike
            };
            var frameRightBarInput = new BarInput
            {
                angleY = input.frameBarAngleY,
                radius = input.frameBarRadius,
                offset = frameOffset,
                height = frameHeight,
                spike  = frameSpike
            };

            AddBar(meshBuilder, frameLeftBarInput);
            AddBar(meshBuilder, frameRightBarInput);

            var windowHeight       = frameHeight * input.windowHeightFill;
            var windowOffset       = frameOffset * input.windowWidthFill;
            var windowHeightOffset = frameHeight * input.windowHeightOffsetFill;
            var windowLeftBarInput = new BarInput
            {
                angleY = -WINDOW_BAR_ANGLE_Y,
                radius = input.windowBarRadius,
                offset = -windowOffset + windowHeightOffset,
                height = windowHeight,
                spike  = frameSpike
            };
            var windowRightBarInput = new BarInput
            {
                angleY = WINDOW_BAR_ANGLE_Y,
                radius = input.windowBarRadius,
                offset = windowOffset + windowHeightOffset,
                height = windowHeight,
                spike  = frameSpike
            };

            AddBar(meshBuilder, windowLeftBarInput);
            AddBar(meshBuilder, windowRightBarInput);

            var wideBoardsExtents = new Vector3(input.width, 0.0f, input.boardThickness * 0.5f);
            var topBoardsHeight   = frameHeight - windowHeight - windowHeightOffset;
            var topBoardsInput    = new BoardsInput
            {
                extents = wideBoardsExtents,
                top     = frameHeight,
                height  = topBoardsHeight,
                count   = input.topBoardsCount
            };
            var bottomBoardsInput = new BoardsInput
            {
                extents = wideBoardsExtents,
                top     = windowHeightOffset,
                height  = windowHeightOffset,
                count   = input.bottomBoardsCount
            };

            AddBoards(meshBuilder, topBoardsInput);
            AddBoards(meshBuilder, bottomBoardsInput);

            var sideBoardsOffset    = windowOffset + (frameOffset - windowOffset) * 0.5f;
            var sideBoardsExtents   = (wideBoardsExtents - windowOffset * 2.0f) * 0.5f;
            var leftSideBoardsInput = new BoardsInput
            {
                offset  = -sideBoardsOffset + windowHeightOffset,
                extents = sideBoardsExtents,
                top     = windowHeight,
                height  = windowHeight,
                count   = input.sideBoardsCount
            };
            var rightSideBoardsInput = new BoardsInput
            {
                offset  = sideBoardsOffset + windowHeightOffset,
                extents = sideBoardsExtents,
                top     = windowHeight,
                height  = windowHeight,
                count   = input.sideBoardsCount
            };

            AddBoards(meshBuilder, leftSideBoardsInput);
            AddBoards(meshBuilder, rightSideBoardsInput);

            return(meshBuilder);
        }
Example #16
0
 public SessionBarFactoryItem(Instrument instrument, BarInput barInput, ClockType type, TimeSpan session1, TimeSpan session2, int providerId = -1)
     : base(instrument, BarType.Session, (long)(session2 - session1).TotalSeconds, barInput, session1, session2, providerId)
 {
     this.type = type;
 }
Example #17
0
 public void Add(string symbol, BarInput barInput, ClockType type, TimeSpan session1, TimeSpan session2,
                 int providerId = -1)
 {
     Add(this.framework.InstrumentManager[symbol], BarType.Session, (session2 - session1).Seconds, barInput, type,
         session1, session2, providerId);
 }
Example #18
0
 public void Add(string symbol, BarType barType, long barSize, BarInput barInput, ClockType type,
     TimeSpan session1, TimeSpan session2, int providerId = -1)
 {
     Add(this.framework.InstrumentManager[symbol], barType, barSize, barInput, type, session1, session2,
         providerId);
 }
Example #19
0
 public void Remove(Instrument instrument, BarType barType, long barSize, BarInput barInput = BarInput.Trade,
     ClockType type = ClockType.Local)
 {
     BarFactoryItem item;
     switch (barType)
     {
         case BarType.Time:
             item = new TimeBarFactoryItem(instrument, barSize, barInput, type, -1);
             break;
         case BarType.Tick:
             item = new TickBarFactoryItem(instrument, barSize, barInput, -1);
             break;
         case BarType.Volume:
             item = new VolumeBarFactoryItem(instrument, barSize, barInput, -1);
             break;
         case BarType.Range:
             item = new RangeBarFactoryItem(instrument, barSize, barInput, -1);
             break;
         case BarType.Session:
             throw new ArgumentException(
                 "BarFactory::Remove Can not create SessionBarFactoryItem without session parameters");
         default:
             throw new ArgumentException($"Unknown bar type - {barType}");
     }
     Remove(item);
 }
Example #20
0
 public void Add(Instrument instrument, BarType barType, long barSize, BarInput barInput, ClockType type,
     TimeSpan session1, TimeSpan session2, int providerId = -1)
 {
     BarFactoryItem item;
     switch (barType)
     {
         case BarType.Time:
             item = new TimeBarFactoryItem(instrument, barSize, barInput, type, session1, session2, providerId);
             break;
         case BarType.Tick:
             item = new TickBarFactoryItem(instrument, barSize, barInput, session1, session2, providerId);
             break;
         case BarType.Volume:
             item = new VolumeBarFactoryItem(instrument, barSize, barInput, session1, session2, providerId);
             break;
         case BarType.Range:
             item = new RangeBarFactoryItem(instrument, barSize, barInput, session1, session2, providerId);
             break;
         case BarType.Session:
             item = new SessionBarFactoryItem(instrument, barInput, type, session1, session2, providerId);
             break;
         default:
             throw new ArgumentException($"Unknown bar type - {barType}");
     }
     Add(item);
 }
Example #21
0
 public void Add(string symbol, BarInput barInput, ClockType type, TimeSpan session1, TimeSpan session2,
     int providerId = -1)
 {
     Add(this.framework.InstrumentManager[symbol], BarType.Session, (session2 - session1).Seconds, barInput, type,
         session1, session2, providerId);
 }
Example #22
0
 public void Add(string[] symbols, BarType barType, long barSize, BarInput barInput = BarInput.Trade,
     ClockType type = ClockType.Local, int providerId = -1)
 {
     foreach (var symbol in symbols)
         Add(this.framework.InstrumentManager.Get(symbol), barType, barSize, barInput, type, providerId);
 }
Example #23
0
 public VolumeBarFactoryItem(Instrument instrument, long barSize, BarInput barInput = BarInput.Trade, int providerId = -1)
     : base(instrument, BarType.Volume, barSize, barInput, providerId)
 {
 }
Example #24
0
 public VolumeBarFactoryItem(Instrument instrument, long barSize, BarInput barInput, TimeSpan session1, TimeSpan session2, int providerId = -1)
     : base(instrument, BarType.Tick, barSize, barInput, session1, session2, providerId)
 {
 }
Example #25
0
 public TimeBarFactoryItem(Instrument instrument, long barSize, BarInput barInput, ClockType type, TimeSpan session1, TimeSpan session2, int providerId = -1)
     : base(instrument, BarType.Time, barSize, barInput, session1, session2, providerId)
 {
     this.type = type;
 }
Example #26
0
 public TimeBarFactoryItem(Instrument instrument, long barSize, BarInput barInput = BarInput.Trade, ClockType type = ClockType.Local, int providerId = -1)
     : base(instrument, BarType.Time, barSize, barInput, providerId)
 {
     this.type = type;
 }
Example #27
0
 public TimeBarFactoryItem(Instrument instrument, long barSize, BarInput barInput = BarInput.Trade, ClockType type = ClockType.Local, int providerId = -1)
     : base(instrument, BarType.Time, barSize, barInput, providerId)
 {
     this.type = type;
 }
Example #28
0
 public TimeBarFactoryItem(Instrument instrument, long barSize, BarInput barInput, ClockType type, TimeSpan session1, TimeSpan session2, int providerId = -1)
     : base(instrument, BarType.Time, barSize, barInput, session1, session2, providerId)
 {
     this.type = type;
 }
Example #29
0
 public string AddFoo(FooInput foo, BarInput bar, BazInput baz)
 {
     return("added foo");
 }
Example #30
0
 public VolumeBarFactoryItem(Instrument instrument, long barSize, BarInput barInput = BarInput.Trade, int providerId = -1)
     : base(instrument, BarType.Volume, barSize, barInput, providerId)
 {
 }
Example #31
0
 protected BarFactoryItem(Instrument instrument, BarType barType, long barSize, BarInput barInput, TimeSpan session1, TimeSpan session2, int providerId = -1)
     : this(instrument, barType, barSize, barInput, providerId)
 {
     this.sessionEnabled = true;
     this.session1       = session1;
     this.session2       = session2;
 }
Example #32
0
 public void Add(string symbol, BarType barType, long barSize, BarInput barInput = BarInput.Trade,
     ClockType type = ClockType.Local, int providerId = -1)
 {
     Add(this.framework.InstrumentManager[symbol], barType, barSize, barInput, type, providerId);
 }