class TestEbest(unittest.TestCase):
    def setUp(self):
        self.ebest = EBest("DEMO")
        self.ebest.login()

    # def test_get_credit_trend_by_code(self):
    #     print(inspect.stack()[0][3])
    #     result = self.ebest.get_credit_trend_by_code("005830", "20190222")
    #     assert result is not None
    #     print(result)
    #
    # def test_get_short_trend_by_code(self):
    #     print(inspect.stack()[0][3])
    #     result = self.ebest.get_short_trend_by_code(
    #         "005930", sdate="20181201", edate="20181231"
    #     )
    #     assert result is not None
    #     print(result)
    #
    # def test_get_agent_trend_by_code(self):
    #     print(inspect.stack()[0][3])
    #     result = self.ebest.get_agent_trend_by_code(
    #         "005930", fromdt="20181201", todt="20181231"
    #     )
    #     assert result is not None
    #     print(result)
    #
    # def test_get_code_list(self):
    #     print(inspect.stack()[0][3])
    #     all_result = self.ebest.get_code_list("ALL")
    #     assert all_result is not None
    #     kospi_result = self.ebest.get_code_list("KOSPI")
    #     assert kospi_result is not None
    #     kosdaq_result = self.ebest.get_code_list("KOSDAQ")
    #     assert kosdaq_result is not None
    #     try:
    #         error_result = self.ebest.get_code_list("KOS")
    #     except:
    #         error_result = None
    #     assert error_result is None
    #     print("result:", len(all_result), len(kosdaq_result), len(kospi_result))
    #
    # def test_get_stock_price_list_by_code(self):
    #     print(inspect.stack()[0][3])
    #     result = self.ebest.get_stock_price_by_code("005930", "2")
    #     assert result is not None
    #     print(result)

    # def test_get_account_info(self):
    #     result = self.ebest.get_account_info()
    #     assert result is not None
    #     print(result)

    def test_get_account_stock_info(self):
        result = self.ebest.get_account_stock_info()
        assert result is not None
        print(result)

    def tearDown(self):
        self.ebest.logout()
class TestEBest(unittest.TestCase):
    def setUp(self):
        self.ebest = EBest("DEMO")
        self.ebest.login()

    def test_get_code_list(self):
        print(inspect.stack()[0][3])
        all_result = self.ebest.get_code_list("ALL")
        assert all_result is not None
        kospi_result = self.ebest.get_code_list("KOSPI")
        assert kospi_result is not None
        kosdaq_result = self.ebest.get_code_list("KOSDAQ")
        assert kosdaq_result is not None

        try:
            error_result = self.ebest.get_code_list("KOS")
        except:
            error_result = None

        assert error_result is None

        print("result : ", len(all_result), len(kospi_result),
              len(kosdaq_result))

    # def test_get_stock_price_by_code(self):
    #     print(inspect.stack()[0][3])
    #     result = self.ebest.get_stock_price_by_code("005930", "30")
    #     assert result is not None
    #     print(result)

    def tearDown(self):
        self.ebest.logout()
class TestEBest(unittest.TestCase):
    # 하나의 테스트 케이스가 실행되기 전에는 setUp 메서드가 호출되고,
    # 테스트 케이스가 수행된 이후에는 tearDown 메서드가 호출.
    def setUp(self):
        # EBest 클래스의 인스턴스(self.ebest) 생성
        self.ebest = EBest("DEMO")
        self.ebest.login()

    def tearDown(self):
        self.ebest.logout()
