Exemplo n.º 1
0
        public override async Task RunSample()
        {
            string requestId;

            if (await IqClientApiDotNet.ConnectAsync())
            {
                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                var profile = await IqClientApiDotNet.GetProfileAsync(requestId);

                var demo = profile.Balances.FirstOrDefault(x => x.Type == BalanceType.Practice);

                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                await IqClientApiDotNet.ChangeBalanceAsync(requestId, demo.Id);

                var real = profile.Balances.FirstOrDefault(x => x.Type == BalanceType.Real);

                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                await IqClientApiDotNet.ChangeBalanceAsync(requestId, real.Id);

                /*
                 * Don't forget to check if it is in the live account or in training
                 * before taking your Balance Changed tests
                 */
                IqClientApiDotNet.BalanceChangedObservable.Subscribe(x => {
                    // values goes here
                    _logger.Information(
                        $"Balance Changed on UserId: {x.UserId} - Amount: {x.CurrentBalance.Amount}, Enrolled Amount: {x.CurrentBalance.EnrolledAmount}"
                        );
                });
            }
        }
Exemplo n.º 2
0
        public override async Task RunSample()
        {
            string requestId;

            if (await IqClientApiDotNet.ConnectAsync())
            {
                // subscribe to pair to get real-time data for tf1min and tf5min
                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                IqClientApiDotNet.SubscribeLiveDeal(requestId, "live-deal-digital-option", ActivePair.EURUSD, DigitalOptionsExpiryType.PT1M);

                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                IqClientApiDotNet.SubscribeLiveDeal(requestId, "live-deal-digital-option", ActivePair.EURUSD, DigitalOptionsExpiryType.PT5M);

                // call the subscribe to listening when mood changed
                IqClientApiDotNet.WsClient.LiveDealObservable().Subscribe(x => {
                    // values goes here
                    _logger.Information(
                        $"Lives User Id: {x.UserId} Created {x.CreatedAt} Amount: {x.AmountEnrolled} Direction: {x.InstrumentDir}"
                        );
                });

                // hold 2 secs
                Thread.Sleep(2000);

                // after this line no-more realtime data for min5 print on console
                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                IqClientApiDotNet.UnSubscribeLiveDeal(requestId, "live-deal-digital-option", ActivePair.EURUSD, DigitalOptionsExpiryType.PT1M);

                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                IqClientApiDotNet.UnSubscribeLiveDeal(requestId, "live-deal-digital-option", ActivePair.EURUSD, DigitalOptionsExpiryType.PT5M);
            }
        }
Exemplo n.º 3
0
        public override async Task RunSample()
        {
            if (await IqClientApiDotNet.ConnectAsync())
            {
                // call the subscribe to listening when mood changed
                IqClientApiDotNet.WsClient.TradersMoodObservable().Subscribe(x => {
                    // values goes here
                    _logger.Information(
                        $"TradersMood on {x.InstrumentType} - {x.ActivePair} values Higher :{x.Higher}, Lower: {x.Lower}"
                        );
                });

                string requestId;

                // begin subscribe 2 pairs
                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                IqClientApiDotNet.SubscribeTradersMoodChanged(requestId, InstrumentType.BinaryOption, ActivePair.EURUSD);

                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                IqClientApiDotNet.SubscribeTradersMoodChanged(requestId, InstrumentType.BinaryOption, ActivePair.GBPUSD);

                //wait for 10 secs
                await Task.Delay(10000);

                // after unsubscribe GBPUSD moods will not come anymore
                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                IqClientApiDotNet.UnSubscribeTradersMoodChanged(requestId, InstrumentType.BinaryOption, ActivePair.GBPUSD);
            }
        }
Exemplo n.º 4
0
        public override async Task RunSample()
        {
            string requestId;

            if (await IqClientApiDotNet.ConnectAsync())
            {
                // subscribe to pair to get real-time data for tf1min and tf5min
                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                var streamMin1 = await IqClientApiDotNet.SubscribeRealtimeQuoteAsync(requestId, ActivePair.EURUSD_OTC, TimeFrame.Min1);

                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                var streamMin5 = await IqClientApiDotNet.SubscribeRealtimeQuoteAsync(requestId, ActivePair.EURUSD_OTC, TimeFrame.Min5);

                streamMin5.Merge(streamMin1)
                .Subscribe(candleInfo =>
                {
                    Console.WriteLine(
                        $"Now {ActivePair.EURUSD_OTC} {candleInfo.TimeFrame} : Bid={candleInfo.Bid}\t Ask={candleInfo.Ask}\t");
                });


                // hold 2 secs
                Thread.Sleep(2000);

                // after this line no-more realtime data for min5 print on console
                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                await IqClientApiDotNet.UnSubscribeRealtimeData(requestId, ActivePair.EURUSD_OTC, TimeFrame.Min5);
            }
        }
