Exemple #1
0
        //
        // Streaming Data  ON/OFF...
        //
        private void cbPositions_CheckedChanged(object sender, EventArgs e)
        {
            if (cbPositions.CheckState == CheckState.Checked)
            {
                // Subscribe to positions...
                if ((_positions != null) && (_positions.Count > 0))
                {
                    // Now subscribe to live prices for these positions...
                    _positionSubscription = new PositionSubscription(this);

                    string[] uc =
                        (from position in _positions where position.market.streamingPricesAvailable == true select position.market.epic)
                        .Distinct().ToArray();

                    if (uc.Length > 0)
                    {
                        _positionSubscriptionStk = _igStreamApiClient.subscribeToMarketDetails(uc, _positionSubscription);
                    }
                    else
                    {
                        AppendActivityMessage("Streaming prices not enabled for these positions");
                    }
                }
                else
                {
                    AppendActivityMessage("There are no Positions to subscribe too. Either server is not responding or there are no positions.");
                }
            }
            else
            {
                // Unsubscribe from positions...
                if ((_positionSubscriptionStk != null) && (_igStreamApiClient != null))
                {
                    _igStreamApiClient.UnsubscribeTableKey(_positionSubscriptionStk);
                }
            }
        }
        //
        // Streaming Data  ON/OFF...
        //
        private void cbPositions_CheckedChanged(object sender, EventArgs e)
        {
            if (cbPositions.CheckState == CheckState.Checked)
            {
                // Subscribe to positions...
                if ((_positions != null) && (_positions.Count > 0))
                {
                    // Now subscribe to live prices for these positions...
                    _positionSubscription = new PositionSubscription(this);

	                string[] uc =
		                (from position in _positions where position.market.streamingPricesAvailable == true select position.market.epic)
			                .Distinct().ToArray();

	                if (uc.Length > 0)
	                {
		                _positionSubscriptionStk = _igStreamApiClient.subscribeToMarketDetails( uc, _positionSubscription);
	                }
	                else
	                {
						AppendActivityMessage("Streaming prices not enabled for these positions"); 
	                }
                }
                else
                {
                    AppendActivityMessage("There are no Positions to subscribe too. Either server is not responding or there are no positions.");
                }
            }
            else
            {
                // Unsubscribe from positions...
                if ((_positionSubscriptionStk != null) && (_igStreamApiClient != null))
                {
                    _igStreamApiClient.UnsubscribeTableKey(_positionSubscriptionStk);
                }
            }
        }