Exemple #1
0
def testIO():
    f = open('tinyG.txt', 'r')
    tinyG = list(f)
    tinyG = map(lambda x: x.strip(), tinyG)

    G = Arbitrage.WgtGraph()

    for line in tinyG:
        line = line.split()
        G.addEdge(arbitrage.DirectedEdge(line[0], line[1], float(line[2])))

    print G
    res = Arbitrage.WgtDirectedCycle(G)
    for edge in res.cycle():
        print edge
Exemple #2
0
def mainTest(testData):

    G = Arbitrage.makeGraph(testData)

    bf = Arbitrage.BellmanFord(G, G.vertices()[0])

    if bf.hasNegativeCycle():
        result = bf.getCycle()
        print "Start with 100 units {0}".format(result[-1].fromVertex())
        balance = 100
        while result:
            edge = result.pop()
            key = edge.fromVertex() + "_" + edge.toVertex()
            balance = balance * testData[key]
            print "{0} to {1} @ {2} = {3:.2f} {4}".format(
                edge.fromVertex(), edge.toVertex(), testData[key], balance,
                edge.toVertex())
    else:
        print "No arbitrage found"
    print "\n"
Exemple #3
0
def main():
    f = open('./input/arb_convenience.txt','r')
    symbol_list = []
    for i in f.readlines():
        symbol_list.append(i.strip())
    f.close()
    res = {}

    for i in symbol_list:
        f= open(DEMO_DIR + i, 'r')
        changes=[]
        for i2 in f.readlines():
            changes.append(float(i2.strip()))
        res.update({ i: arb.calc_total_changed(changes)})

    data_list = []
    for i in res.keys():
        data_list.append(res[i])
    diviation = arb.calc_standard_deviation(data_list)

    #print(diviation)
    print(res)
    chance = arb.check_arbitrage_chance(res, ALLOWED_DEVIATION, ARBITRAGE_NETCHANGE)
    print(chance)
def mainTest(testData):
        
    G = Arbitrage.makeGraph(testData)
    
    bf = Arbitrage.BellmanFord(G, G.vertices()[0])

    if bf.hasNegativeCycle():
        result = bf.getCycle()
        print "Start with 100 units {0}".format(result[-1].fromVertex())
        balance = 100
        while result:
            edge = result.pop()
            key = edge.fromVertex() + "_" + edge.toVertex()
            balance = balance * testData[key]
            print "{0} to {1} @ {2} = {3:.2f} {4}".format(edge.fromVertex(), edge.toVertex(), testData[key], balance, edge.toVertex())
    else:
        print "No arbitrage found"
    print "\n"
def testDictionaryBuild():
    
    csvReader = Arbitrage.makeFile()
    print Arbitrage.convertToDictionary(csvReader)
def testGraph():
    
    G = Arbitrage.makeGraph(testData)
    print G
Exemple #7
0
def testDictionaryBuild():

    csvReader = Arbitrage.makeFile()
    print Arbitrage.convertToDictionary(csvReader)
Exemple #8
0
def testGraph():

    G = Arbitrage.makeGraph(testData)
    print G