class TestEBest(unittest.TestCase):
    def setUp(self):
        print("setUp")
        self.ebest = EBest("DEMO")
        self.ebest.login()

    def tearDown(self):
        print("tearDown")
        self.ebest.logout()

    """
    def test_get_code_list(self):
        print(inspect.stack()[0][3])
        all_result = self.ebest.get_code_list("ALL")
        assert all_result is not None
        kosdaq_result = self.ebest.get_code_list("KOSDAQ")
        assert kosdaq_result is not None
        kospi_result = self.ebest.get_code_list("KOSPI")
        assert kospi_result is not None
        try :
            error_result = self.ebest.get_code_list("KOS")
        except :
            error_result = None
        assert error_result is None
        print("result:", len(all_result), len(kosdaq_result), len(kospi_result))
    """

    def test_get_stock_price_list_by_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_stock_price_by_code("005930", "2")
        assert result is not None
        print(result)

    def test_get_credit_trend_by_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_credit_trend_by_code("005930", "20201001")
        assert result is not None
        print(result)

    def test_get_short_trend_by_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_short_trend_by_code("005930",
                                                    sdate="20200901",
                                                    edate="20200930")
        assert result is not None
        print(result)

    def test_get_agent_trend_by_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_agent_trend_by_code("005930",
                                                    fromdt="20200901",
                                                    todt="20200930")
        assert result is not None
        print(result)
Exemple #5
0
def collect_stock_info():
    ebest = EBest("DEMO")
    mongodb = MongoDBHandler()
    ebest.login()

    code_list = mongodb.find_item({}, "stocklab_ace", "code_info")
    target_code = set([item["단축코드"] for item in code_list])
    today = datetime.today().strftime("%Y%m%d")
    print(today)

    collect_list = mongodb.find_item({"날짜": today}, "stocklab_ace", "price_info") \
        .distinct("code")
    for col in collect_list:
        target_code.remove(col)

    for code in target_code:
        time.sleep(1)
        print("code:", code)
        """
        result_price = ebest.get_stock_price_by_code(code, "1")
        if len(result_price) > 0:
            print(result_price)
            mongodb.insert_item_many(result_price, "stocklab_ace", "price_info")
        
        
        result_credit = ebest.get_credit_trend_by_code(code, today)
        if len(result_credit) > 0:
            mongodb.insert_item_many(result_credit, "stocklab_ace", "credit_info")
        """
        result_short = ebest.get_short_trend_by_code(code,
                                                     sdate=today, edate=today)
        if len(result_short) > 0:
            mongodb.insert_item_many(result_short, "stocklab_ace", "short_info")

        result_agent = ebest.get_agent_trend_by_code(code,
                                                     fromdt=today, todt=today)
        if len(result_agent) > 0:
            mongodb.insert_item_many(result_agent, "stocklab_ace", "agent_info")
        #
        ebest.logout()
