Пример #1
0
def test_investpy_indices():
    """
    This function checks that index data retrieval functions listed in investpy work properly.
    """

    params = [
        {
            'country': 'spain',
        },
        {
            'country': None,
        },
    ]

    for param in params:
        investpy.get_indices(country=param['country'])
        investpy.get_indices_list(country=param['country'])

    params = [
        {
            'country': None,
            'columns': ['name', 'currency'],
            'as_json': True
        },
        {
            'country': None,
            'columns': ['name', 'currency'],
            'as_json': False
        },
        {
            'country': 'spain',
            'columns': ['name', 'currency'],
            'as_json': True
        },
        {
            'country': 'spain',
            'columns': ['name', 'currency'],
            'as_json': False
        },
        {
            'country': 'spain',
            'columns': None,
            'as_json': False
        },
    ]

    for param in params:
        investpy.get_indices_dict(country=param['country'],
                                  columns=param['columns'],
                                  as_json=param['as_json'])

    investpy.get_index_countries()

    params = [
        {
            'as_json': True,
            'order': 'ascending',
        },
        {
            'as_json': False,
            'order': 'ascending',
        },
        {
            'as_json': True,
            'order': 'descending',
        },
        {
            'as_json': False,
            'order': 'descending',
        },
    ]

    for param in params:
        investpy.get_index_recent_data(index='ibex 35',
                                       country='spain',
                                       as_json=param['as_json'],
                                       order=param['order'],
                                       interval='Daily')

        investpy.get_index_historical_data(index='ibex 35',
                                           country='spain',
                                           from_date='01/01/2018',
                                           to_date='01/01/2019',
                                           as_json=param['as_json'],
                                           order=param['order'],
                                           interval='Daily')

    params = [
        {
            'index': 'ibex 35',
            'country': 'spain',
            'as_json': False
        },
        {
            'index': 'ibex 35',
            'country': 'spain',
            'as_json': True
        }
    ]

    for param in params:
        investpy.get_index_information(index=param['index'], country=param['country'], as_json=param['as_json'])
    
    params = [
        {
            'country': 'united states', 
            'as_json': False,
            'n_results': 10
        },
        {
            'country': 'united kingdom', 
            'as_json': True,
            'n_results': 10
        }
    ]

    for param in params:
        investpy.get_indices_overview(country=param['country'], as_json=param['as_json'], n_results=param['n_results'])

    investpy.search_indices(by='name', value='ibex')
Пример #2
0
########################################################################################################################
# 현재 접근 가능한 국가 리스트
countriesAvailable = investpy.get_certificate_countries()
print(countriesAvailable)

# 현재 접근 가능한 주식
currentCountry = countriesAvailable[1]
stocks = investpy.get_stocks(currentCountry)
print(stocks)
print(type(stocks))

# 미국 ETF 리스트 검색
df_us_etf = investpy.get_etfs(country='United States')
df_us_etf_search = df_us_etf[df_us_etf['symbol'].str.contains("IEF")]

countriesAvailable = investpy.get_index_countries()

investpy.indices.get_indices_list(country=None)
list_indices = investpy.indices.get_indices_list(country='United States')

# investpy 패키지를 사용하여 KOSPI 자료 받기
investpy_kospi = investpy.get_index_historical_data(index="KOSPI",
                                                    country="south korea",
                                                    from_date="30/01/1900",
                                                    to_date=DD_END_DATE)
investpy_kospi.reset_index(level=0, inplace=True)  # 날짜 인덱스를 칼럼으로
investpy_kospi.rename(columns={
    "Open": "KOSPI_Open",
    "High": "KOSPI_High",
    "Low": "KOSPI_Low",
    "Close": "KOSPI_Close"
Пример #3
0
def test_investpy_indices():
    """
    This function checks that index data retrieval functions listed in investpy work properly.
    """

    params = [
        {
            'country': 'spain',
        },
        {
            'country': None,
        },
    ]

    for param in params:
        investpy.get_indices(country=param['country'])
        investpy.get_indices_list(country=param['country'])

    params = [
        {
            'country': None,
            'columns': ['name', 'currency'],
            'as_json': True
        },
        {
            'country': None,
            'columns': ['name', 'currency'],
            'as_json': False
        },
        {
            'country': 'spain',
            'columns': ['name', 'currency'],
            'as_json': True
        },
        {
            'country': 'spain',
            'columns': ['name', 'currency'],
            'as_json': False
        },
        {
            'country': 'spain',
            'columns': None,
            'as_json': False
        },
    ]

    for param in params:
        investpy.get_indices_dict(country=param['country'],
                                  columns=param['columns'],
                                  as_json=param['as_json'])

    investpy.get_index_countries()

    params = [
        {
            'as_json': True,
            'order': 'ascending',
            'debug': False
        },
        {
            'as_json': False,
            'order': 'ascending',
            'debug': True
        },
        {
            'as_json': True,
            'order': 'descending',
            'debug': False
        },
        {
            'as_json': False,
            'order': 'descending',
            'debug': False
        },
    ]

    for param in params:
        investpy.get_index_recent_data(index='ibex 35',
                                       country='spain',
                                       as_json=param['as_json'],
                                       order=param['order'],
                                       debug=param['debug'])

        investpy.get_index_historical_data(index='ibex 35',
                                           country='spain',
                                           from_date='01/01/2018',
                                           to_date='01/01/2019',
                                           as_json=param['as_json'],
                                           order=param['order'],
                                           debug=param['debug'])

    investpy.search_indices(by='name', value='ibex')
Пример #4
0
import pandas as pd

fund_sheet = 'funds'
index_sheet = 'indices'
stock_sheet = 'stocks'
bond_sheet = 'bonds'
etf_sheet = 'etfs'
crypto_sheet = 'cryptos'

req_fund_countries = investpy.get_fund_countries()
df_fund_countries = pd.DataFrame(req_fund_countries)

req_bond_countries = investpy.get_bond_countries()
df_bond_countries = pd.DataFrame(req_bond_countries)

req_index_countries = investpy.get_index_countries()
df_index_countries = pd.DataFrame(req_index_countries)

req_stock_countries = investpy.get_stock_countries()
df_stock_countries = pd.DataFrame(req_stock_countries)

req_etf_countries = investpy.get_etf_countries()
df_etf_countries = pd.DataFrame(req_etf_countries)


def GetCountries():
    wb = xw.Book.caller()
    wb.sheets[fund_sheet].range('A1').value = df_fund_countries
    wb.sheets[index_sheet].range('A1').value = df_index_countries
    wb.sheets[stock_sheet].range('A1').value = df_stock_countries
    wb.sheets[bond_sheet].range('A1').value = df_bond_countries