Giter VIP home page Giter VIP logo

iqoption.net's Introduction

IqOption.Net

iqoption api to connect to www.iqoption.com (unofficial), with .netcore based for another framework you can suggest,

Branch Build Nuget
master Build status NuGet Badge
developer(Pre-release) Build Status NuGet Badge

Package Installation

PM> Install-Package iqoptionapi

alpha version now available

PM> Install-Package iqoptionapi -Version 2.0.0-alpha1

How it work

This api using websocket to communicate realtime-data to Iqoption server through secured websocket channel, so the realtime meta data that come on this channel will be handles by .net reactive programming called "Rx.NET", cause of a haundred of data type stream on only one channle so we need to selected subscribe on specific topic.

Milestone

  • BuyBack Position
  • Subscribe to the channel
  • support open Long/Short for CFD contract (Digital Options)

How to use

var client = new IqOptionApi("emailaddress", "password");

//begin connect
if(await client.ConnectAsync()){

  //get user profile
  var profile = await client.GetProfileAsync();
  
  // open order EurUsd in smallest period (1min) 
  var exp = DateTime.Now.AddMinutes(1);
  var buyResult = await api.BuyAsync(ActivePair.EURUSD, 1, OrderDirection.Call, exp);
  
  // get candles data
  var candles = await api.GetCandlesAsync(ActivePair.EURUSD, TimeFrame.Min1, 100, DateTimeOffset.Now);
  _logger.LogInformation($"CandleCollections received {candles.Count}");


  // subscribe to pair to get real-time data for tf1min and tf5min
  var streamMin1 = await api.SubscribeRealtimeDataAsync(ActivePair.EURUSD, TimeFrame.Min1);
  var streamMin5 = await api.SubscribeRealtimeDataAsync(ActivePair.EURUSD, TimeFrame.Min5);

  streamMin5.Merge(streamMin1)
      .Subscribe(candleInfo => {
          _logger.LogInformation($"Now {ActivePair.EURUSD} {candleInfo.TimeFrame} : Bid={candleInfo.Bid}\t Ask={candleInfo.Ask}\t");
  });

  // after this line no-more realtime data for min5 print on console
  await api.UnSubscribeRealtimeData(ActivePair.EURUSD, TimeFrame.Min5);

}

Example Use Cases

This is example use cases that this api could solve your problems

Trading follower

public async Task TradingFollower_ExampleAsync() {

    var trader = new IqOptionApi("[email protected]", "passcode");
    var follower = new IqOptionApi("[email protected]", "passcode");

    await Task.WhenAll(trader.ConnectAsync(), follower.ConnectAsync());

    trader.InfoDatasObservable.Select(x => x[0]).Where(x => x.Win == "equal").Subscribe(x => {
        follower.BuyAsync(x.ActiveId, (int) x.Sum, x.Direction, x.Expired);
    });
    
}

Version 2.0.0

Now you can open order like this

var api = new IqOptionApi("[email protected]", "passcode");

try {
    //logging in
    if (await api.ConnectAsync()) {
        //open order EurUsd in smallest period(1min) 
        var exp = DateTime.Now.AddMinutes(1);
        await api.BuyAsync(ActivePair.EURUSD, 1, OrderDirection.Call, exp);
    }
}
catch (Exception ex) {
    Console.WriteLine(ex.Message);
}
finally {
    Console.ReadLine();
}

Trading follower

now using ReactiveUI way for subscribe the changing of model following this

using System;
using System.Reactive.Linq;
using System.Threading.Tasks;
using IqOptionApi.Models;
using ReactiveUI;

namespace IqOptionApi.Sample {
    public class TradingExample {
        public async Task RunAsync() {
            var trader = new IqOptionApi("[email protected]", "passcode");
            var follower = new IqOptionApi("[email protected]", "passcode");

            await Task.WhenAll(trader.ConnectAsync(), follower.ConnectAsync());

            trader.WsClient.WhenAnyValue(x => x.InfoData)
                .Where(x => x != null && x.Win == WinType.Equal)
                .Subscribe(x => { follower.BuyAsync(x.ActiveId, (int) x.Sum, x.Direction, x.Expired); });


            //var exp = DateTime.Now.AddMinutes(1);
            var exp = DateTime.Now.AddMinutes(1);
            await trader.BuyAsync(ActivePair.EURUSD, 1, OrderDirection.Call, exp);
        }
    }
}

Support Me

If you've got value from any of the content which I have created, but pull requests are not your thing, then I would also very much appreciate your support by buying me a coffee.

Buy Me A Coffee

iqoption.net's People

Contributors

mongkoneiadon avatar

Stargazers

Roman avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.