Exemplo n.º 1
0
 public override async Task RunSample()
 {
     if (await IqClientApi.ConnectAsync())
     {                // open order EurUsd in smallest period (1min)
         var exp       = DateTime.Now.AddMinutes(1);
         var buyResult = await IqClientApi.BuyAsync(ActivePair.EURUSD, 1, OrderDirection.Call, exp);
     }
 }
        public override async Task RunSample()
        {
            if (await IqClientApi.ConnectAsync())
            {
                var result = await IqClientApi.BuyAsync(ActivePair.EURUSD_OTC, 1, OrderDirection.Call, DateTimeOffset.MinValue);

                Console.WriteLine($"PositionId = {result.PositionId}");
            }
        }
Exemplo n.º 3
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()
        {
            if (await IqClientApi.ConnectAsync())
            {
                var candleInfo = await IqClientApi.GetCandlesAsync(ActivePair.EURUSD_OTC, TimeFrame.Min1, 100, DateTimeOffset.Now.AddMinutes(-5));

                _logger.Information(JsonConvert.SerializeObject(candleInfo));
            }
        }
Exemplo n.º 4
0
        public override async Task RunSample()
        {
            if (await IqClientApi.ConnectAsync())
            {
                var profile = await IqClientApi.GetProfileAsync();

                _logger.Information(JsonConvert.SerializeObject(profile));
            }
        }
        public override async Task RunSample()
        {
            if (await IqClientApi.ConnectAsync())
            {
                var position = await IqClientApi.WsClient.PlaceDigitalOptions(ActivePair.EURUSD_OTC, OrderDirection.Call, DigitalExpiryDuration.M1, 1);

                Console.WriteLine(position.Id);
            }
        }
        public override async Task RunSample()
        {
            if (await IqClientApi.ConnectAsync())
            {
                var profile = await IqClientApi.GetProfileAsync();

                var demo = profile.Balances.FirstOrDefault(x => x.Type == BalanceType.Practice);
                await IqClientApi.ChangeBalanceAsync(demo.Id);

                var real = profile.Balances.FirstOrDefault(x => x.Type == BalanceType.Real);
                await IqClientApi.ChangeBalanceAsync(real.Id);
            }
        }
Exemplo n.º 7
0
        public override async Task RunSample()
        {
            if (await IqClientApi.ConnectAsync())
            {
                while (true)
                {
                    await Task.Delay(5000);

                    var result = await IqClientApi.BuyAsync(ActivePair.EURUSD_OTC, 1, OrderDirection.Call,
                                                            DateTimeOffset.Now);

                    Console.WriteLine($"PositionId = {result.PositionId}");
                }
            }
        }
        public override async Task RunSample()
        {
            if (await IqClientApi.ConnectAsync())
            {
                // call the subscribe to listening when mood changed
                IqClientApi.WsClient.TradersMoodObservable().Subscribe(x => {
                    // values goes here
                    _logger.Information(
                        $"TradersMood on {x.InstrumentType} - {x.ActivePair} values Higher :{x.Higher}, Lower: {x.Lower}"
                        );
                });

                // begin subscribe 2 pairs
                IqClientApi.SubscribeTradersMoodChanged(InstrumentType.BinaryOption, ActivePair.EURUSD);
                IqClientApi.SubscribeTradersMoodChanged(InstrumentType.BinaryOption, ActivePair.GBPUSD);

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

                // after unsubscribe GBPUSD moods will not come anymore
                IqClientApi.UnSubscribeTradersMoodChanged(InstrumentType.BinaryOption, ActivePair.GBPUSD);
            }
        }
        public override async Task RunSample()
        {
            if (await IqClientApi.ConnectAsync())
            {
                // subscribe to pair to get real-time data for tf1min and tf5min
                var streamMin1 = await IqClientApi.SubscribeRealtimeQuoteAsync(ActivePair.EURUSD_OTC, TimeFrame.Min1);

                var streamMin5 = await IqClientApi.SubscribeRealtimeQuoteAsync(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
                await IqClientApi.UnSubscribeRealtimeData(ActivePair.EURUSD_OTC, TimeFrame.Min5);
            }
        }
Exemplo n.º 10
0
        public override async Task RunSample()
        {
            if (await IqClientApi.ConnectAsync())
            {
                IqClientApi.WsClient.OrderChangedObservable().Subscribe(x =>
                {
                    Console.WriteLine(string.Format("OrderChanged - {0}, InstrumentId: {1}, Side: {2}, Margin(Amount): {3}",
                                                    x.OrderChangedEventInfo.Id,
                                                    x.OrderChangedEventInfo.InstrumentId,
                                                    x.OrderChangedEventInfo.Side,
                                                    x.OrderChangedEventInfo.Margin));
                });

                while (true)
                {
                    await Task.Delay(10000);

                    var position = await IqClientApi.WsClient.PlaceDigitalOptions(ActivePair.EURUSD,
                                                                                  OrderDirection.Call, DigitalOptionsExpiryDuration.M1, 1);

                    Console.WriteLine($"Placed position Id: {position.Id}");
                }
            }
        }