Bloomberg API - get list of government bonds - c#

When hitting KENGB <Govt> <GO> on the Bloomberg terminal I get list of all Kenya government bonds.
How do I get this list through Bloomberg API? Or list of their tickers?
(I download PX_LAST prices and historical prices for various securities regularly, so I am pretty familiar with service "//blp/refdata" and request "ReferenceDataRequest" ... but cannot figure out how to retrieve list of securities (and its tickers) programmatically)

try to take a look at this:
http://www.openbloomberg.com/content/uploads/sites/2/2013/04/blpapi-developers-guide.pdf
at page 77 it explains which service you must call to have Government Bonds.
this is teh c++ code:
Service govtService = session.getService("//blp/instruments");
Request request = govtService.createRequest("govtListRequest");
request.asElement().setElement("partialMatch", true);
request.asElement().setElement("query", "T*");// this plus the previous line permits to retrieve all the thicker that begins with T
request.asElement().setElement("ticker", "LANG_OVERRIDE_NONE");
request.asElement().setElement("maxResults", 10);
sendRequest(request, session);

The only way I know to get a list of securities via API v3 is to use the EQS API where you set up an EQS screen and then use the API to get the matching securities. Not sure if this lets you achieve the same result you get from security search on the Terminal.

Related

Quickbooks Online integration c#

