Ejemplo n.º 1
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            TKChart chart = new TKChart(this.ExampleBounds);

            chart.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
            this.View.AddSubview(chart);

            Random r = new Random();
            List <DataPointImpl> data = new List <DataPointImpl> ();

            for (int i = 0; i <= 5; i++)
            {
                DataPointImpl impl = new DataPointImpl()
                {
                    ObjectID = i,
                    Value    = r.Next(100)
                };
                data.Add(impl);
            }

            TKChartColumnSeries columnSeries = new TKChartColumnSeries(data.ToArray());

            columnSeries.SelectionMode = TKChartSeriesSelectionMode.Series;
            chart.AddSeries(columnSeries);
        }
Ejemplo n.º 2
0
		public override void ViewDidLoad ()
		{
			base.ViewDidLoad ();

			TKChart chart = new TKChart (this.View.Bounds);
			chart.AutoresizingMask = UIViewAutoresizing.FlexibleWidth | UIViewAutoresizing.FlexibleHeight;
			this.View.AddSubview (chart);

			Random r = new Random ();
			List<DataPointImpl> data = new List<DataPointImpl> ();
			for (int i = 0; i <= 5; i++) {
				DataPointImpl impl = new DataPointImpl () {
					ObjectID = i,
					Value = r.Next(100)
				};
				data.Add (impl);
			}

			TKChartColumnSeries columnSeries = new TKChartColumnSeries (data.ToArray ());
			columnSeries.SelectionMode = TKChartSeriesSelectionMode.Series;
			chart.AddSeries (columnSeries);
		}
