Thursday 7 December 2017

Using Bloomberg From R and Excel


Bloomberg from R

First, you need to be logged on to Bloomberg.

If the Bloomberg/Excel add-in does not work, then:
1. Close Excel and/or R
2. Keep Bloomberg running
3. Go to Start-> Bloomberg -> API Environment Diagnostics
4. Click Start when the Bloomberg API Diagnostics window has loaded
5. If a “Login to wintrv…” message below then pops up, this occurs when Bloomberg isn’t open – it is highly recommended that you have Bloomberg running; you can proceed without it, but you may not be able to resolve some errors if you do so
6. Once the check is finished, you will get a 'Diagnostics completed' message
7. If the Repair button is available to press on the Bloomberg API Diagnostics window, it means it needs to run the repair and you should do so by clicking Repair (it should take a couple of minutes)
8. Once the check is done, and repair if necessary, the ideal state is all green ticks except for 2 yellow “!” for Dotnet Installation and Excel Throttle Interval only. Else, you can still run Excel or R-Studio and see if the Bloomberg-associated functionality is working.

# install the Bloomberg package, and connect
install.packages("Rblpapi")
library (Rblpapi)
blpConnect()

# get the Bloomberg data history for SPY US Equity - last 100 days - and plot it
x <-  bdh("SPY US Equity", "PX_LAST", start.date=Sys.Date()-100)
plot(x)

# find out what other fields are available for prices
res <- fieldSearch("price")
res

# get the Bloomberg data history for SPY US Equity - last 100 days - and plot it
x <-  bdh("SPY US Equity", "OPEN", start.date=Sys.Date()-100)
plot(x)

Bloomberg from Excel

As above, if the Bloomberg/Excel add-in does not work, then repair (Steps 1-8).
Open an Excel Sheet, and type the following into a cell:
Historical prices: BDH("F US Equity", "PX_LAST", “16/11/2000”, “15/11/2016”)
This will give you the last traded price (PX_LAST) for 'F US Equity (Ford Motor  Company) from 16/11/2000 to 15/11/2016. The first parameter must be the Bloomberg stock code.

For DMU students, this URL shows how to get data from Bloomberg into Excel.
Also for DMU students, this URL shows how to use Bloomberg.


Monday 25 September 2017

Ukraine's path to prosperity


You can get an Uber in Ukraine. Investment is more difficult, because borrowing in local currency (Hryvnia) is expensive. The official interest rate is 12.5%, local currency mortgages cost around 20% and credit cards cost around 40%. To borrow more cheaply, many households took out USD mortgages prior to the Global Financial Crisis but, when the Hryvnia collapsed, these became unmanageable. Subsequently, the parliament (Rada) banned foreign currency mortgages and imposed a moratorium on the confiscation of property by the banks. The government finds it equally difficult to borrow cheaply, with the most recent sovereign Eurobond issue at 7.375%. The cheapest borrowing is reserved for privatised companies that export commodities: for example, LSE listed Ferrexpo, which is 51% owned by Rada member Kostyantyn Zhevago and exports iron ore pellets, has bond yields as low as 3.7%.  

Unsurprisingly, Ukranian public opinion is that the financial system is loaded against them. Two-thirds of sovereign bonds are issued in foreign currency, which means that Ukraine must have a constant stream of foreign currency to meet its payment schedules. When Ukraine does well, the Hryvina strengthens and foreign currency is easy to get. When Ukraine does badly, as it did after the conflict in the East, the Hryvina devalues and there is a scrabble for foreign exchange to satisfy creditors. Official statistics suggest that the central bank has enough foreign exchange reserves for about 3.5 months of exports, at $18 billion, but there is another $90 billion held privately by individuals. 



The conditionality attached to foreign loans is depressingly familiar, with the IMF requiring a maximum 3% public deficit, and the World Bank calling for sustainable public pensions. This, at a time when the minimum pension is little more than $2 per day.

