Ejemplo n.º 1
0
    def update_bal_seq_end_by_recent_bal_init_mode(self):

        rough_exhaust_divider = self.EXHAUST_CTRL_DIVISION
        Global.write_balance_seq_end_to_ini(
            krw_seq_end=(self.mm1_krw_bal + self.mm2_krw_bal) /
            rough_exhaust_divider,
            coin_seq_end=(self.mm1_coin_bal + self.mm2_coin_bal) /
            rough_exhaust_divider)
Ejemplo n.º 2
0
    def update_bal_seq_end_by_recent_bal_and_exhaust_ctrl(self):

        # update exhaust_ctrl_currency
        trade_strategy = self.update_exhaust_ctrl_target_currency()

        # update exhaust_ctrl_stage
        self.update_exhaust_stage_and_iyo_config()

        # evaluate current exhaust rate and decide whether to boost or inhibit
        current_exhaust_rate = 1 - (self.cur_exhaust_ctrl_currency_bal /
                                    self.init_exhaust_ctrl_currency_bal)

        if current_exhaust_rate <= self.cur_exhaust_ctrl_stage / self.EXHAUST_CTRL_DIVISION:
            exhaust_rate_divider = self.EXHAUST_CTRL_DIVISION / self.EXHAUST_CTRL_BOOSTER
        else:
            exhaust_rate_divider = self.EXHAUST_CTRL_DIVISION / self.EXHAUST_CTRL_INHIBITOR

        # finally, create seq with initial bal and evaluated divider
        latest_rev_ledger = self.streamer_db["revenue_ledger"].find_one(
            sort=[('_id', pymongo.DESCENDING)])
        if trade_strategy == "new":
            current_krw_be_traded = latest_rev_ledger["current_bal"]["krw"][
                "mm1"]
            current_coin_be_traded = latest_rev_ledger["current_bal"]["coin"][
                "mm2"]

        elif trade_strategy == "rev":
            current_krw_be_traded = latest_rev_ledger["current_bal"]["krw"][
                "mm2"]
            current_coin_be_traded = latest_rev_ledger["current_bal"]["coin"][
                "mm1"]
        else:
            raise Exception(
                "Invalid type of trade strategy injected.. should be one of NEW or REV"
            )

        krw_seq_end = current_krw_be_traded / exhaust_rate_divider
        coin_seq_end = current_coin_be_traded / exhaust_rate_divider

        # update Balance seq end accordingly
        Global.write_balance_seq_end_to_ini(krw_seq_end=krw_seq_end,
                                            coin_seq_end=coin_seq_end)

        # log its result in order to analyze deeper
        logging.warning("\n========= [EXHAUSTION INFO Report] =========")
        logging.warning("Current Exhst rate: %.4f" % current_exhaust_rate)
        logging.warning("Current Exhst Ctrl Stage: %d" %
                        self.cur_exhaust_ctrl_stage)
        logging.warning("[KRW] seq end: %.5f" % krw_seq_end)
        logging.warning("[%s] seq end: %.5f\n" %
                        (self.target_currency.upper(), coin_seq_end))