My company uses QuickBooks Online, and I would like to write some c# scripts that retrieve very basic information like a list of customers and list of invoices from the QuickBooks Online subscription.
I would also like to submit invoices and payments.
I have created a QuickBooks IPP account (at developer.intuit.com).
I am able to authenticate myself (OAuth) just fine. My questions are:
1) Do I need to authenticate myself every time I wish to connect to QBO IPP (to retrieve a list of customers, submit an invoice, etc.)? Or can my app authenticate itself once & stay 'connected' for months?
2) Is there any sample code to do basic things such as obtain a list of customers, submit an invoice, etc.? I downloaded the sample MVC app from this link
And it was quite helpful - but when I try to get some of the code to work, I just get errors - which leads me to my first question - can I authenticate myself ONCE and use those tokens (appToken, and appTokenSecret) many times in order to perform simple tasks (obtain customer list), or do I have to authenticate myself every time?
Thank you.
Re - 1) Do I need to authenticate myself every time I wish to connect to QBO IPP (to retrieve a list of customers, submit an invoice, etc.)? Or can my app authenticate itself once & stay 'connected' for months?
Please find below steps to get OAuth tokens using which you can make API call against your QBO account. If you create an app in appcenter, you'll get consumerKey and consumerSecret. https://developer.intuit.com/Application/Create/IA
Using the above two tokens, you can generate accessToken and accessSecret from the OAuthPlayground. https://appcenter.intuit.com/Playground/OAuth/IA PN - After completing C2QB(OAuth) flow, you should use 'App Menu API Test.' option which will show you accessToken and accessSecret.
These tokens are valid for 180 days (at max). When these tokens are more than 150 days old (and <180 days), you can make Reconnect API call to revalidate those again.
Ref https://developer.intuit.com/docs/0050_quickbooks_api/0020_authentication_and_authorization/oauth_management_api#Reconnect
So you can always persist these tokens and reuse it.
To let end users connect their QB data with you SaaS app, you need to implement a wizard called 'Connect to Quickbook'. Using 3-legged Oauth your app will be able to capture the acessToken and acessSecret corresponding to the end-user's qbo account.
Ref - https://developer.intuit.com/docs/0100_accounting/0060_authentication_and_authorization/connect_from_within_your_app#7._Add_the_Connect_to_QuickBooks_button
Re - 2) Is there any sample code to do basic things such as obtain a list of customers, submit an invoice, etc.?
Please refer - https://developer.intuit.com/docs/0100_accounting/0500_developer_kits/0150_ipp_.net_devkit_3.0/0002_synchronous_calls#/Data_Services_API
and how to add invoice or sales receipt quickbooks rest api v3.0
This is a sample code to get the Quickbooks data using c#.
You can use OAuth play ground(https://developer.intuit.com/app/developer/playground) to get the access token, realm Id.
Base url is https://sandbox-quickbooks.api.intuit.com/v3/company/realmId/query?minorversion={{minorversion}}.
In here I used 55 as minor version.
using Intuit.Ipp.Core;
using Intuit.Ipp.Data;
using Intuit.Ipp.QueryFilter;
using Intuit.Ipp.Security;
using System;
using System.Collections.Generic;
using System.Linq;
namespace InvoiceTable
{
class Program
{
static void Main(string[] args)
{
try
{
//List<Invoice> InvoiceList = new List<Invoice>();
OAuth2RequestValidator oauthValidator = new OAuth2RequestValidator(Access_Token);
ServiceContext serviceContext = new ServiceContext(realm Id, IntuitServicesType.QBO, oauthValidator);
serviceContext.IppConfiguration.MinorVersion.Qbo = "minorversion";
serviceContext.IppConfiguration.BaseUrl.Qbo = Base URL;
var querySvc = new QueryService<Invoice>(serviceContext);
var InvoiceList = querySvc.ExecuteIdsQuery("Select Balance From Invoice").ToList();
}
catch (Exception ex)
{
throw;
}
}
}
}
IppDotNetSdkForQuickBooksApiV3 version 10.0.0 is the package that you have to install.

Instagram feed based on tag and geolocation

Is it possible to get an instagram feed based on both a tag and location?
I want all the images tagged with #stackExchange located in Johannesburg ( and surrounding radius of 100 km )
There is no API to get feed with both tag and location, there are independent APIs for tag and location, but you cannot currently make a single call and get results filtered for both.
Tag API:
https://api.instagram.com/v1/tags/snow/media/recent?access_token=ACCESS-TOKEN
Location search API:
https://api.instagram.com/v1/media/search?lat=48.858844&lng=2.294351&access_token=ACCESS-TOKEN
You can make location API call cache and then manually look for tags, but this may be expensive on number of API calls.. here is an implementation of location search and then you can filter by keyword: http://www.gramfeed.com/instagram/map
As krisrak said - you need to choose: either get by location and then filter by tag or get by tag and then filter by location.
check instafeed.js - you can use this for example (get by location and then filter by tag):
var mylocation = 1234569; //must be a number!
var feed = new Instafeed({
get: 'location',
locationId: mylocation,
clientId: 'someId', //change this with the client id you get from Instagram
filter: function(image) {
return (image.tags.indexOf('myTag') >= 0);
}
});
feed.run();
You can find the location you want in google maps. right click the specific point on the map and choose "what's here?" - this will reveal the coordinates. now use this site to get the Instagram locationId.
Notice that image object has all the properties returned by the Instagram api, so you can get the tags, the location, comments...
fora full list of fields look at returned media api (click on response button).
but just remember: filter function must return boolean!

How to retrieve an image from an OData Service?

I have an OData service (its System Center Orchestrator's web service if you must know ) that returns a BMP image if I query
http://localhost.com/Orchestrator2012/Orchestrator.svc/RunbookDiagrams(guid'882f767d-63bd-437c-b0c7-4051aac56176')/$value
So its basically saying, give me the RunbookDiagram with the Id 882f767d-63bd-437c-b0c7-4051aac56176
It renders it correctly in IE. But when I query it fom C# I'm not able to get the image data, but I do get all other data fields.
Now the documentation of the webservice says I need to use $value to return the query. But how do I use $value in the following OData query from C#
RunbookDiagram rbkdiag=orch.RunbookDiagrams.Where(
m => m.RunbookId ==runbookId
).SingleOrDefault();
Maybe the service is returning the images as media link entries?
You can check for this by viewing the xml returned from the server and look for m:HasStream="true"
If this is the case use GetReadStream on the context.
Check this astoriateam blog post for details.

Bloomberg API - using .Net API to get the FUT_CHAIN on an underlying security

I am trying to query the Bloomberg API (.Net) to get the future chain on an underlying security. Preferably, I would be able to get the list of futures for a given date in the past.
The equivalent operation in Excel using the worksheet formula API would be the following:-
=BDS("ERA COMDTY","FUT_CHAIN","CHAIN_DATE=20120103",
"INCLUDE_EXPIRED_CONTRACTS=Yes")
I looked at a large number of online resources, and I don't seem to be getting anywhere.
For the v3 API, you need to use request overrides.
Request request = refDataService.createRequest("ReferenceDataRequest");
request.append("securities", "ERA Comdty");
request.append("fields","FUT_CHAIN");
Element overrides = request.getElement("overrides");
Element override1 = overrides.appendElement();
override1.setElement("fieldId", "CHAIN_DATE");
override1.setElement("value", "20120103");
Element override2 = overrides.appendElement();
override2.setElement("fieldId", "INCLUDE_EXPIRED_CONTRACTS);
verride2.setElement("value", 'Y');
session.sendRequest(request);

Get stream of new Facebook likes for your application

Is it possible to get response from Graph API (or FQL) that will list new likes for application and objects tied to it? Meaning - I created application, posted Like buttons all over the site - can I now get feed that will tell me what are the last 10 likes my pages received?
Related - can I somehow get list of last 10 likes of my Fan Page (something like New Likes box in Admin section)?
There is no public Facebook API that will allow you to receive a stream of the most recent likes for a collection of objects.
Furthermore, it doesn't appear to be possible to obtain a stream of likes ordered specifically by time, however it is possible to receive a list of user IDs who liked an object using the like FQL table.
like: An FQL table that returns the IDs of users who like a given object (video, note, link, photo, or album).
For example, to retrieve a list of all the user ids who liked the 'Facebook' page, you would use the FQL query:
SELECT user_id FROM like WHERE object_id="122706168308"
Which would return a list similar to this:
<fql_query_response xmlns="http://api.facebook.com/1.0/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" list="true">
<like>
<user_id>100003494051884</user_id>
</like>
<like>
<user_id>100003621882407</user_id>
</like>
<like>
<user_id>100003664580513</user_id>
</like>
<like>
<user_id>100002342537723</user_id>
</like>
<like>
<user_id>100001712929866</user_id>
</like>
<like>
<user_id>100003278394112</user_id>
</like>
</fql_query_response>
The order of the user IDs isn't clear - it may be in no specific order, or it may be ordered by time. I'd recommend that you have a bit of a fiddle with FQL and likes to see if it is in any particular order. You should also take a look at the other examples documented here.
As mentioned by Roni, it is possible to use the notifications RSS feed of your page to retrieve an RSS 2.0/XML feed of all notifications, sorted by time.
It may be possible to parse that XML to find the users who most recently liked your page, but the feed can get messy: it basically contains the HTML for each notification on the notifications page.
Question #1:
You can use Real-time Updates
Here are the steps to set up a subscription:
Set up an endpoint URL that receives both HTTP GET (for subscription verification) and > POST (for actual change data) requests from Facebook.
Make a POST to the graph API url https://graph.facebook.com//subscriptions to > subscribe, and be ready to handle the verification request.
What you get:
User connections to which you can subscribe: feed, friends, activities, interests, music, books, movies, television, likes, checkins.
What you don't get (yet):
home, tagged, posts, photos, albums, videos, groups, notes, events, inbox, outbox, updates, accounts.
Question #2:
Sure you can !
go to your Page Notifications (replace XXXX with your page ID)
you will find there an RSS link which you can use without even making a Graph API call
You will receive notifications when visitors interact with your page.
For example, if a visitor likes your page or a fan writes on your
wall, you will receive a notification.

Categories