IqOption Api Dot Net to connect to www.iqoption.com (unofficial).
Please be sure to install using the NUGET Package Manager
PM> Install-Package IqOptionApiDotNet
This api using websocket to communicate realtime-data to IqOption server through secured websocket channel, so the realtime metadata 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.
- BuyBack Position
- Subscribe to the channel
- support open Long/Short for CFD contract (Digital Options)
- Get Top Assets
- Requirement to define the request identifier to improve returns.
- Reset Balance Practice
- Get Financial Information
- Get User Profile by User Id
- Get Users Availabilty by USer Id
- Get Leaderboard (TOP TRADERS)
- Get Leaderboard Details bu User Id
- Reset Balance Practice
- Alerts (List, Create, Delete, Update, ObservableChanged and ObservableTriggered)
var client = new IqOptionApiDotNetClient("emailIqOption", "passwordIqOption");
string requestId; // this is new
//begin connect
if(await client.ConnectAsync()){
//get user profile
requestId = Guid.NewGuid().ToString().Replace("-", string.Empty); // New
var profile = await client.GetProfileAsync(requestId);
// Reset Training Balance
requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
client.ResetTrainingBalanceAsync(requestId);
//Get Profile from User ID.
requestId = Guid.NewGuid().ToString().Replace("-", string.Empty); // New
var userId = ""; // <-- Id User in Here!
var profile = await client.GetUserProfileClientAsync(requestId, userId);
//Get Status from users id array.
requestId = Guid.NewGuid().ToString().Replace("-", string.Empty); // New
long[] userId = { 0, 0, 0 }; // Substituir os zeros por IDS de usuarios
var profile = await client.GetUsersAvailabilityAsync(requestId, userId);
//Get Top Traders.
requestId = Guid.NewGuid().ToString().Replace("-", string.Empty); // New
CountryType country = CountryType.Worldwide;
long from_position = 1;
long to_position = 10;
var leader = await client.RequestLeaderboardDealsClientAsync(requestId, country, from_position, to_position);
//Get Top Traders Details from User Id.
requestId = Guid.NewGuid().ToString().Replace("-", string.Empty); // New
CountryType[] countryes = {CountryType.Worldwide, };
var userId = ""; // <-- User ID here!
var leader = await client.RequestLeaderboardUserinfoDealsClientAsync(requestId, countryes, userId);
// open order EurUsd in smallest period (1min)
requestId = Guid.NewGuid().ToString().Replace("-", string.Empty); // New
var exp = DateTime.Now.AddMinutes(1);
var buyResult = await api.BuyAsync(requestId, ActivePair.EURUSD, (decimal)1.5, OrderDirection.Call, exp);
// get candles data
requestId = Guid.NewGuid().ToString().Replace("-", string.Empty); // New
var candles = await api.GetCandlesAsync(requestId, 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
requestId = Guid.NewGuid().ToString().Replace("-", string.Empty); // New
var streamMin1 = await api.SubscribeRealtimeDataAsync(requestId, ActivePair.EURUSD, TimeFrame.Min1);
requestId = Guid.NewGuid().ToString().Replace("-", string.Empty); // New
var streamMin5 = await api.SubscribeRealtimeDataAsync(requestId, 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
requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
await api.UnSubscribeRealtimeData(requestId, ActivePair.EURUSD, TimeFrame.Min5);
// Get list 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 client.CreateAlert(requestId
// 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 client.UpdateAlert(requestId, alertId, newActiveId, newInstrumentType, newValue, newActivations);
_logger.Information(JsonConvert.SerializeObject(alertUpdated));
// Delete Alert
requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
alertId = alertCreated.Id; // Get id alert created this sample
var alertDelete = await client.DeleteAlert(requestId, alertId);
_logger.Information(JsonConvert.SerializeObject(alertDelete));
}
This is example use cases that this api could solve your problems
public async Task TradingFollower_ExampleAsync() {
var trader = new IqOptionApiDotNetClient("a@b.com", "changeme");
var follower = new IqOptionApiDotNetClient("b@c.com", "changeme");
await Task.WhenAll(trader.ConnectAsync(), follower.ConnectAsync());
trader.WsClient.OpenOptionObservable().Subscribe(x => {
string requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
follower.BuyAsync(requestId, x.Active, (int) x.Amount, x.Direction, x.ExpirationTime);
});
}
To open turbo-option within (1M-5M) duration
var api = new IqOptionApiDotNetClient("email@email.com", "passcode");
string requestId; // New
try {
//logging in
if (await api.ConnectAsync()) {
//open order EurUsd in smallest period(1min)
var exp = DateTime.Now.AddMinutes(1);
string requestId; // this is new
requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
await api.BuyAsync(requestId, ActivePair.EURUSD, 1, OrderDirection.Call, exp);
}
}
catch (Exception ex) {
Console.WriteLine(ex.Message);
}
finally {
Console.ReadLine();
}
To check traders mood on specific Instrument/ActivePair
var api = new IqOptionApiDotNetClient("email@email.com", "passcode");
string requestId; // this is new
try {
//logging in
if (await api.ConnectAsync()) {
// call the subscribe to listening when mood changed
api.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
requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
api.SubscribeTradersMoodChanged(requestId, InstrumentType.BinaryOption, ActivePair.EURUSD);
requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
api.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);
api.UnSubscribeTradersMoodChanged(requestId, InstrumentType.BinaryOption, ActivePair.GBPUSD);
}
}
catch (Exception ex) {
Console.WriteLine(ex.Message);
}
finally {
Console.ReadLine();
}
now using ReactiveUI way for subscribe the changing of model following this
var trader = new IqOptionApiDotNetClient("a@b.com", "changeme");
var follower = new IqOptionApiDotNetClient("b@c.com", "changeme");
await Task.WhenAll(trader.ConnectAsync(), follower.ConnectAsync());
trader.WsClient.OpenOptionObservable().Subscribe(x => {
var requestId = Guid.NewGuid().ToString().Replace("-", string.Empty);
follower.BuyAsync(requestId, x.Active, (int) x.Amount, x.Direction, x.ExpirationTime);
});
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.
Jorge Beserra (Este Repositorio)
MongkonEiadon (Developer from Repository base)