getHistoryData

I am getting this error when running the getHistorydata function, my codes are bloew:

Some fields are invalid or do not exist for requested ticker(s):

data = alphien.data.getTickersSP500().ticker

tickers = data.tolist() 

tickers

px = alphien.data.getHistoryData(tickers, field = ‘bb_live’, zoom=‘2006::2017’)


So the database don’t have certain tickers due to some of them getting drop out of the index.

But do they not show up as NaN?We have to find them out ourselves?


I tried getting tickers from the Wikipedia and append .US Equity to them and re run it and get the same error.

ValueError: Some fields are invalid or do not exist for requested ticker(s):
ticker: ABMD.US Equity / field: bb_live
ticker: ALGN.US Equity / field: bb_live
ticker: AMCR.US Equity / field: bb_live
ticker: ANET.US Equity / field: bb_live
ticker: ANSS.US Equity / field: bb_live
ticker: AOS.US Equity / field: bb_live
ticker: ARE.US Equity / field: bb_live
ticker: ATO.US Equity / field: bb_live
ticker: BIO.US Equity / field: bb_live
ticker: BR.US Equity / field: bb_live
ticker: CARR.US Equity / field: bb_live
ticker: CBOE.US Equity / field: bb_live
ticker: CDNS.US Equity / field: bb_live
ticker: CDW.US Equity / field: bb_live
ticker: CE.US Equity / field: bb_live
ticker: CPRT.US Equity / field: bb_live
ticker: CTVA.US Equity / field: bb_live
ticker: DISH.US Equity / field: bb_live
ticker: DOW.US Equity / field: bb_live
ticker: DPZ.US Equity / field: bb_live
ticker: DRE.US Equity / field: bb_live
ticker: DXC.US Equity / field: bb_live
ticker: DXCM.US Equity / field: bb_live
ticker: EVRG.US Equity / field: bb_live
ticker: FANG.US Equity / field: bb_live
ticker: FLT.US Equity / field: bb_live
ticker: FOX.US Equity / field: bb_live
ticker: FOXA.US Equity / field: bb_live
ticker: FRC.US Equity / field: bb_live
ticker: FTNT.US Equity / field: bb_live
ticker: HFC.US Equity / field: bb_live
ticker: HII.US Equity / field: bb_live
ticker: HLT.US Equity / field: bb_live
ticker: IDXX.US Equity / field: bb_live
ticker: IEX.US Equity / field: bb_live
ticker: INCY.US Equity / field: bb_live
ticker: INFO.US Equity / field: bb_live
ticker: IPGP.US Equity / field: bb_live
ticker: IQV.US Equity / field: bb_live
ticker: IR.US Equity / field: bb_live
ticker: IT.US Equity / field: bb_live
ticker: JKHY.US Equity / field: bb_live
ticker: KEYS.US Equity / field: bb_live
ticker: LVS.US Equity / field: bb_live
ticker: LW.US Equity / field: bb_live
ticker: LYV.US Equity / field: bb_live
ticker: MGM.US Equity / field: bb_live
ticker: MKTX.US Equity / field: bb_live
ticker: MO.US Equity / field: bb_live
ticker: MSCI.US Equity / field: bb_live
ticker: NCLH.US Equity / field: bb_live
ticker: NOW.US Equity / field: bb_live
ticker: NVR.US Equity / field: bb_live
ticker: ODFL.US Equity / field: bb_live
ticker: OTIS.US Equity / field: bb_live
ticker: PAYC.US Equity / field: bb_live
ticker: PKG.US Equity / field: bb_live
ticker: RE.US Equity / field: bb_live
ticker: REG.US Equity / field: bb_live
ticker: RJF.US Equity / field: bb_live
ticker: RMD.US Equity / field: bb_live
ticker: ROL.US Equity / field: bb_live
ticker: SBAC.US Equity / field: bb_live
ticker: SIVB.US Equity / field: bb_live
ticker: SNPS.US Equity / field: bb_live
ticker: STE.US Equity / field: bb_live
ticker: TDY.US Equity / field: bb_live
ticker: TFX.US Equity / field: bb_live
ticker: TTWO.US Equity / field: bb_live
ticker: TWTR.US Equity / field: bb_live
ticker: TXT.US Equity / field: bb_live
ticker: TYL.US Equity / field: bb_live
ticker: VAR.US Equity / field: bb_live
ticker: WAB.US Equity / field: bb_live
ticker: WRB.US Equity / field: bb_live
ticker: WST.US Equity / field: bb_live
ticker: ZBRA.US Equity / field: bb_live


Hi Keith,

Thanks for pointing this out; we’ll need to investigate what’s happening in those stocks. However, I can see some tickers from the above list are different from the ones given by getTickersSP500. Please use (as you correctly did in your code) tickers as given by the ticker function.


Meanwhile we investigate on these series, I suggest you use a smaller sample to try and build your first payout. If you manage to implement you logic correctly for 50 stocks, applying it to 500 or 600 stocks should only be a matter of changing an input in your function.


We’ll come back to you on the issue above asap. Again, thanks for pointing it out.

Hi Keith - The database contains delisted tickers and you can check the price is not available on some of them, you should not be using third party data source for the competition - all data in the Alphien platform should be cleaned and checked, please report any issues if any specific equity missing. Please post your competition on the Alphathon category.


Thanks and happy coding on Alphien. Lionel.

Dear Ls


Many stock tickers which went bankruptcy are missing. Please fix the problem.


Best regards

I met the same problem.I hope this problem can be fixed soon.Thank you !

I am contacting both of you via Alphachat because the problem that you point out above is not clear to us. We don’t know what is not working on your side.


If you are using wikipedia stock name which is unreliable, you have no chance of moving forward.


Please be clear on what you request us to help on ! Cheers. Lionel.

Hello,

can you restart your kernel and try the code below?

import alphien
from more_itertools import unique_everseen
tickers = alphien.data.getTickersSP500()
data = alphien.data.getHistoryData(list(unique_everseen(tickers.ticker)),field = “bb live”)


It’s able to grab 667 tickers from 2007 to 2016 and a lot quicker!! I am also able to pass my payout function and get the dataframe i need for backtest.


However, there seems to be issues when I run the backtest:

[14]:port = alphien.portfolio.Portfolio(tickers)

Generating weights for payoutorz007200915

No value found for EOP.US Equity, HPC.US Equity, MCHP.US Equity, MRO.US Equity, PDCO.US Equity, WAT.US Equity at specified dates

NameError Traceback (most recent call last)
<ipython-input-18-7fb61b6786f7> in <module>
----> 1 port.backtest()

/mnt/public/IT/Libs/Python/alphien/portfolio/portfolio.py in backtest(self, zoom, period, plot, printStats, tc, fc)
544
545 #remove non business days from weights
–> 546 weights = removeNonBusinessDaysFromIndicator(weights, prices)
547
548 #combine prices and indicator

/mnt/public/IT/Libs/Python/alphien/database/removeNonBusinessDaysFromIndicator.py in removeNonBusinessDaysFromIndicator(indicator, bbPrices, lag)
38 shapeDiff = indicator.shape[1] - bbPrices.shape[1]
39 for i in range(shapeDiff):
—> 40 bbPrice[f’price_{i+1}’] = bbPrice.values
41 indCol = indicator.shape[1]
42

NameError: name ‘bbPrice’ is not defined


I did assign the tickers with what you provided too for the portfolio:


tickers = list(unique_everseen(tickers.ticker))