And therein lies the trap. Public borrowing is heavily constrained, and private borrowing is too expensive. Notionally, the primary target of the central bank is inflation, and they have implemented tough measures to stabilise the foreign exchange rate. But lowering the interest rate requires reforms to reduce the cost of borrowing from local banks: better regulation, banking competition, less corruption, enforceable contracts, recognised accounting standards and clear accountability. Without deeper reforms, the risk is that the Rada will continue to make the same mistakes: hasty privatisations and sales of public land to ease the budget pressures but, in the process, creating the conditions for a new class of wealthy elites. Part of the problem is the Rada itself, which is unicameral (one legislative chamber) with code-based law. Here, the outlook for reform is less clear.

What’s to be done? At the Ukrfinforum last week (21/9/2017), Yanis Varoufakis called for a new Bretton Woods agreement. The World Bank and IMF could acknowledge that the financial system is heavily loaded against ordinary people, accept the need for International reforms, and back off on the conditionality around sequencing: they could support any measures that reduce the cost of borrowing, including an end to the war. The economy will turn round when Ukranians are confident and able to borrow and invest locally, which in turn will reduce Ukraine’s dependency on foreign exchange being earned by a small number of commodity exporters.

Wednesday 25 January 2017

Infrastructure activism


The highlight of the inaugral NEKS conference was to hear Sir Vince Cable talking about Theresa May's industrial strategy, which he describe as a 'rebranding [of the 2011 strategy] with some good new features'. He reminded us that the UK abandoned interventionist policies in 1979, a state that remained until Mandelson's car scrappage scheme in April 2009, followed by support for the UK aerospace sector.

Sir Vince told us that he concocted a letter with Michael Heseltine, who had an adjacent office, asking David Cameron to be more strategic about UK government procurement. Two big ideas followed. The first was to encourage long-term, strategic thinking by government, leading to such things as the recently launched National Infrastructure Commission; the second was to directly support key sectors such as aerospace, cars, textiles, apprenticeships and University Innovation Centres. Sir Vince reminded us that we should also question economic wisdoms: in terms of revealed comparative advantage, the UK is supposed to put all its eggs in one basket and concentrate on financial services. BREXIT poses a new question for industrial strategy: do we 'take back control' and become more interventionist, or do we relinquish control to the markets?

In explaining how the UK handles infrastructure today, Bridget Roswell told us about the National Infrastructure Commission (NIC), an Executive Agency that reports to HM Treasury. The NIC is designed to circumvent short-term electoral cycles by developing long-term infrastructure plans for transport, energy, water, sewerage and telecoms. At the conference, I heard several different approaches to long-term planning, but the problems were the same: how do you measure success, which criteria do you use? Francesca Medda (UCL) described a portfolio structuring approach, designed to optimise a portfolio of projects combining negative NPV/high social value projects with positive NPV/lower social value projects. Others, such as Tim Foxon (SPRU), outlined ways to involve the local community in the appraisal and selection of suitable projects.

It is always difficult squaring the circle between objective and subjective approaches to project appraisal. I was reminded of the solution adopted for the schools' funding formula: central government sets the boundaries within which each local authority must work. On the one hand, there is an objective framework that is the equivalent of UCL's social value optimisation. On the other hand, local authorities tweak the formula to meet local needs. However, the option to consider non-financial measures barely features in the infrastructure regulation. Chris Green (SQW) and Nicholas Miles bemoaned that the majority of transport projects look only at 'time saved', which an optimiser would rapidly transform into something akin to Le Corbusier's Plan Voisin:



Several conference participants came up with alternative factors that local communities might want to consider: health, productivity, distributional effects, ecological value, direct consumption value, and so on. Goodhart's Law is clearly at play here: 'when a measure (journey time saved) becomes a target, it ceases to be a good measure'.

In several breakout sessions, we discussed how we might persuade private investors to look beyond short-term financial gain. Steve Keen berated economists for narrow-thinking, as did Sir Vince who plugged the 'brilliant book written by Manchester students'. But there was also room for optimism. Sir Vince highlighted the alternative business model of The People's Trust whose objective is to 'achieve sustainable, long-term growth' via an alternative investment fund 'owned 100% by our members'. This is not investment advice, but a £20 bet, to help them launch, seems worth it to ensure an alternative to non-interventionist pension funds.

To sum up: I took away two strategies if we are going to 'take back control'. First, put public funds to better use through localism, or social value index optimisation, or both. Second, reinvigorate private investor activism.