Ejemplo n.º 1
0
    def __init__(self, log):
        WookLog.custom_init(self, log)

        self.leverage = None
        self.balance_item = None
        self.broker = None
        self.signal = None
        self.orders = dict()
        self.log = log

        self.is_running = False
        self.capital = 0
        self.interval = 0
        self.loss_cut = 0
        self.start_time_text = ''
        self.start_time = 0
        self.start_price = 0
        self.reference_price = 0
        self.buy_limit = 0
        self.loss_limit = 0
        self.sell_off_ordered = False

        self.previous_situation = ''
        self.previous_msg = ()
Ejemplo n.º 2
0
    def __init__(self, trader, log):
        WookLog.custom_init(self, log)
        self.trader = trader
        self.log = log
        self.broker = None

        self.is_running = False
        self.sell_off_ordered = False
        self.settle_up_in_progress = False
        self.finish_up_in_progress = False
        self.open_orders = 0
        self.open_correct_orders = 0
        self.open_cancel_orders = 0
        self.open_purchase_correct_orders = 0
        self.open_purchase_cancel_orders = 0
        self.open_sale_correct_orders = 0
        self.open_sale_cancel_orders = 0

        self.previous_situation = ''
        self.previous_msg = ()

        self.draw_chart = ChartDrawer(self.display_chart)
        self.timer = QTimer()
        self.timer.setInterval(60000)
        self.timer.timeout.connect(self.on_every_minute)
        self.chart_locator = list()
        self.chart_formatter = list()
        self.interval_prices = list()
        self.loss_cut_prices = list()
        self.top_price = 0
        self.bottom_price = 0
        self.chart_scope = 90

        self.items = dict()
        self.orders = dict()
        self.episode_purchase = Episode()
        self.episode_sale = Episode()
        self.purchase_episode_shifted = False
        self.sale_episode_shifted = False
        self.episode_purchase_number = ''
        self.episode_sale_number = ''
        self.episode_count = 0
        self.episode_amount = 0

        self.capital = 0
        self.interval = 0
        self.loss_cut = 0
        self.shift_interval = 0
        self.reference_price = 0
        self.buy_limit = 0
        self.loss_limit = 0
        self.minimum_transaction_amount = 0
        self.start_time_text = ''
        self.start_comment = ''
        self.start_time = 0
        self.start_price = 0
        self.total_profit = 0
        self.total_fee = 0
        self.net_profit = 0
        self.fee = 0
        self.fee_ratio = 0.0
        self.tax_ratio = 0.0
Ejemplo n.º 3
0
    def __init__(self, trader, log, key):
        super().__init__('KHOPENAPI.KHOpenAPICtrl.1')
        WookLog.custom_init(self, log)
        WookUtil.__init__(self)

        # For Signal
        self.trader = trader

        # Password
        wc = WookCipher(key)
        wc.decrypt_data()
        self.login_id = wc.login_id
        self.login_password = wc.login_password
        self.account_password = wc.account_password
        self.certificate_password = wc.certificate_password

        # Eventloop
        self.login_event_loop = QEventLoop()
        self.event_loop = QEventLoop()
        self.timer_event_loop = QEventLoop()
        self.wook_timer = WookTimer(self.timer_event_loop)

        # Chart
        self.chart_prices = list()
        self.chart_item_code = ''
        self.is_running_chart = False

        # Deposit
        self.account_list = None
        self.account_number = 0
        self.deposit = 0
        self.withdrawable_money = 0
        self.orderable_money = 0

        # Items and Orders
        self.portfolio = dict()
        self.monitoring_items = dict()
        self.balance = dict()
        self.open_orders = dict()
        self.order_history = dict()
        self.previous_order = Order()

        # Pending order
        self.pending_order = None
        self.cancel_confirmed = False
        self.cancel_order_number = 0

        # For debug
        self.order_position = ''
        self.order_variables = None

        # Request limit
        self.inquiry_count = 0
        self.previous_time = 0.0
        self.reference_time = Queue()
        self.reference_time_interval_limit = 20
        self.consecutive_interval_limit = 0.25
        self.request_time = 0
        self.request_interval_limit = 0.5
        self.request_block_time_limit = 5
        self.request_block_size = 10
        self.request_count = 0
        self.request_count_threshold = 90
        self.request_count_interval = 60
        self.request_count_waiting = 30

        # Fee and Tax
        # self.fee_ratio = 0.0035
        self.fee_ratio = 0.00015
        self.tax_ratio = 0.0023
        self.futures_fee_ratio = 0.00003
        self.futures_tax_ratio = 0.0

        # Screen numbers
        self.screen_account = '0010'
        self.screen_open_order = '0020'
        self.screen_operation_state = '0040'
        self.screen_portfolio = '0060'
        self.screen_send_order = '0080'
        self.screen_stock_price = '0120'
        self.screen_futures_stock_price = '0140'
        self.screen_test = '9999'
Ejemplo n.º 4
0
 def set_log(self, log):
     WookLog.custom_init(self, log)
Ejemplo n.º 5
0
    def __init__(self, log, key):
        super().__init__('KHOPENAPI.KHOpenAPICtrl.1')
        WookLog.custom_init(self, log)
        WookUtil.__init__(self)

        # Password
        wc = WookCipher(key)
        wc.decrypt_data()
        self.login_id = wc.login_id
        self.login_password = wc.login_password
        self.account_password = wc.account_password
        self.certificate_password = wc.certificate_password

        # Eventloop
        self.login_event_loop = QEventLoop()
        self.event_loop = QEventLoop()
        self.timer_event_loop = QEventLoop()
        self.wook_timer = WookTimer(self.timer_event_loop)

        # Chart
        self.draw_chart = ChartDrawer()
        self.chart_prices = list()
        self.min_timer = QTimer()
        self.min_timer.setInterval(60000)
        self.min_timer.timeout.connect(self.on_every_min)

        # Requesters
        self.deposit_requester = QThread()
        self.moveToThread(self.deposit_requester)
        self.deposit_requester.started.connect(self.request_deposit_info)
        self.portfolio_requester = QThread()
        self.moveToThread(self.portfolio_requester)
        self.portfolio_requester.started.connect(self.request_portfolio_info)
        self.order_history_requester = QThread()
        self.moveToThread(self.order_history_requester)
        self.order_history_requester.started.connect(self.request_order_history)

        self.request_time = 0
        self.request_interval_limit = 0.5
        self.order_position = ''

        # Signals
        self.log = None
        self.signal = None
        self.status = None

        # Deposit
        self.account_list = None
        self.account_number = 0
        self.deposit = 0
        self.withdrawable_money = 0
        self.orderable_money = 0

        # Items and Orders
        self.portfolio = dict()
        self.monitoring_items = dict()
        self.balance = dict()
        self.open_orders = dict()
        self.order_history = dict()
        self.algorithm = None

        # Pending order
        self.pending_order = None
        self.cancel_confirmed = False
        self.cancel_order_number = 0

        # Request limit
        self.inquiry_count = 0
        self.previous_time = 0.0
        self.reference_time = Queue()
        self.reference_time_interval_limit = 20
        self.consecutive_interval_limit = 0.25
        self.request_block_time_limit = 5
        self.request_block_size = 10
        self.request_count = 0
        self.request_count_threshold = 90
        self.request_count_interval = 60
        self.request_count_waiting = 30

        # Fee and Tax
        self.fee_ratio = 0.0035
        self.tax_ratio = 0.0023

        # Screen numbers
        self.screen_account = '0010'
        self.screen_open_order = '0020'
        self.screen_operation_state = '0040'
        self.screen_portfolio = '0060'
        self.screen_send_order = '0080'
        self.screen_stock_price = '0120'
        self.screen_futures_stock_price = '0140'
        self.screen_test = '9999'