Exemple #6
0
class TestEBest(unittest.TestCase):
    def setUp(self):
        print("setUp")
        self.ebest = EBest("DEMO")
        self.ebest.login()

    def tearDown(self):
        self.ebest.logout()

    def test_get_price_n_min_by_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_price_n_min_by_code("20200303", "180640")
        assert result
        print(result)

    def test_get_price_n_min_by_code_tick(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_price_n_min_by_code("20200303", "005930", 0)
        assert result
        print(result)

    """
class TestEBest(unittest.TestCase):
    def setUp(self):
        self.ebest = EBest("DEMO")
        self.ebest.login()

    """
    def test_get_code_list(self):
        print(inspect.stack()[0][3]) # 실행하는 메서드의 이름 출력
        all_result = self.ebest.get_code_list("ALL")
        assert all_result is not None
        kosdaq_result = self.ebest.get_code_list("KOSDAQ")
        assert kosdaq_result is not None
        kospi_result = self.ebest.get_code_list("KOSPI")
        assert kospi_result is not None
        try:
            error_result = self.ebest.get_code_list("KOS")
        except:
            error_result = None
        assert error_result is None
        print("result : ", len(all_result), len(kosdaq_result), len(kospi_result))
        
    def test_get_stock_price_list_by_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_stock_price_by_code("005930", "2") # 삼성전자(005930)의 최근 2일 치 데이터를 조회
        assert result is not None
        print(result)
        
    def test_get_credit_trend_by_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_credit_trend_by_code("005930", "20190304")
        assert result is not None
        print(result)

    def test_get_short_trend_by_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_short_trend_by_code("005930", sdate="20190304", edate="20190304")
        assert result is not None
        print(result)

    def test_get_agent_trend_by_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_agent_trend_by_code("005930", fromdt="20190304", todt="20190304")
        assert result is not None
        print(result)
        
    def test_get_account_info(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_account_info()
        assert result
        print(result)
        
    def test_get_account_stock_info(self):
        result = self.ebest.get_account_stock_info()
        assert result is not None
        print(result)
        
    def test_order_stock(self):
        print(inspect.stack()[0][3])
        result = self.ebest.order_stock("005930", "2", "46000", "2", "00")
        assert result
        print(result)
        
    def test_order_cancel(self):
        print(inspect.stack()[0][3])
        result = self.ebest.order_cancel("29515", "A005930", "2")
        assert result
        print(result)
        
    def test_order_check(self):
        print(inspect.stack()[0][3])
        result = self.ebest.order_check("29515")
        assert result
        print(result)
        
    def test_get_current_call_price_by_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_current_call_price_by_code("005930")
        assert result
        print(result)
        
    def test_get_price_n_min_by_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_price_n_min_by_code("20200501", "180640")
        assert result
        print(result)

    def test_get_price_n_min_by_code_tick(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_price_n_min_by_code("20200501", "005930", 0)
        assert result
        print(result)
     """

    def tearDown(self):
        self.ebest.logout()
Exemple #8
0
class TestEBest(unittest.TestCase):
    def setUp(self):
        self.ebest = EBest("DEMO")
        self.ebest.login()

    def tearDown(self):
        self.ebest.logout()

    """
    def test_get_code_list(self):
        print(inspect.stack()[0][3])
        all_result = self.ebest.get_code_list("ALL")
        assert all_result is not None
        kosdaq_result = self.ebest.get_code_list("KOSDAQ")
        assert kosdaq_result is not None
        kospi_result = self.ebest.get_code_list("KOSPI")
        assert kospi_result is not None
        try:
            error_result = self.ebest.get_code_list("KOS")
        except:
            error_result = None
        assert error_result is None
        print("result:", len(all_result), len(kosdaq_result), len(kospi_result))

    def test_get_stock_price_by_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_stock_price_by_code("005930","2")
        assert result is not None
        print(result)

    def test_agent_account_info(self):
        result = self.ebest.get_account_info()
        assert result is not None
        print(result)

    def test_agent_account_stock_info(self):
        result = self.ebest.get_accout_stock_info()
        assert result is not None
        print(result)


    def test_order_stock(self):
        print(inspect.stack() [0][3])
        result = self.ebest.order_stock("005930", "2", "48000", "2", "00")
        assert result
        print(result)

    def test_order_cancel(self):
        print(inspect.stack()[0][3])
        result = self.ebest.order_cancel("32957", "A005930", "1")
        assert result
        print(result)

    def test_order_check(self):
        print(inspect.stack()[0][3])
        result = self.ebest.order_check("32957")
        assert result
        print(result)

    def test_get_current_call_price_by_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_current_call_price_by_code("005930")
        assert result
        print(result)

    def test_get_price_n_min_by_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_price_n_min_by_code("20190412", "180640")
        assert result
        print(result)
    """
    """
class TestEbest(unittest.TestCase):
    def setUp(self):
        self.ebest = EBest("DEMO")
        self.ebest.login()

    def test_get_current_call_price_by_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_current_call_price_by_code("005930")
        assert result
        print(result)

    # def test_get_code_list(self):
    #     print(inspect.stack()[0][3])
    #     all_result = self.ebest.get_code_list("ALL")
    #     assert all_result is not None
    #     kosdaq_result = self.ebest.get_code_list("KOSDAQ")
    #     assert kosdaq_result is not None
    #     kospi_result = self.ebest.get_code_list("KOSPI")
    #     assert kospi_result is not None
    #     try:
    #         error_result = self.ebest.get_code_list("KOS")
    #     except:
    #         error_result = None
    #     assert error_result is None
    #     print("result:",len(all_result),len(kosdaq_result),len(kospi_result))

    def test_get_stock_price_list_by_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_stock_price_by_code("005930","2")
        assert result is not None
        print(result)

    def test_get_credit_trend_by_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_credit_trend_by_code("005930","20190719")
        assert result is not None
        print(result)

    def test_get_agent_trend_by_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_agent_trend_by_code("005930", fromdt="20200630",todt="20200719")
        assert result is not None
        print(result)

    def test_get_short_trend_by_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_short_trend_by_code("005930", sdate="20200630",edate="20200719")
        assert result is not None
        print(result)

    def test_get_account_info(self):
        result = self.ebest.get_account_info()
        assert result is not None
        print(result)

    def test_get_account_stock_info(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_account_stock_info()
        assert result
        print(result)

    def test_order_stock(self):
        print(inspect.stack()[0][3])
        result = self.ebest.order_stock("005930", "2", "46000", "2", "00")
        assert result
        print(result)
        #code = result[0]["ShtnIsuNo"]
        #order_no = result[0]["OrdNo"]
        #print(code, order_no)
        #time.sleep(1)
        #result1 = self.ebest.get_order_check("005930", order_no)
        #print(result1)

    def test_order_cancel(self):
        print(inspect.stack()[0][3])
        result = self.ebest.order_cancel("22250", "A005930", "2")
        assert result
        print(result)

    def test_order_check(self):
        print(inspect.stack()[0][3])
        result = self.ebest.order_check("22187")
        assert result
        print(result)

    def test_order_check2(self):
        print(inspect.stack()[0][3])
        result = self.ebest.order_check2("20200721","A033530","22187")
        assert result
        print(result)

    def tearDown(self):
        self.ebest.logout()
class TestEBest(unittest.TestCase):
	def setUp(self):
		self.ebest = EBest("DEMO")
		self.ebest.login()

	def tearDown(self):
		self.ebest.logout()

	def test_get_code_list(self):
		print(inspect.stack()[0][3])
		all_result = self.ebest.get_code_list("ALL")
		assert all_result is not None
		kosdaq_result = self.ebest.get_code_list("KOSDAQ")
		assert kosdaq_result is not None
		kospi_result= self.ebest.get_code_list("KOSPI")
		assert kospi_result is not None
		try: 
			error_result = self.ebest.get_code_list("KOS")
		except:
			error_result =None
		assert error_result is None
		print(len(all_result), len(kosdaq_result), len(kospi_result))

	def test_get_stock_price_by_code(self):
		print(inspect.stack()[0][3])
		result = self.ebest.get_stock_price_by_code("005930", "2")
		assert result is not None
		print(result)

	def test_get_credit_trend_by_code(self):
		print(inspect.stack()[0][3])
		result = self.ebest.get_credit_trend_by_code("005930", "20190304")
		assert result is not None
		print(result)

	def test_get_short_trend_by_code(self):
		print(inspect.stack()[0][3])
		result = self.ebest.get_short_trend_by_code("005930", sdate="20190304", edate="20190304")
		assert result is not None
		print(result)

	def test_get_agent_trend_by_code(self):
		print(inspect.stack()[0][3])
		result = self.ebest.get_agent_trend_by_code("005930", fromdt="20190304", todt="20190304")
		assert result is not None
		print(result)

	def test_get_account_info(self):
		print(inspect.stack()[0][3])
		result = self.ebest.get_account_info()
		assert result
		print(result)

	def test_order_stock(self):
		print(inspect.stack()[0][3])
		result = self.ebest.order_stock("005930", "2", "46000", "2", "00")
		assert result
		print(result)
        #code = result[0]["ShtnIsuNo"]
        #order_no = result[0]["OrdNo"]
        #print(code, order_no)
        #time.sleep(1)
        #result1 = self.ebest.get_order_check("005930", order_no)
        #print(result1)
		

	
	def test_get_current_call_price_by_code(self):
		print(inspect.stack()[0][3])
		result = self.ebest.get_current_call_price_by_code("005930")
		assert result
		print(result)

	def test_order_cancel(self):
		print(inspect.stack()[0][3])
		result = self.ebest.order_cancel("15853", "A005930", "2")
		assert result
		print(result)

	def test_order_check(self):
		print(inspect.stack()[0][3])
		result = self.ebest.order_check("15853")
		assert result
		print(result)

	def test_get_price_n_min_by_code(self):
		print(inspect.stack()[0][3])
		result = self.ebest.get_price_n_min_by_code("20190412", "180640")
		assert result
		print(result)
	
	def test_get_price_n_min_by_code_tick(self):
		print(inspect.stack()[0][3])
		result = self.ebest.get_price_n_min_by_code("20190412", "005930", 0)
		assert result
		print(result)
Exemple #11
0
class TestEbest(unittest.TestCase):
    def setUp(self):
        self.ebest = EBest("DEMO")
        self.ebest.login()

    def test_get_current_call_price_by_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_current_call_price_by_code("005930")
        assert result
        print(result)


    """
    def test_get_stock_price_by_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_stock_price_by_code("005930", "30")
        assert result is not None
        print(result)
    def testLogin(self):
        print(inspect.stack()[0][3])
        self.ebest.login()
        assert self.ebest.xa_session_client.login_state == 1

    def test_get_code_list(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_code_list("ALL")
        assert result is not None
        print(len(result))

    def test_get_stock_price_by_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_stock_price_by_code("005930", "2")
        assert result is not None
        print(result)

    def test_get_credit_trend_by_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_credit_trend_by_code("005930", "20190304")
        assert result is not None
        print(result)

    def test_get_short_trend_by_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_short_trend_by_code("005930", sdate="20190304", edate="20190304")
        assert result is not None
        print(result)

    def test_get_agent_trend_by_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_agent_trend_by_code("005930", fromdt="20190304", todt="20190304")
        assert result is not None
        print(result)

    def test_order_stock(self):
        print(inspect.stack()[0][3])
        result = self.ebest.order_stock("005930", "2", "46000", "2", "00")
        assert result
        print(result)
        #code = result[0]["ShtnIsuNo"]
        #order_no = result[0]["OrdNo"]
        #print(code, order_no)
        #time.sleep(1)
        #result1 = self.ebest.get_order_check("005930", order_no)
        #print(result1)



    def test_order_cancel(self):
        print(inspect.stack()[0][3])
        result = self.ebest.order_cancel("29515", "A005930", "2")
        assert result
        print(result)


    def test_get_price_n_min_by_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_price_n_min_by_code("20190412", "180640")
        assert result
        print(result)
    def test_get_price_n_min_by_code_tick(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_price_n_min_by_code("20190412", "005930", 0)
        assert result
        print(result)
    def test_get_account_stock_info(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_account_stock_info()
        assert result
        print(result)

    def test_get_account_info(self):
        print(inspect.stack()[0][3])
        result = self.ebest.get_account_info()
        assert result
        print(result)
    def test_real_code(self):
        print(inspect.stack()[0][3])
        result = self.ebest._execute_real("005930")
        print(result)

    def test_order_check(self):
        print(inspect.stack()[0][3])
        result = self.ebest.order_check("29515")
        assert result
        print(result)

    def test_get_theme_by_code(self):
        time.sleep(1)
        print(inspect.stack()[0][3]) 
        result = self.ebest.get_theme_by_code("078020")
        assert result is not None
        print(len(result))

    def test_get_theme_list(self):
        time.sleep(1)
        print(inspect.stack()[0][3]) 
        result = self.ebest.get_theme_list()
        assert result is not None
        print(result)

    def test_get_category_list(self):
        time.sleep(1)
        print(inspect.stack()[0][3]) 
        result = self.ebest.get_category_list()
        assert result is not None
        print(len(result))

    def test_price_by_category(self):
        result = self.ebest.get_price_by_category("101")
        assert result is not None
        print(len(result))

    def test_price_by_theme(self):
        result = self.ebest.get_price_by_theme("0403")
        assert result is not None
        print(len(result))


    def test_short_trend_by_code(self):
        result = self.ebest.get_short_trend_by_code("0403", sdate="20181201", edate="20181203")
        assert result is not None
        print(len(result))

    def test_get_event_by_code(self):
        result = self.ebest.get_event_by_code("0403", date="20181201")
        assert result is not None
        print(len(result))

    def test_get_trade_history(self):
        result = self.ebest.get_trade_history("10")
        assert result is not None
        print(result)

    def test_get_account_info(self):
        result = self.ebest.get_account_info()
        assert result is not None
        print(result)

    def test_get_account_stock_info(self):
        result = self.ebest.get_account_stock_info()
        assert result is not None
        print(result)
    """

    def tearDown(self):
        self.ebest.logout()