* European YTD sector performance chart: bit.ly/2grRpFK
* European basic resources index up 70 pct in 2016
* Extension of rally into 2017 rests on China, Trump
* Stocks expensive relative to historical standards
By Atul Prakash and Peter Hobson
LONDON, Dec 9 (Reuters) - European miners are in a race for the title of the best sector performer this year, a sharp turnaround from a slump in 2015, although the rally extending into 2017 rests on U.S. president-elect Donald Trump and China.
A recovery in commodity prices, better balance sheets and brighter global economic growth prospects have underpinned the rally in so-called 'cyclical' stocks - which tend to follow the fortunes of the wider economy - that were beaten down to low valuations at the end of 2015.
Glencore's move to join a consortium taking a stake in Russian oil giant Rosneft suggests some companies are getting more confident about their balance sheets, analysts said.
But with several blue-chip mining shares surging, a lot of optimism may already be in the price, they said.
Companies such as Anglo American and Glencore , up 315 percent and 235 percent respectively in 2016, have helped the mining index to surge 70 percent this year and be on track to snap a three-year losing streak. In contrast, the pan-European STOXX 600 is down 3 percent.
The sector is also relatively expensive, with its price-to-earnings ratio now at 14.6 times forward earnings, against a 10-year average of 11.5, according to Thomson Reuters Data.
With valuations not so supportive, any sign of fresh wobbles in China, or that an expected fiscal stimulus from Donald Trump's incoming U.S. administration may not be as big as hoped, risks derailing the current rally.
"The main risks for miners are indeed Trump and China. A lot of the rally is built on him delivering on his lofty promises. If he fails, it will hurt materials disproportionately," said Philippe Gijsels, head of research at BNP Paribas Fortis.
"The same goes for China. The country continues to stimulate its economy. If the efforts are mismanaged and China end up in a hard landing scenario, it would have a profoundly negative impact on commodities-related stocks."
Analysts said any economic stress on China, the world's biggest metals consumer, could change sentiment.
Chinese economic growth is more reliant on government spending, state-owned firms and "old economy" industries like steel and mining which Beijing has been trying to restructure via capacity cuts.
Analysts warn a property boom, which has generated a significant share of the growth, may be peaking, dampening demand for building materials from cement to steel.
"Trends in earnings have been turning to the upside. However, the biggest risk is a significant growth deterioration in China," UniCredit analyst Christian Stocker said.
Analysts said Trump is also seen as a risk for the sector.
After his election win, Trump said U.S. infrastructure will become "second to none". He has pledged to allocate $500 billion to $1 trillion to rebuild dilapidated roads and bridges.
There was no certainty that his vague plans would go ahead in the way a lot of investors were anticipating, analysts said, adding that any diversion from the pledge could result in a sharp sell-off in metals, which in turn would hit mining stocks.
A firmer dollar on expectations of U.S. rate hikes is another potential risk as a stronger dollar makes metals expensive for other currency holders.
However, some investors are sticking with their bullish views seeing potential for dividends.
"I think we are near the end of a commodities downturn. There is scope for dividends to rise from here over the coming years," said Stephen Macklow-Smith, head of European equity strategy at JPMorgan Asset Management.
"Capex expectations have been reset and balance sheets don't look particularly stretched. If demand continues to recover in emerging markets, then commodities prices will continue to recover," he added.
Dividend yield at miners listed in London has slumped 1.4 percent to its lowest in five years just as cash flows in the sector improve following a recovery in metals prices, prompting some analysts to call for higher payouts as early as next year.
Prices of commodities such as copper and aluminium have recovered this year, partly on the back of capacity cuts in China, further improving profit margins of producers.
Credit Suisse predicts free cash flow yield, a measure of balance sheet health, of large-cap firms at 10 to 11 percent in 2017 and 8 to 9 percent in 2018. Dividend yields are forecast to almost double to 4 percent.
Reporting by Atul Prakash; Editing by Vikram Subhedar and Toby Chopra