Beispiel #1
0
 def run_condition_trade(self, index: int, realtime_data):
     '''
     매도 매수 조건이 만족될 경우, 거래를 진행시킨다.
     '''
     condition_value, offer = self._check_condition(index, realtime_data)
     if condition_value:
         # 조건 충족
         if offer == OfferStock.BUYING:
             # 매수 조건일 때
             Dao().buy_stock(self.__stock, self.__money)
         else:
             # 매도 조건일 때
             Dao().sell_stock(self.__stock)
Beispiel #2
0
    def filter_list() -> list:
        condition_list = Dao().request_condition_list()

        ready_stock = []

        for condition in condition_list:
            if condition[1] == "fifteen_bottom":
                stock_list: List[Stock] = Dao().request_condition_stock(
                    condition[0], condition[1])
        for stock in stock_list:
            data = Dao().request_candle_data_from_now(stock, CandleUnit.MINUTE,
                                                      30)  #한번만 검색하면됨.
            if data.loc[0].percentage >= 3:
                ready_stock.append(stock)
                Dao().set_buying_price(stock, data.loc[0].open)
        return deepcopy(ready_stock)
Beispiel #3
0
 def attach_condition(self, condition: Condition,
                      offer: OfferStock) -> None:
     '''
     시그널 이벤트 등록
     '''
     # Dao에서 실시간 데이터를 받아올 수 있도록 함.
     Dao().reg_realtime_data(
         self.realtime_data_slot, self.__stock,
         condition.realtime_data_requirement())  # 실시간 슬롯에 등록
     self.__condition_list.append([condition, offer])
Beispiel #4
0
 def condition_test(self, stock: Stock,
                    realtime_data: Dict[RealTimeDataEnum, Any]):
     '''
     Condition 클래스의 condition 메소드를 오버라이드
     '''
     rtde = RealTimeDataEnum
     current_price = realtime_data[rtde.CURRENT_PRICE]
     buying_price = Dao().request_buying_price(stock)
     data = Dao().request_candle_data_from_now(stock, CandleUnit.MINUTE,
                                               30)
     if (((current_price - buying_price) - 1) * 100) > 0.8:
         # 익절
         # Dao().delete_stock()
         return True
     elif data.loc[0].close < buying_price:
         # 손절
         # Dao().delete_stock()
         return True
     return False
Beispiel #5
0
 def condition_test(self, stock: Stock,
                    realtime_data: Dict[RealTimeDataEnum, Any]):
     '''
     Condition 클래스의 condition 메소드를 오버라이드
     만약
     '''
     rtde = RealTimeDataEnum
     current_price = realtime_data[rtde.CURRENT_PRICE]
     buying_price = Dao().request_buying_price(stock)
     if current_price == buying_price:
         # Dao().store_stock(stock)
         return True
     return False
Beispiel #6
0
 def force_selling(self):
     '''
     보유 주식 강제매도
     '''
     Dao().sell_stock(self.__stock)
Beispiel #7
0
 def __init__(self, stock: Stock):
     super().__init__(stock, FifteenBottom.FifteenBottom_BuyingCondition,
                      FifteenBottom.FifteenBottom_SellingCondition, 60,
                      50000)
     self.__dao = Dao()
Beispiel #8
0
 def __init__(self):
     self.__algorithm_runner = AlgoritmRunner()
     Dao().login()
     Dao().set_chejan_data_callback(self.echo)
     Dao().set_server_msg_callback(self.echo)