Ejemplo n.º 3
0
        /// <summary>
        /// Initialize new internal live data feed
        /// </summary>
        public void Initialize(MessageInstance initialmessage)
        {
            //Set data
            _endpoint      = Config.TryGetEnvVariable("hist.endpoint", Config.GlobalConfig.HistEndpoint);
            _startDateTime = DateTime.Parse(Config.TryGetEnvVariable("hist.start", Config.GlobalConfig.HistStart));
            _endDateTime   = DateTime.Parse(Config.TryGetEnvVariable("hist.end", Config.GlobalConfig.HistEnd));

            //Set conversion method
            Conversion = (data) => new[] { DataPointImpl.Deserialize(data as byte[], true) };

            //Set socket
            _histRequestSocket = new RequestSocket(_endpoint);
            _histRequestSocket.ReceiveReady += OnReceive;
            _histRequestSocket.Options.ReceiveHighWatermark = 1000;

            //Set poller
            _timeoutTimer          = new NetMQTimer(_timeoutTimerSpan);
            _timeoutTimer.Elapsed += OnTimeoutTimer;
            _timeoutTimer.Enable   = false;
            _poller = new NetMQPoller();
            _poller.Add(_histRequestSocket);

            //Set allowed tickers
            _allowedTickers = Config.SecurityConfig.Select(x => x.Ticker).ToArray();

            //Set source
            string brokertype = (initialmessage is LiveTradingMessage liveTradingMessage)
                ? liveTradingMessage.BrokerType
                : (initialmessage is SimulationMessage backtestmessage)
                    ? backtestmessage.BrokerType
                    : "";

            switch ((BrokerType)Enum.Parse(typeof(BrokerType), brokertype))
            {
            case BrokerType.Robinhood:
                _source = "IEX";
                break;

            case BrokerType.Bittrex:
                _source = "Bittrex";
                break;

            case BrokerType.HitBtc:
                _source = "HitBtc";
                break;

            case BrokerType.Cobinhood:
                _source = "CobinHood";
                break;

            case BrokerType.FreeTrade:
                _source = "IEX";
                break;

            case BrokerType.Unknown:
                throw new Exception($"Data source is unknown, cannot retrieve data from an unknown data source");

            default:
                throw new ArgumentOutOfRangeException($"{brokertype} is unknown, cannot derive data source from an unknown broker type");
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// returns true if more data to process, false otherwise
        /// </summary>
        /// <returns></returns>
        public bool NextDataPoint()
        {
            //Check if we have header of file
            if (!_haveheader)
            {
                ReadHeader();
            }

            try
            {
                // get line type
                byte linetype = ReadByte();

                // prepare a datapoiny
                DataPoint d;

                // get the tick
                switch (linetype)
                {
                case DataConst.EndData: return(false);

                case DataConst.StartData: return(true);

                case DataConst.FileVersion: return(true);

                case DataConst.DatapointStart:
                {
                    //Get data point data
                    List <byte> data  = new List <byte>();
                    bool        ended = false;
                    while (!ended)
                    {
                        var lastbyte = ReadByte();
                        if (lastbyte == DataConst.DatapointEnd)
                        {
                            ended = true;
                        }
                        else
                        {
                            data.Add(lastbyte);
                        }
                    }

                    //Convert data
                    d = DataPointImpl.Deserialize(data.ToArray(), true);
                }
                    ;
                    break;

                default:
                {
                    // weird data, try to keep reading
                    ReadByte();

                    // but don't send this data, just get next record
                    return(true);
                }
                }

                // send any data we have
                if (d != null)
                {
                    GotData?.Invoke(this, d);
                }

                // count it
                Count++;

                // assume there is more
                return(true);
            }
            catch (EndOfStreamException)
            {
                return(false);
            }
            catch (ObjectDisposedException)
            {
                return(false);
            }
            catch (Exception exc)
            {
                _log.Error(exc, $"Unexpected error while reading file in datareader: {exc.Message}");
                return(false);
            }
        }
Ejemplo n.º 5
0
        /// <summary>
        /// Initializes this instance.
        /// </summary>
        public void Initialize(MessageInstance initialmessage)
        {
            //Set data
            _endpoint = Config.TryGetEnvVariable("datafeedendpoint", Config.GlobalConfig.DataFeedEndpoint);

            //Set conversion method
            Conversion = data => new[] { DataPointImpl.Deserialize(data as byte[], true) };;

            //Set socket
            _subscriberSocket = new SubscriberSocket(_endpoint);
            _subscriberSocket.ReceiveReady += OnReceive;
            _subscriberSocket.Options.ReceiveHighWatermark = 1000;
            _subscriberSocket.Subscribe(Topic.HeartBeatMessage);
            _subscriberSocket.Subscribe(Topic.WelcomeMessage);

            //Set poller
            _timeoutTimer          = new NetMQTimer(_timeoutTimerSpan);
            _timeoutTimer.Elapsed += OnTimeoutTimer;
            _timeoutTimer.Enable   = false;
            _poller = new NetMQPoller();
            _poller.Add(_subscriberSocket);

            //Set allowed tickers
            _allowedTickers = Config.SecurityConfig.Select(x => x.Ticker).ToArray();

            //Set allowed currency conversion tickers
            //TODO: set allowed currency conversion tickers (all combinations possible)

            //Set source
            string brokertype = (initialmessage is LiveTradingMessage liveTradingMessage)
                ? liveTradingMessage.BrokerType
                : (initialmessage is SimulationMessage backtestmessage)
                    ? backtestmessage.BrokerType
                    : "";

            switch ((BrokerType)Enum.Parse(typeof(BrokerType), brokertype))
            {
            case BrokerType.Robinhood:
                _source = "IEX";
                break;

            case BrokerType.Bittrex:
                _source = "Bittrex";
                break;

            case BrokerType.HitBtc:
                _source = "HitBtc";
                break;

            case BrokerType.Cobinhood:
                _source = "CobinHood";
                break;

            case BrokerType.FreeTrade:
                _source = "IEX";
                break;

            case BrokerType.Unknown:
                throw new Exception($"Data source is unknown, cannot retrieve data from an unknown data source");

            default:
                throw new ArgumentOutOfRangeException($"{brokertype} is unknown, cannot derive data source from an unknown broker type");
            }
        }