Exemplo n.º 1
0
    def run(self, strategy, db_name):
        """ run """
        symbol = strategy.config["symbol"]

        db = md.MongoDB(mongo_user, mongo_pwd, db_name, db_url)
        orders = db.find("orders", {"instance_id": self.instance_id})

        self.analyze(symbol, orders)
Exemplo n.º 2
0
    def __init__(self, instance_id, config, db_orders_name=None):
        self.instance_id = instance_id
        self.config = config

        exchange = config["exchange"]
        if exchange == "binance":
            self.kline_column_names = BinanceExchange.get_kline_column_names()
        elif exchange == "okex":
            self.kline_column_names = OkexExchange.get_kline_column_names()

        self.md_db = md.MongoDB(mongo_user, mongo_pwd, exchange, db_url)
        self.td_db = md.MongoDB(mongo_user, mongo_pwd, "xquant", db_url)

        self.value = 100

        if db_orders_name:
            self.db_orders_name = db_orders_name
            self.td_db.ensure_index(db_orders_name, [("instance_id", 1),
                                                     ("symbol", 1)])

        self.can_buy_time = None
Exemplo n.º 3
0
    if not (args.s and args.r and args.k and args.m):
        parser.print_help()
        exit(1)

    start_time, end_time = split_time_range(args.r)

    interval = args.k
    collection = xq.get_kline_collection(args.s, interval)
    td = xq.get_interval_timedelta(interval)
    period = xq.get_interval_seconds(interval)
    tick_time = xq.get_open_time(interval, start_time)
    if tick_time < start_time:
        tick_time = xq.get_open_time(interval, start_time + td)

    db = md.MongoDB(mongo_user, mongo_pwd, args.m, db_url)

    klines = db.find_sort(
        collection, {
            "open_time": {
                "$gte": int(start_time.timestamp()) * 1000,
                "$lt": int(end_time.timestamp()) * 1000
            }
        }, 'open_time', 1)

    i = 0
    miss_count = 0
    print(len(klines))

    period_ms = period * 1000
    for kline in klines:
Exemplo n.º 4
0
    else:
        process_info = process[ret.span()[0]:]
    print(process_info)
    '''
    process_info = ''
    with open(file_name, 'r') as f:
        off = 1800
        f.seek(0, os.SEEK_END)
        f.seek(f.tell() - off, os.SEEK_SET)
        lines = f.readlines()
        for line in lines:
            process_info += (line + "<br>")

    print(process_info)

    db = md.MongoDB(mongo_user, mongo_pwd, db_name, db_url)
    collection = 'orders'

    begin_time = datetime.datetime.now() - datetime.timedelta(days=int(days))

    orders = db.find_sort(
        collection, {
            "instance_id": instance_id,
            "create_time": {
                "$gte": int(begin_time.timestamp())
            }
        }, 'create_time', -1)

    print('orders:', orders)
    for order in orders:
        del order['_id']