Skip to content

Instantly share code, notes, and snippets.

@mythz
Last active July 15, 2017 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mythz/acbf6173444b7dba1556ac9a842defd6 to your computer and use it in GitHub Desktop.
Save mythz/acbf6173444b7dba1556ac9a842defd6 to your computer and use it in GitHub Desktop.
Bloomberg API example
using System.Runtime.Serialization;
using System.Collections.Generic;
using ServiceStack;
using ServiceStack.Text;
// OpenFIGI API: https://www.openfigi.com/api
[DataContract]
public class Mapping
{
[DataMember(Name="idType")]
public string IdType { get; set; }
[DataMember(Name="idValue")]
public string IdValue { get; set; }
[DataMember(Name="exchCode")]
public string ExchCode { get; set; }
[DataMember(Name="currency")]
public string Currency { get; set; }
[DataMember(Name="micCode")]
public string MicCode { get; set; }
}
public class BloombertResult
{
public string Figi { get; set; }
public string SecurityType { get; set; }
public string MarketSector { get; set; }
public string Ticker { get; set; }
public string Name { get; set; }
public string UniqueId { get; set; }
public string ExchCode { get; set; }
public string ShareClassFIGI { get; set; }
public string CompositeFIGI { get; set; }
public string SecurityType2 { get; set; }
public string SecurityDescription { get; set; }
public string UniqueIdFutOpt { get; set; }
}
public class BloombergResponse
{
public List<BloombertResult> Data { get; set; }
public string Error { get; set; }
}
var url = "https://api.openfigi.com/v1/mapping";
var response = url.PostJsonToUrl(new[]{
new Mapping { IdType = "ID_ISIN", IdValue = "US4592001014" },
new Mapping { IdType = "ID_WERTPAPIER", IdValue = "851399", ExchCode = "US" },
new Mapping { IdType = "ID_BB_UNIQUE", IdValue = "EQ0010080100001000", Currency = "USD" },
new Mapping { IdType = "ID_SEDOL", IdValue = "2005973", MicCode = "EDGX", Currency = "USD" },
})
.FromJson<BloombergResponse[]>();
//response.PrintDump();
// Save a copy of this *public* Gist by clicking the "Save As" below
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="ServiceStack.Text" version="4.5.12" targetFramework="net45" />
<package id="ServiceStack.Client" version="4.5.12" targetFramework="net45" />
<package id="ServiceStack.Interfaces" version="4.5.12" targetFramework="net45" />
</packages>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment