예제 #1
0
    def iyo_result_to_mongo_db(coin_name: str, start_time: int, end_time: int):
        Global.configure_default_root_logging(should_log_to_file=False,
                                              log_level=logging.CRITICAL)
        SharedMongoClient.initialize(should_use_localhost_db=True)
        db_client = SharedMongoClient.instance()

        # convert epoch time to local_time and log
        local_st = Global.convert_epoch_to_local_datetime(start_time,
                                                          timezone="kr")
        local_et = Global.convert_epoch_to_local_datetime(end_time,
                                                          timezone="kr")

        # create combination of coin that is injected by validating if the exchange has that coin
        rfab_combi_list = Global.get_rfab_combination_tuples(coin_name)

        for _combi in rfab_combi_list:
            logging.critical(
                "[%s-%s-%s] IYO conducting -> start_time: %s, end_time: %s" %
                (coin_name.upper(), str(_combi[0]).upper(), str(
                    _combi[1]).upper(), local_st, local_et))

            # draw iyo_config for bal & factor_setting
            iyo_config = Global.read_iyo_setting_config(coin_name)

            settings = TradeSettingConfig.get_settings(
                mm1_name=_combi[0],
                mm2_name=_combi[1],
                target_currency=coin_name,
                start_time=start_time,
                end_time=end_time,
                division=iyo_config["division"],
                depth=iyo_config["depth"],
                consecution_time=iyo_config["consecution_time"],
                is_virtual_mm=True)
            # todo
            bal_factor_settings = TradeSettingConfig.get_bal_fact_settings(
                iyo_config["krw_seq_end"], iyo_config["coin_seq_end"])

            factor_settings = TradeSettingConfig.get_factor_settings(
                _combi[0], _combi[1], coin_name,
                iyo_config["max_trade_coin_end"], iyo_config["threshold_end"],
                iyo_config["appx_unit_coin_price"])

            try:
                iyo_result = IntegratedYieldOptimizer.run(
                    settings, bal_factor_settings, factor_settings)

                # finally save to mongoDB
                if len(iyo_result) > 0:
                    db_client["statistics"]["iyo"].insert_many(iyo_result)
                else:
                    logging.critical(
                        "There was no oppty!! Skipping to next combination!")
                    continue

            except TypeError as e:
                Global.send_to_slack_channel(
                    Global.SLACK_BOT_STATUS_URL,
                    "Something went wrong in IYO Schduler! >> %s" % e)
                pass
예제 #2
0
def main(coin_name: str, mm1_name: str, mm2_name: str):
    Global.configure_default_root_logging(should_log_to_file=False,
                                          log_level=logging.INFO)
    SharedMongoClient.initialize(should_use_localhost_db=False)
    start_time = Global.convert_local_datetime_to_epoch("2018.08.20 09:00:00",
                                                        timezone="kr")
    end_time = Global.convert_local_datetime_to_epoch("2018.08.20 13:00:00",
                                                      timezone="kr")

    iyo_config = Global.read_iyo_setting_config(coin_name)

    # set settings // fix manually if you need to
    settings = TradeSettingConfig.get_settings(
        mm1_name=mm1_name,
        mm2_name=mm2_name,
        target_currency=coin_name,
        start_time=start_time,
        end_time=end_time,
        division=iyo_config["division"],
        depth=iyo_config["depth"],
        consecution_time=iyo_config["consecution_time"],
        is_virtual_mm=True)

    bal_factor_settings = TradeSettingConfig.get_bal_fact_settings(
        iyo_config["krw_seq_end"], iyo_config["coin_seq_end"])

    ibo_result = InitialBalanceOptimizer.run(settings, bal_factor_settings)
    print(ibo_result)
def main(target_currency: str, mm1_name: str, mm2_name: str, st_local: str,
         et_local: str):
    Global.configure_default_root_logging(should_log_to_file=False)
    SharedMongoClient.initialize(should_use_localhost_db=False)

    start_time = Global.convert_local_datetime_to_epoch(st_local,
                                                        timezone="kr")
    end_time = Global.convert_local_datetime_to_epoch(et_local, timezone="kr")

    mm1_taker_fee = Global.read_market_fee(mm1_name, True)
    mm1_maker_fee = Global.read_market_fee(mm1_name, False)
    mm2_taker_fee = Global.read_market_fee(mm2_name, True)
    mm2_maker_fee = Global.read_market_fee(mm2_name, False)

    mm1_market = getattr(Market, "VIRTUAL_%s" % mm1_name.upper())
    mm2_market = getattr(Market, "VIRTUAL_%s" % mm2_name.upper())

    bal_setting = {
        'mm1': {
            'krw_balance': 0,
            'coin_balance': 0.04475666666666667
        },
        'mm2': {
            'krw_balance': 333333.3333333333,
            'coin_balance': 0.0
        }
    }

    initial_setting_dict = {
        'max_trading_coin': 0.005,
        'min_trading_coin': 0,
        'new': {
            'threshold': 0,
            'factor': 1
        },
        'rev': {
            'threshold': 0,
            'factor': 1
        }
    }

    mm1 = VirtualMarketManager(mm1_market, mm1_taker_fee, mm1_maker_fee,
                               bal_setting["mm1"]["krw_balance"],
                               bal_setting["mm1"]["coin_balance"],
                               target_currency, True)
    mm2 = VirtualMarketManager(mm2_market, mm2_taker_fee, mm2_maker_fee,
                               bal_setting["mm2"]["krw_balance"],
                               bal_setting["mm2"]["coin_balance"],
                               target_currency, True)
    mm1_col = SharedMongoClient.get_target_col(mm1_market, target_currency)
    mm2_col = SharedMongoClient.get_target_col(mm2_market, target_currency)

    mm1_data_cursor, mm2_data_cursor = SharedMongoClient.get_data_from_db(
        mm1_col, mm2_col, start_time, end_time)
    RfabBacktester(mm1, mm2,
                   target_currency).run(mm1_data_cursor,
                                        mm2_data_cursor,
                                        initial_setting_dict,
                                        is_running_in_optimizer=False)
예제 #4
0
def main(target_currency: str, mm1_name: str, mm2_name: str):
    Global.configure_default_root_logging(should_log_to_file=False, log_level=logging.INFO)
    SharedMongoClient.initialize(should_use_localhost_db=True)

    mm1 = Global.get_market_manager(mm1_name)
    mm2 = Global.get_market_manager(mm2_name)

    RiskFreeArbBotV4(target_currency, mm1, mm2, is_test=True).run()
예제 #5
0
    def __init__(self):
        # init root logger
        Global.configure_default_root_logging()
        # set the log level for the schedule
        # in order not to display any extraneous log
        logging.getLogger("schedule").setLevel(logging.CRITICAL)

        # add SIGTERM handler
        signal.signal(signal.SIGTERM, self.handle_sigterm)
def main(target_currency: str, mm1_name: str, mm2_name: str):
    Global.configure_default_root_logging(should_log_to_file=True, log_level=logging.INFO)
    SharedMongoClient.initialize(should_use_localhost_db=True)

    mm1 = Global.get_market_manager(mm1_name)
    mm2 = Global.get_market_manager(mm2_name)

    # run TradeStreamer
    TradeStreamerV2(mm1=mm1, mm2=mm2, target_currency=target_currency, is_test=False).run()
예제 #7
0
def main(target_currency: str, mm1: MarketManager, mm2: MarketManager,
         mm1_name: str, mm2_name: str, mm1_krw_bal: float, mm1_coin_bal: float,
         mm2_krw_bal: float, mm2_coin_bal: float):
    Global.configure_default_root_logging(should_log_to_file=False,
                                          log_level=logging.WARNING)
    SharedMongoClient.initialize(should_use_localhost_db=False)

    trade_streamer = TestTradeStreamer(target_currency, mm1, mm2, mm1_name,
                                       mm2_name, mm1_krw_bal, mm1_coin_bal,
                                       mm2_krw_bal, mm2_coin_bal)

    trade_streamer.real_time_streamer()
예제 #8
0
def main(coin_name: str, mm1_name: str, mm2_name: str, start_time: str,
         end_time: str, slicing_interval: int):
    Global.configure_default_root_logging(should_log_to_file=False,
                                          log_level=logging.INFO)
    SharedMongoClient.initialize(should_use_localhost_db=False)

    logging.warning("Nohup conducting -> start_time: %s, end_time: %s" %
                    (start_time, end_time))
    # Global.send_to_slack_channel("IYO Initiated!! start_time: %s, end_time: %s" % (prev_time, cur_time))

    start_time = Global.convert_local_datetime_to_epoch(start_time,
                                                        timezone="kr")
    end_time = Global.convert_local_datetime_to_epoch(end_time, timezone="kr")

    # draw iyo_config for bal & factor_setting
    iyo_config = Global.read_sliced_iyo_setting_config(coin_name)

    logging.critical(
        "[%s-%s-%s] IYO conducting -> start_time: %s, end_time: %s" %
        (coin_name.upper(), mm1_name.upper(), mm2_name.upper(), start_time,
         end_time))

    # set settings, bal_fact_settings, factor_settings
    settings = TradeSettingConfig.get_settings(
        mm1_name=mm1_name,
        mm2_name=mm2_name,
        target_currency=coin_name,
        start_time=start_time,
        end_time=end_time,
        division=iyo_config["division"],
        depth=iyo_config["depth"],
        consecution_time=iyo_config["consecution_time"],
        is_virtual_mm=True)

    bal_factor_settings = TradeSettingConfig.get_bal_fact_settings(
        iyo_config["krw_seq_end"], iyo_config["coin_seq_end"])

    factor_settings = TradeSettingConfig.get_factor_settings(
        mm1_name, mm2_name, coin_name, iyo_config["max_trade_coin_end"],
        iyo_config["threshold_end"], iyo_config["appx_unit_coin_price"])

    iyo_result = IntegratedYieldOptimizer.run(
        settings,
        bal_factor_settings,
        factor_settings,
        is_stat_appender=False,
        is_slicing_dur=True,
        slicing_interval=slicing_interval)
    logging.critical("Final IYO result: %s" % iyo_result)
    return iyo_result
import logging
from config.global_conf import Global
from config.shared_mongo_client import SharedMongoClient
from optimizer.integrated_yield_optimizer import IYOStatAppender

Global.configure_default_root_logging(should_log_to_file=False, log_level=logging.INFO)
SharedMongoClient.initialize(should_use_localhost_db=True)

start_time = Global.convert_local_datetime_to_epoch("2018.07.24 11:00:00", timezone="kr")
end_time = Global.convert_local_datetime_to_epoch("2018.07.24 12:00:00", timezone="kr")

db_client = SharedMongoClient.instance()
iyo_col = db_client["statistics"]["iyo"]
iyo_cur = iyo_col.find({
    "settings.start_time": {
        "$gte": start_time,
        "$lte": end_time}}).sort([("start_time", 1)])

for iyo_data in iyo_cur:
    logging.critical("Now starting: %s" % Global.convert_epoch_to_local_datetime(iyo_data["settings"]["start_time"]))
    stat_result = IYOStatAppender.run(iyo_data=iyo_data)

    # append this stat dict to the current IYO_data
    db_client["statistics"]["iyo"].update(
        {'_id': iyo_data['_id']}, {
            '$set': {
                'stat': stat_result
            }}, upsert=False, multi=False)

    logging.critical("Appended Stat result to target IYO_data at MongoDB")
예제 #10
0
 def __init__(self):
     Global.configure_default_root_logging(should_log_to_file=True,
                                           log_level=logging.CRITICAL)
     SharedMongoClient.initialize(should_use_localhost_db=True)
     super().__init__()
예제 #11
0
 def run(self):
     Global.configure_default_root_logging()
     self.execute_bollinger(self.v_coinone_mm, self.v_korbit_mm,
                            self.BOLLINGER_TIME_STEP)
def main(coin_name: str, init_time: str, final_time: str):
    Global.configure_default_root_logging(should_log_to_file=False,
                                          log_level=logging.INFO)
    SharedMongoClient.initialize(should_use_localhost_db=False)
    db_client = SharedMongoClient.instance()

    time_list = make_time_list(init_time, final_time)

    prev_time = None
    for cur_time in time_list:
        if prev_time is None:
            prev_time = cur_time
            continue
        logging.warning("Nohup conducting -> start_time: %s, end_time: %s" %
                        (prev_time, cur_time))
        # Global.send_to_slack_channel("IYO Initiated!! start_time: %s, end_time: %s" % (prev_time, cur_time))

        start_time = Global.convert_local_datetime_to_epoch(prev_time,
                                                            timezone="kr")
        end_time = Global.convert_local_datetime_to_epoch(cur_time,
                                                          timezone="kr")

        # draw iyo_config for bal & factor_setting
        iyo_config = Global.read_iyo_setting_config(coin_name)

        # FIXME: 빗썸 등등 거래소 생긴 날부터는 밑에 주석 쓰기
        # rfab_combi_list = Global.get_rfab_combination_list(coin_name)
        rfab_combi_list = list(it.combinations(["okcoin", "coinnest"], 2))
        for _combi in rfab_combi_list:
            logging.critical(
                "[%s-%s-%s] IYO conducting -> start_time: %s, end_time: %s" %
                (coin_name.upper(), str(_combi[0]).upper(), str(
                    _combi[1]).upper(), start_time, end_time))

            # set settings, bal_fact_settings, factor_settings
            settings = TradeSettingConfig.get_settings(
                mm1_name=_combi[0],
                mm2_name=_combi[1],
                target_currency=coin_name,
                start_time=start_time,
                end_time=end_time,
                division=iyo_config["division"],
                depth=iyo_config["depth"],
                consecution_time=iyo_config["consecution_time"],
                is_virtual_mm=True)

            bal_factor_settings = TradeSettingConfig.get_bal_fact_settings(
                iyo_config["krw_seq_end"], iyo_config["coin_seq_end"])

            factor_settings = TradeSettingConfig.get_factor_settings(
                _combi[0], _combi[1], coin_name,
                iyo_config["max_trade_coin_end"], iyo_config["threshold_end"],
                iyo_config["appx_unit_coin_price"])

            iyo_result = IntegratedYieldOptimizer.run(settings,
                                                      bal_factor_settings,
                                                      factor_settings)

            # finally save to mongoDB
            if len(iyo_result) > 0:
                db_client["statistics"]["iyo"].insert_many(iyo_result)
            else:
                logging.critical(
                    "There was no oppty!! Skipping to next combination!")
                continue
            logging.warning("Nohup done, now conducting next time set!!")
            prev_time = cur_time
예제 #13
0
from config.global_conf import Global
from config.shared_mongo_client import SharedMongoClient
from temp.arbbot_ideas.stat_arb_bot import StatArbBot
import logging

Global.configure_default_root_logging(log_level=logging.CRITICAL, should_log_to_file=True)
# SharedMongoClient.COINONE_DB_NAME = "coinone_180402"
# SharedMongoClient.KORBIT_DB_NAME = "korbit_180402"
SharedMongoClient.KORBIT_DB_NAME = "korbit"
SharedMongoClient.COINONE_DB_NAME = "coinone"
SharedMongoClient.initialize(should_use_localhost_db=False)
# start_time = Global.convert_local_datetime_to_epoch("2018.03.25 00:00:00", timezone="kr")
# end_time = Global.convert_local_datetime_to_epoch("2018.03.30 00:00:00", timezone="kr")
start_time = Global.convert_local_datetime_to_epoch("2018.04.06 10:00:00", timezone="kr")
end_time = Global.convert_local_datetime_to_epoch("2018.04.06 22:00:00", timezone="kr")

COIN_UNIT = (0.1,)
TARGET_SPREAD_STACK_HOUR = (18, 21, 24, 27)
Z_SCORE_SIGMA_PROB = (0.9,)

for coin_unit in COIN_UNIT:
    for stack_hour in TARGET_SPREAD_STACK_HOUR:
        for z_prob in Z_SCORE_SIGMA_PROB:
            logging.critical("------------------------------------------------------")
            logging.critical("coin unit: %.2f, stack_hour: %d, z_score: %d%%" % (coin_unit, stack_hour, z_prob * 100))
            StatArbBot.COIN_TRADING_UNIT = coin_unit
            StatArbBot.TARGET_SPREAD_STACK_HOUR = stack_hour
            StatArbBot.Z_SCORE_SIGMA = Global.get_z_score_for_probability(z_prob)
            StatArbBot(should_db_logging=False, is_backtesting=True, start_time=start_time, end_time=end_time).run()
예제 #14
0
from config.global_conf import Global
from config.shared_mongo_client import SharedMongoClient
from temp.arbbot_ideas.stat_arb_bot import StatArbBot

Global.configure_default_root_logging(should_log_to_file=False)
SharedMongoClient.initialize(should_use_localhost_db=False)
StatArbBot(is_backtesting=False).run()
예제 #15
0
def main(mm1: MarketManager, mm2: MarketManager, target_currency: str):
    Global.configure_default_root_logging(should_log_to_file=True,
                                          log_level=logging.WARNING)
    SharedMongoClient.initialize(should_use_localhost_db=True)
    # run TradeStreamer
    TradeStreamer(mm1=mm1, mm2=mm2, target_currency=target_currency).run()
예제 #16
0
import logging
from config.global_conf import Global
from trader.market_manager.okcoin_market_manager import OkcoinMarketManager
from trader.market_manager.bithumb_market_manager import BithumbMarketManager
from config.shared_mongo_client import SharedMongoClient
from temp.arbbot_ideas.risk_free_arb_bot_v3 import RiskFreeArbBotV3

Global.configure_default_root_logging(should_log_to_file=True, log_level=logging.WARNING)
SharedMongoClient.initialize(should_use_localhost_db=True)

RiskFreeArbBotV3(
    target_currency="xrp",
    mm1=BithumbMarketManager(),
    mm2=OkcoinMarketManager(),
    streamer_db=SharedMongoClient.get_streamer_db()
).run()