Epics + source

LabZone, l'atelier de développement du forum Andlil : API, logiciels et utilitaires de trading créés par les membres, versions, bugs et idées.
Avatar du membre
brucy
Maître Jedi
Messages : 4691
Enregistré le : 06 mai 2014 11:40

Epics + source

Message non lu par brucy »

Hello a tous , j'ai decide de trouver un moyen de recuperer TOUT les epics trades sur ig , a la fois a titre d'informations et pour recherche personelle.

La quantitee est remarquable (au dela de 400000 ) ,
A vrai dire je ne peux meme pas copier le resultat sur le forum sans faire planter firefox ,
et ne passe pas par l'api officielle , egalement pour cause de crash/blacklist server , partant de la methode browse et marketDetails apres une trentaine de tentatives... :musique:


Pour ceux que ca interesse a des fins de developpement ou autres, envoyez moi un mp pour le fichier txt , ou autrement si benoist me donner un acces ftp.

Il est formate de la sorte ,
name":"Germany3010700PUT" epic":"OP.D.DAXWEEK.10700P.IP"
name":"Germany3010750CALL" epic":"OP.D.DAXWEEK.10750C.IP"
name":"Germany3010750PUT" epic":"OP.D.DAXWEEK.10750P.IP"
name":"Bitcoin($)tobeabove110" epic":"PB.D.BINMBIT.MBIT20.IP"
name":"Bitcoin($)tobeabove130" epic":"PB.D.BINMBIT.MBIT19.IP"
name":"Bitcoin($)tobeabove150" epic":"PB.D.BINMBIT.MBIT18.IP"
name":"Bitcoin($)tobeabove160" epic":"PB.D.BINMBIT.MBIT17.IP"
name":"Bitcoin($)tobeabove170" epic":"PB.D.BINMBIT.MBIT16.IP"
name":"Bitcoin($)tobeabove180" epic":"PB.D.BINMBIT.MBIT15.IP"
name":"Bitcoin($)tobeabove190" epic":"PB.D.BINMBIT.MBIT14.IP"
name":"Bitcoin($)tobeabove200" epic":"PB.D.BINMBIT.MBIT13.IP"
name":"Bitcoin($)tobeabove210" epic":"PB.D.BINMBIT.MBIT12.IP"
name":"Bitcoin($)tobeabove220" epic":"PB.D.BINMBIT.MBIT11.IP"
name":"Aluminium" epic":"CS.D.ALUMINIUM.CFD.IP"
name":"Copper" epic":"CS.D.COPPER.CFD.IP"
name":"HighGradeCopper" epic":"coucou.D.HG.UNC.IP"
name":"Lead" epic":"CS.D.LEAD.CFD.IP"
name":"Nickel" epic":"CS.D.NICKEL.CFD.IP"
name":"Zinc" epic":"CS.D.ZINC.CFD.IP"
name":"HighGradeCopper" epic":"MT.D.HG.FWS1.IP"
..............etc etc
Spoiler:
namespace CEpics
{
internal class Program
{
private static void Main(string[] args)
{
XSECURITYTOKEN = ""; //Your X-security-token , found in IG's API companion headers
CST = ""; //Your CST token , found in IG's API companion headers
Output = -"D:\\log.txt"; // Here is the output file path
Task web = new Task(GetThemTask);
web.Start();
Console.WriteLine("Gettings Instruments...");
Console.ReadLine();
}


public static string ID { get; set; }


public static string XSECURITYTOKEN { get; set; }

public static string CST { get; set; }

public static string Output { get; set; }

public static Uri URI { get; set; }

public static List<int> Subcount(string str, string value)
{
if (String.IsNullOrEmpty(value))
throw new ArgumentException("the string to find may not be empty", "value");
List<int> indexes = new List<int>();
for (int index = 0;; index += value.Length)
{
index = str.IndexOf(value, index);
if (index == -1)
return indexes;
indexes.Add(index);
}
}

private static async void GetThemTask()
{
//creates and sets a security cookie for httpclient
HttpClientHandler handler = new HttpClientHandler();
handler.CookieContainer = new CookieContainer();

HttpClient client = new HttpClient(handler);
Uri uri_epics =
new Uri(URI);

handler.CookieContainer.Add(uri_epics,
new Cookie("X-SECURITY-TOKEN", XSECURITYTOKEN));
// Adding a Cookie
handler.CookieContainer.Add(uri_epics,
new Cookie("CST", CST));
//Total range of instrument's index is arbitrarily located between 50k and 500k...using a brute force approach.
for (int i = 95000; i < 500000; i++)
{
ID = i.ToString();

string epic_url =
String.Format(
"/hiearchyid.htm?hierarchyId={0}&epic=&sort=&dir=asc&view=jsonView",
i.ToString()); //+IG DOMAIN here


Uri uri_epic = new Uri(epic_url);
HttpResponseMessage response_epics = await client.GetAsync(uri_epic);
HttpContent content_epics = response_epics.Content;


string result_epics = await content_epics.ReadAsStringAsync();
string format_epic = Regex.Replace(result_epics, -"\s+", "");


//if empty , total ascii response is always greater than 143
if (format_epic.Length > 143)
{
{
int indexepic = 0;
string epic = string.Empty;
string Formated = string.Empty;

List<int> indexes = Subcount(format_epic, -"epic""");
List<int> names = Subcount(format_epic, -"name");


if (indexes.Count == names.Count)
{
for (int j = 0; j < indexes.Count; j++)
{
string indexlist = (format_epic.Substring(indexes[j]).Split(',')[0]);
string namelist = (format_epic.Substring(names[j]).Split(',')[0]);
Console.WriteLine(namelist + " " + indexlist);

using (StreamWriter Writer = new StreamWriter(Output, true))
{
await Writer.WriteLineAsync(namelist + " " + indexlist);
}
}
}
}
}
}
}
}
}
Avatar du membre
Benoist Rousseau
Trader Futures / CME Member
Messages : 174763
Enregistré le : 06 sept. 2011 22:45

Re: Epics + source

Message non lu par [phpBB Debug] PHP Warning: in file [ROOT]/vendor/twig/twig/src/Extension/CoreExtension.php on line 570: strtr(): Ignoring replacement of empty string
Benoist Rousseau
»

Je te crée un accès FTP aussi rapidement que possible
Avatar du membre
Epitaf
Compagnon Jedi
Messages : 1241
Enregistré le : 25 mai 2015 17:30

Re: Epics + source

Message non lu par Epitaf »

C'est sympa, mais comment un nombre aussi important s'explique t'il ?
Avatar du membre
DarthTrader
Membre du Conseil Jedi
Messages : 11260
Enregistré le : 09 oct. 2013 17:09

Re: Epics + source

Message non lu par DarthTrader »

il y a un paquet d option et de binaire
Avatar du membre
swapping
Maître Jedi
Messages : 4618
Enregistré le : 14 août 2014 06:49

Re: Epics + source

Message non lu par swapping »

Oui, si on enlève les Options, les Binaires et les Sprint Markets çà vas le faire...
Avatar du membre
brucy
Maître Jedi
Messages : 4691
Enregistré le : 06 mai 2014 11:40

Re: Epics + source

Message non lu par brucy »

fyi - desole je n'y pensais plus
https://www.andlil.com/api/Epics/
Avatar du membre
falex
Le Gladiateur
Messages : 34269
Enregistré le : 12 févr. 2013 15:41

Re: Epics + source

Message non lu par falex »

brucy, tu as les epics uniquement depuis un compte FR où tu as aussi les epics des autres pays ?