def test_gdshe_data_no_properties(self, mocked_post):
     ciq_client = CapIQClient("username", "password")
     return_value = ciq_client.gdshe(["TRIP"], ["IQ_CLOSEPRICE"],
                                     ["close_price"],
                                     start_date="12/19/1980",
                                     end_date="12/19/2000")
     self.assertEqual(return_value, {'TRIP:': {'close_price': [['46.80']]}})
예제 #2
0
    def test_python_2_exception(self):
        def import_mock(name, *args):

            if name == 'http.client':
                raise ImportError
            return orig_import(name, *args)

        with mock.patch('builtins.__import__', side_effect=import_mock):
            capiq_client = CapIQClient("username", "password", verify=False)
            self.assertIsInstance(capiq_client, CapIQClient)
 def test_gdshe_multi_data_with_name_collision(self, mocked_post):
     ciq_client = CapIQClient("username", "password")
     return_value = ciq_client.gdshe(["TRIP", "TRIP"],
                                     ["IQ_VWAP", "IQ_VWAP"],
                                     ["vwap1", "vwap2"],
                                     properties=[{
                                         "STARTDATE": "05/23/2017",
                                         "ENDDATE": "05/29/2017"
                                     }, {
                                         "STARTDATE": "05/16/2017",
                                         "ENDDATE": "05/22/2017"
                                     }])
     self.assertEqual(
         return_value, {
             'TRIP:': {
                 'vwap1':
                 [['239.900000', '5/23/2017'], ['240.410000', '5/24/2017'],
                  ['241.710000', '5/25/2017'], ['241.590000', '5/26/2017']],
                 'vwap2':
                 [['240.040000', '5/16/2017'], ['237.870000', '5/17/2017'],
                  ['236.640000', '5/18/2017'], ['238.330000', '5/19/2017'],
                  ['239.210000', '5/22/2017']]
             }
         })
 def test_gdsp_no_data(self, mocked_post):
     ciq_client = CapIQClient("username", "password")
     return_value = ciq_client.gdsp(["TRIP"], ["IQ_CLOSEPRICE"],
                                    ["close_price"], [{}])
     self.assertEqual(return_value, {'TRIP:': {'close_price': None}})
예제 #5
0
           'revenues_ttm': ['IQ_TOTAL_REV', {'PERIODTYPE': 'IQ_LTM'}],
           'revenues': ['IQ_TOTAL_REV', {'PERIODTYPE': 'IQ_FQ'}], 'cash_and_equivalents': ['IQ_CASH_EQUIV', {}],
           'one_month_total_return': ['IQ_CLOSEPRICE_ADJ', {'PERIODTYPE': '-1M', 'MULTIPLYING_FACTOR': 0.01}],
           'three_month_total_return': ['IQ_CLOSEPRICE_ADJ', {'PERIODTYPE': '-3M', 'MULTIPLYING_FACTOR': 0.01}],
           'six_month_total_return': ['IQ_CLOSEPRICE_ADJ', {'PERIODTYPE': '-6M', 'MULTIPLYING_FACTOR': 0.01}],
           'one_year_total_return': ['IQ_CLOSEPRICE_ADJ', {'PERIODTYPE': '-1Y', 'MULTIPLYING_FACTOR': 0.01}],
           'three_year_total_return': ['IQ_CLOSEPRICE_ADJ', {'PERIODTYPE': '-3Y', 'MULTIPLYING_FACTOR': 0.01}],
           'five_year_total_return': ['IQ_CLOSEPRICE_ADJ', {'PERIODTYPE': '-5Y', 'MULTIPLYING_FACTOR': 0.01}],
           'return_on_invested_capital': ['IQ_RETURN_CAPITAL', {}],
           'revenues_annual': ['IQ_TOTAL_REV', {'PERIODTYPE': 'IQ_FY'}],
           'ebit_margin_annual': ['IQ_EBIT_MARGIN', {'PERIODTYPE': 'IQ_FY'}],
           'volume': ['IQ_VOLUME', {}]}

if __name__ == '__main__':

    client = CapIQClient("username", "password")
    #print(client.gdshe(['WMT:', "ibm:"],['IQ_CLOSEPRICE'], ['close_price'], start_date='11/12/2010',end_date='11/18/2010'))
    # mnemonics = []
    # properties = []
    # for m in metrics:
    #     mnemonics += [metrics[m][0]]
    #     properties += [metrics[m][1]]
    # r = client.gdsp(['IBM:'],mnemonics,properties=properties)
    # for k in r:
    #     for i in r[k]:
    #         if 'Headers' not in i:
    #             print 'Error:', i
    #             continue
    #         for ii in range(0,len(i['Headers'])):
    #             print i['Headers'][ii],':',i['Rows'][ii]
 def test_gdsg_data(self, mocked_post):
     ciq_client = CapIQClient("username", "password")
     return_value = ciq_client.gdsg(["TRIP"], ["IQ_CLOSEPRICE"],
                                    ["close_price"],
                                    properties=[{}])
     self.assertEqual(return_value, {'TRIP:': {'close_price': '46.80'}})
예제 #7
0
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Mon Apr 19 12:22:56 2021

@author: byersjw
@author: https://github.com/faaez/capiq-python
"""#
#
#
from capiq.capiq_client import CapIQClient
ciq_client = CapIQClient("*****@*****.**", "SSOK2018a")
return_value = ciq_client.gdsg(["IBM"], ["IQ_CLOSEPRICE"], ["close_price"],
                               properties=[{}])

#  File "/home/byersjw/work/repo/presentations/Classes/Shared/CapitalIQ/capitalIQ.py", line 12, in <module>
#     return_value = ciq_client.gdsg(["TRIP"], ["IQ_CLOSEPRICE"], ["close_price"], properties=[{}])

#   File "/usr/local/lib/python3.9/site-packages/capiq/capiq_client.py", line 99, in gdsg
#     return self.make_request(identifiers, group_mnemonics, return_keys, properties, "GDSG", False)

#   File "/usr/local/lib/python3.9/site-packages/capiq/capiq_client.py", line 157, in make_request
#     if len(response.json()['GDSSDKResponse']) == 1 and \

#   File "/usr/lib/python3.9/site-packages/requests/models.py", line 898, in json
#     return complexjson.loads(self.text, **kwargs)

#   File "/usr/lib64/python3.9/json/__init__.py", line 346, in loads
#     return _default_decoder.decode(s)

#   File "/usr/lib64/python3.9/json/decoder.py", line 337, in decode
예제 #8
0
 def test_gdsp_api_service_error(self, mocked_post):
     ciq_client = CapIQClient("username", "password")
     with self.assertRaises(CiqServiceException):
         ciq_client.gdsp(["TRIP"], ["IQ_CLOSEPRICE"], ["close_price"], [{}])
예제 #9
0
 def test_debug_false(self):
     ciq_client = CapIQClient(
         "username",
         "password",
     )
     self.assertEqual(ciq_client._debug, False)
예제 #10
0
 def test_debug_true(self):
     ciq_client = CapIQClient("username", "password", debug=True)
     self.assertEqual(ciq_client._debug, True)
예제 #11
0
 def test_verify_false(self):
     ciq_client = CapIQClient("username", "password", verify=False)
     self.assertEqual(ciq_client._verify, False)
예제 #12
0
 def test_verify_true(self):
     ciq_client = CapIQClient("username", "password", verify=True)
     self.assertEqual(ciq_client._verify, True)