alvarobartt / investpy

Financial Data Extraction from Investing.com with Python
https://investpy.readthedocs.io/
MIT License
1.63k stars 377 forks source link

Reg: Data extraction #292

Open kamarani1989 opened 3 years ago

kamarani1989 commented 3 years ago

exchange : MCX, while the metals(Copper,Lead,zinc,nickel,aluminium) expiry is 5 days prior to the expiry date, after that next contract data has a significance,while investpy doesn't allow me extract next contract data or 2nd month continuous data.Any solution for this

alvarobartt commented 3 years ago

Hi @kamarani1989, can you give me more details, please? 🙏🏻

kamarani1989 commented 3 years ago

MCX COPPER 26 FEB 2021--- EXPIRY IS 26TH FEB ,but actual trading stops at 19th FEB AFTER WARDS PHYSICAL DELIVERY (TENDER PERIOD STARTS), LIKE WISE ZINC,ALUMINIUM,NICKEL,LEAD EVERY CONTRACT EXPIRY, BEFORE 5 DAYS ACTUAL TRADING IN THESE IS NOT ALLOWED,SAME APPLIES TO GOLD, SILVER EXPIRY DATE IS 05 MAR 2021 BUT TRADING IS ALLOWED TILLL 26TH FEB...

kamarani1989 commented 3 years ago

above phenomenon is observed in the volumes of base metals and bullions 5 trading days prior expiry date ,it significantly drops because the actual trading happens in next contract. According to my understanding either providing 2 continuous contracts or contract wise data could help.. pls suggest any other solution if u have.

kamarani1989 commented 3 years ago

sir, can you suggest me a solution for this

alvarobartt commented 3 years ago

@kamarani1989 I need you to provide me the following:

With all this information I'll be able to help you! 🤗

kamarani1989 commented 3 years ago

FUNCTION I USE IS : tickers= ['MCX Gold 1 Kg','MCX Silver','MCX Crude Oil WTI','MCX Natural Gas','MCX Copper','MCX Zinc','MCX Lead','MCX Nickel',"Aluminum"] comex_ticker = ['gold','silver']

import investpy dfs=[]

for ticker in tickers: df = investpy.commodities.get_commodity_recent_data(commodity=ticker, interval='Daily', country = "india",order ='ascending') There are 2 problems i am facing the while extracting data

1st problem:

1)while downloading today's data ,crude oil past contract data is coming. not found ticker in investing.com

2)which function to use to extract data from the tickers only.

3)while the base metals pct_change is from the previous contract...eg: i want to extract the data MZIH1--TICKER. liemwise other metal contract specific data..link attached.. zinc contract

todays data

2nd problem:

while extracting the last trading day data, comex gold and silver are giving me 21-02-2021(sunday)data. and the crude oil data is 18-02-2021(friday data).pfa

yesterday_data

i want all the contract specfic datas which are ticker based (contracts)rather than continuous basis.

and while extracting comex data saturday prices are coming...

if any additional information required pls comment sir

kamarani1989 commented 3 years ago

sir any temporary solution u may give for the above issue, actually i m doing lot of manual work

kamarani1989 commented 3 years ago

1)Below tickers are available in investing.com while the same are not available in invespty library. 2)how to get the commodity data using the tickers like 'MZIH1' ,'MLDH1',etc.

TICKER | COMMODITY | EXCHANGE

NRSc1 | MUSTARD SEED FUTURES | NCDEX NRSc2 | MUSTARD SEED FUTURES | NCDEX NCHc1 | Chana Gram Futures | NCDEX NCHc2 | Chana Gram Futures | NCDEX NCHc3 | Chana Gram Futures | NCDEX NCSc1 | Castor Seed Futures | NCDEX NCSc2 | Castor Seed Futures | NCDEX NCSc3 | Castor Seed Futures | NCDEX NSOc1 | Refined Soya Oil Futures | NCDEX NSOc2 | Refined Soya Oil Futures | NCDEX NSOc3 | Refined Soya Oil Futures | NCDEX NGRSc1 | Guar Seed 10 MT Futures | NCDEX NGRSc2 | Guar Seed 10 MT Futures | NCDEX NGRSc3 | Guar Seed 10 MT Futures | NCDEX NGGc1 | Guar Gum Futures | NCDEX NGGc2 | Guar Gum Futures | NCDEX NGGc3 | Guar Gum Futures | NCDEX NSBc1 | Soybean Futures | NCDEX NSBc2 | Soybean Futures | NCDEX NSBc3 | Soybean Futures | NCDEX NTMc1 | Turmeric Futures | NCDEX NTMc2 | Turmeric Futures | NCDEX NTMc3 | Turmeric Futures | NCDEX NCORc1 | Coriander futures | NCDEX NCORc2 | Coriander futures | NCDEX NCORc3 | Coriander futures | NCDEX NJEc1 | Jeera Futures | NCDEX NJEc2 | Jeera Futures | NCDEX NJEc3 | Jeera Futures | NCDEX MCBUc1 | MCX ICOMDEX bullion Futures | MCX MCBMc1 | MCX ICOMDEX BASE METAL Futures | MCX

kamarani1989 commented 3 years ago

sir, any update on this issue, kindly provide the alternate solution

alvarobartt commented 3 years ago

Ok, I think I get your point now! So the issue here is that when looking for the Ticker Futures, Investing.com provides you the historical data with duplicated dates since there's a unique value per row for the ticker name so that you want to filter those by ticker?

Can you share something as simple as:

>>> import investpy
>>> # THE INVESTPY FUNCTION FOR 1 EXAMPLE
THE OUTPUT

And then the same, but with the expected output so that I can tackle it ASAP, since I'm not too familiar with Futures, neither on how Investing.com presents that data.

Does this just happen for India?

alvarobartt commented 3 years ago

Regarding your second question, feel free to use invespty.search_quotes() rather than the commodity-specific functions, as that function uses the Investing.com search engine which means that the data is updated and all the data is available (as long as it is available in Investing.com).

Here's a simple example:

>>> import investpy
>>> investpy.__version__
'1.0.6'

>>> search_result = investpy.search_quotes(text='zinc futures', products=['commodities'], countries=['india'], n_results=1)
>>> print(search_result)
{"id_": 49794, "name": "Zinc Futures", "symbol": "MZIK1", "country": "india", "tag": "/commodities/zinc-futures", "pair_type": "commodities", "exchange": "MCX"}

# You can now retrieve either the recent or historical data and the financial product information as it follows
>>> recent_data = search_result.retrieve_recent_data()
>>> historical_data = search_result.retrieve_historical_data(from_date='01/01/2020', to_date='01/01/2021')
>>> information = search_result.retrieve_information()

To further explore the functionality of investpy.search_quotes() please check [Wiki - investpy.search_quotes()](https://github.com/alvarobartt/investpy/wiki/investpy.search_quotes())

:pushpin: Make sure that you are using the latest investpy version! investpy v1.0.6

alvarobartt commented 3 years ago

Also, please don't forget to share the Investing.com URL of the screenshot you sent me so that I can work on it! 👍🏻

kamarani1989 commented 3 years ago

import investpy

search_result = investpy.search_quotes(text='Turmeric Futures', products=['commodities'], countries=['india'], n_results=1) print(search_result)

recent_data = search_result.retrieve_recent_data()

recent_data

got the data for ntmc1 ,how to get the data for ntmc2,ntmc3---future tickers(2nd,3rd month continuous)