예제 #1
0
def dataType2Sigal(dt):
    price_seps = [50.0,200.0]
    volume_seps = [10,100,400]
    key_transform = {'price' : numberic2SignalFn(float, price_seps),
        'volume' : numberic2SignalFn(int, volume_seps)}
    signals = {}
    for key in key_transform:
        if hasattr(dt, key):
            v = getattr(dt, key)
            signal = "%s%s" % (key, key_transform[key](v))
            signals[signal] = 1
    return signals
예제 #2
0
def dataType2Sigal(dt):
    price_seps = [50.0, 200.0]
    volume_seps = [10, 100, 400]
    key_transform = {
        'price': numberic2SignalFn(float, price_seps),
        'volume': numberic2SignalFn(int, volume_seps)
    }
    signals = {}
    for key in key_transform:
        if hasattr(dt, key):
            v = getattr(dt, key)
            signal = "%s%s" % (key, key_transform[key](v))
            signals[signal] = 1
    return signals
예제 #3
0
def stats_items(iter, fn_conv, name):
    logger.info("Stating %s", name)
    #n2s = numberic2SignalFn(int, [0, 1, 10, 100, 400])
    n2s = numberic2SignalFn(
        int,
        range(21) + range(30, 110, 10) + range(150, 350, 50) +
        range(400, 1200, 200))

    volumes = []
    for i in iter:
        iv = fn_conv(i)
        s = n2s(iv)
        volumes.append(s)

    cs = Series(volumes)
    g = cs.groupby(cs.values).agg(len)
    total = len(volumes)
    sig2prob = {}
    for sig, count in g.iteritems():
        if sig == 0:
            logger.warn("%s sig %s -- %s %s %s", name, sig,
                        count * 1.0 / total, count, total)
            total -= count
        else:
            logger.info("%s sig %s -- %s %s %s", name, sig,
                        count * 1.0 / total, count, total)
            sig2prob[sig] = count * 1.0 / total
    return sig2prob
예제 #4
0
 def __init__(self):
     self.total = 0
     self.matched = 0
     self.shop_matched = 0
     self.item_matched = 0
     self.notmatched_item_exists = 0
     dbs = get_db_engines(**{'dbconnstrs' : FLAGS.xdbconnstrs})
     self.guangdb = dbs[0]
     self.statdb = dbs[1]
     self.timediffs = []
     self.pricediffs = []
     self.volumediffs = []
     self.volumesignal_diffs = []
     self.volume2signal = numberic2SignalFn(int, [1, 10, 100, 400])
def stats_items_dist(iter, fn_conv, name, splitter):
    logger.info("Stating %s", name)
    n2s = numberic2SignalFn(int, splitter.range_sum)

    volumes = []
    for i in iter:
        iv = fn_conv(i)
        s = n2s(iv)
        volumes.append(s)

    cs = Series(volumes)
    g = cs.groupby(cs.values).agg(len)
    total = len(volumes)
    sig2prob = {}
    for sig, count in g.iteritems():
        if sig == 0:
            logger.warn("%s sig %s -- %s %s %s", name, sig, count*1.0/total, count, total)
            total -= count
        else:
            logger.info("%s sig %s -- %s %s %s", name, sig, count*1.0/total, count, total)
            sig2prob[sig] = count*1.0/total
    return sig2prob
예제 #6
0
def stats_items(iter, fn_conv, name):
    logger.info("Stating %s", name)
    #n2s = numberic2SignalFn(int, [0, 1, 10, 100, 400])
    n2s = numberic2SignalFn(int, range(21) + range(30, 110, 10) + range(150,350,50) + range(400,1200,200))

    volumes = []
    for i in iter:
        iv = fn_conv(i)
        s = n2s(iv)
        volumes.append(s)

    cs = Series(volumes)
    g = cs.groupby(cs.values).agg(len)
    total = len(volumes)
    sig2prob = {}
    for sig, count in g.iteritems():
        if sig == 0:
            logger.warn("%s sig %s -- %s %s %s", name, sig, count*1.0/total, count, total)
            total -= count
        else:
            logger.info("%s sig %s -- %s %s %s", name, sig, count*1.0/total, count, total)
            sig2prob[sig] = count*1.0/total
    return sig2prob
예제 #7
0
def stats_items_dist(iter, fn_conv, name, splitter):
    logger.info("Stating %s", name)
    n2s = numberic2SignalFn(int, splitter.range_sum)

    volumes = []
    for i in iter:
        iv = fn_conv(i)
        s = n2s(iv)
        volumes.append(s)

    cs = Series(volumes)
    g = cs.groupby(cs.values).agg(len)
    total = len(volumes)
    sig2prob = {}
    for sig, count in g.iteritems():
        if sig == 0:
            logger.warn("%s sig %s -- %s %s %s", name, sig,
                        count * 1.0 / total, count, total)
            total -= count
        else:
            logger.info("%s sig %s -- %s %s %s", name, sig,
                        count * 1.0 / total, count, total)
            sig2prob[sig] = count * 1.0 / total
    return sig2prob