Exemplo n.º 5
0
        public override async Task RunSample()
        {
            string requestId;

            if (await IqClientApiDotNet.ConnectAsync())
            {
                // subscribe to top assets updated
                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                IqClientApiDotNet.SubscribeTopAssetsUpdated(requestId, InstrumentType.DigitalOption);

                // call the subscribe to listening when mood changed

                /*
                 * IqClientApiDotNet.WsClient.TopAssetsUpdatedObservable().Subscribe(x => {
                 *
                 *  // values goes here
                 *  _logger.Information(
                 *      $"Lives User Id: {x.UserId} Created {x.CreatedAt} Amount: {x.AmountEnrolled} Direction: {x.InstrumentDir}"
                 *  );
                 *
                 * });
                 */
                // hold 2 secs
                Thread.Sleep(2000);

                // after this line no-more realtime top assets updated
                //requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                //IqClientApiDotNet.Uns(requestId, "live-deal-digital-option", ActivePair.EURUSD, DigitalOptionsExpiryType.PT1M);
            }
        }
Exemplo n.º 6
0
        public override async Task RunSample()
        {
            string requestId;

            if (await IqClientApiDotNet.ConnectAsync())
            {
                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                IqClientApiDotNet.ResetTrainingBalanceAsync(requestId);
            }
        }
Exemplo n.º 7
0
        // Get User Profile Client Informations Using ID User
        // By: Jorge Beserra
        public override async Task RunSample()
        {
            string requestId;

            if (await IqClientApiDotNet.ConnectAsync())
            {
                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                var topAssets = await IqClientApiDotNet.GetTopAssetsAsync(requestId, InstrumentType.DigitalOption);

                _logger.Information(JsonConvert.SerializeObject(topAssets.Data));
            }
        }
Exemplo n.º 8
0
        // Get User Profile Client Informations Using ID User
        // By: Jorge Beserra
        public override async Task RunSample()
        {
            string requestId;

            if (await IqClientApiDotNet.ConnectAsync())
            {
                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                var profile = await IqClientApiDotNet.GetUserProfileClientAsync(requestId, 0);

                _logger.Information(JsonConvert.SerializeObject(profile));
            }
        }
Exemplo n.º 9
0
        // Get Financial Information from ACTIVE PAIR
        // By: Jorge Beserra
        public override async Task RunSample()
        {
            string requestId;

            if (await IqClientApiDotNet.ConnectAsync())
            {
                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                var financialinformation = await IqClientApiDotNet.GetFinancialInformationAsync(requestId, Models.ActivePair.EURUSD);

                _logger.Information(JsonConvert.SerializeObject(financialinformation));
            }
        }
        // Get Leaderboard Top Traders
        // By: Jorge Beserra
        public override async Task RunSample()
        {
            string requestId;

            if (await IqClientApiDotNet.ConnectAsync())
            {
                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                var leader = await IqClientApiDotNet.RequestLeaderboardDealsClientAsync(requestId, 0, 191, 1, 10, 64, 64, 64, 64, 2);

                _logger.Information(JsonConvert.SerializeObject(leader));
            }
        }
Exemplo n.º 11
0
        /*
         * Purpose:
         *     To get the candles information (Not Realtime) back to the specific
         *     time frame and period
         *
         * Payload Result:
         *     "candles": [
         * { "id": 78112508, "from": 1589034889, "at": 1589034890021414406, "to": 1589034890, "open": 1.038268, "close": 1.038268, "min": 1.038268, "max": 1.038268, "volume": 0 },
         * { "id": 78112509, "from": 1589034890, "at": 1589034891025205250, "to": 1589034891, "open": 1.038269, "close": 1.038269, "min": 1.038269, "max": 1.038269, "volume": 0 },
         *              ]
         */
        public override async Task RunSample()
        {
            string requestId;

            if (await IqClientApiDotNet.ConnectAsync())
            {
                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                var candleInfo = await IqClientApiDotNet.GetCandlesAsync(requestId, ActivePair.EURUSD_OTC, TimeFrame.Min1, 100, DateTimeOffset.Now.AddMinutes(-5));

                _logger.Information(JsonConvert.SerializeObject(candleInfo));
            }
        }
Exemplo n.º 12
0
        // Get Leaderboard Trader infor
        // By: Jorge Beserra
        public override async Task RunSample()
        {
            if (await IqClientApiDotNet.ConnectAsync())
            {
                string        requestId;
                CountryType[] countryes = { CountryType.Worldwide, };
                var           userId    = 0;
                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                var leader = await IqClientApiDotNet.RequestLeaderboardUserinfoDealsClientAsync(requestId, countryes, userId);

                _logger.Information(JsonConvert.SerializeObject(leader));
            }
        }
Exemplo n.º 13
0
        public override async Task RunSample()
        {
            if (await IqClientApiDotNet.ConnectAsync())
            {
                string requestId;
                while (true)
                {
                    await Task.Delay(5000);

                    requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                    var result = await IqClientApiDotNet.BuyAsync(requestId, ActivePair.EURUSD_OTC, 1, OrderDirection.Call,
                                                                  DateTimeOffset.Now);

                    Console.WriteLine($"PositionId = {result.PositionId}");
                }
            }
        }
        public override async Task RunSample()
        {
            string requestId;

            if (await IqClientApiDotNet.ConnectAsync())
            {
                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                var profile = await IqClientApiDotNet.GetProfileAsync(requestId);

                var demo = profile.Balances.FirstOrDefault(x => x.Type == BalanceType.Practice);

                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                await IqClientApiDotNet.ChangeBalanceAsync(requestId, demo.Id);

                var real = profile.Balances.FirstOrDefault(x => x.Type == BalanceType.Real);

                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                await IqClientApiDotNet.ChangeBalanceAsync(requestId, real.Id);
            }
        }
Exemplo n.º 15
0
        // Get Leaderboard Top Traders
        // By: Jorge Beserra
        public override async Task RunSample()
        {
            string requestId;

            if (await IqClientApiDotNet.ConnectAsync())
            {
                /*
                 * During the tests I found that the IQ blocks for a time when there
                 * are many requests so if you receive timeout errors wait
                 * about 5 or 10 minutes for the next request.
                 */

                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                CountryType country       = CountryType.Worldwide;
                long        from_position = 1;
                long        to_position   = 10;
                var         leader        = await IqClientApiDotNet.RequestLeaderboardDealsClientAsync(requestId, country, from_position, to_position);

                _logger.Information(JsonConvert.SerializeObject(leader));
            }
        }
Exemplo n.º 16
0
        public override async Task RunSample()
        {
            string requestId;

            if (await IqClientApiDotNet.ConnectAsync())
            {
                // Observable to AlertChanged
                IqClientApiDotNet.AlertChangedObservable.Subscribe(x => {
                    // values goes here
                    _logger.Information(
                        $"Alert Changed reason {x.Reason} - {x.AssetId} value: {x.Value} {x.Activations}"
                        );
                });

                // Observable to AlertTriggered
                IqClientApiDotNet.AlertTriggeredObservable.Subscribe(x => {
                    // values goes here
                    _logger.Information(
                        $"Alert Triggered - User: {x.UserId} Asset: {x.AssetId} value: {x.Value} Time: {x.Timestamp}"
                        );
                });

                // Get All Alerts
                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                var alerts = await IqClientApiDotNet.GetAlerts(requestId);

                _logger.Information(JsonConvert.SerializeObject(alerts));

                // Create Alert
                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                ActivePair     activeId       = ActivePair.EURAUD;
                InstrumentType instrumentType = InstrumentType.DigitalOption;
                double         value          = 200.10;
                int            activations    = 0; // 1 - For one time OR 2 - For all time
                var            alertCreated   = await IqClientApiDotNet.CreateAlert(requestId, activeId, instrumentType, value, activations);

                _logger.Information(JsonConvert.SerializeObject(alertCreated));

                // hold 5 secs after update for new value
                Thread.Sleep(5000);

                // Update Alert
                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                long           alertId           = alertCreated.Id; // Get id alert created this sample
                ActivePair     newActiveId       = ActivePair.EURAUD;
                InstrumentType newInstrumentType = InstrumentType.DigitalOption;
                double         newValue          = 300.51;
                int            newActivations    = 0; // 1 - For one time OR 2 - For all time
                var            alertUpdated      = await IqClientApiDotNet.UpdateAlert(requestId, alertId, newActiveId, newInstrumentType, newValue, newActivations);

                _logger.Information(JsonConvert.SerializeObject(alertUpdated));

                // hold 5 secs after delete
                Thread.Sleep(5000);

                // Delete Alert
                requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
                alertId   = alertCreated.Id; // Get id alert created this sample
                var alertDelete = await IqClientApiDotNet.DeleteAlert(requestId, alertId);

                _logger.Information(JsonConvert.SerializeObject(alertDelete));
            }
        }