bellmanford
Bellman Ford Graph Execution.
With an initialized networkx DiGraph DAG using our real time ticker data, execute Bellman Ford Optimizationto find most profitable trade path by finding the biggest negative weights in price and volume.
- class bellmanford.NegativeWeightDepthFinder(graph: networkx.classes.graph.Graph)
Negative Weight Depth Finder.
- bellman_ford(source='BTC', unique_paths=True)
Find arbitrage opportunities in self graph and yields them.
- Parameters
source – A node (currency) in self.graph. Opportunities will be yielded only if they are “reachable” from source. Reachable means that a series of trades can be executed to buy one of the currencies in the opportunity. For the most part, it does not matter what the value of source is, because typically any currency can be reached from any other via only a few trades.
unique_paths – If True, each opportunity is not yielded more than once
- Returns
a generator of profitable (negatively-weighted) arbitrage paths in self.graph
- distance_to
- graph
- initialize(source)
Initialize nodes.
- predecessor_to
- relax(edge)
Relax edges.
- reset_all_but_graph()
Call this to look for opportunities after updating the graph.
- seen_nodes
- class bellmanford.NegativeWeightFinder(graph: networkx.classes.graph.Graph)
Negative Weight Finder.
- Variables
~NegativeWeightFinder.graph – the Graph
~NegativeWeightFinder.predecessor_to – The node that came before the new one created
~NegativeWeightFinder.distance_to – the distance to the closest node
~NegativeWeightFinder.seen_nodes – the nodes that it got along the way of the path
- bellman_ford(source='BTC', unique_paths=True)
Find arbitrage opportunities in self graph and yields them.
- Parameters
source – A node (currency) in self.graph. Opportunities will be yielded only if they are “reachable” from source. Reachable means that a series of trades can be executed to buy one of the currencies in the opportunity. For the most part, it does not matter what the value of source is, because typically any currency can be reached from any other via only a few trades.
unique_paths – If True, each opportunity is not yielded more than once
- Returns
a generator of profitable (negatively-weighted) arbitrage paths in self.graph
- distance_to
- graph
- initialize(source)
Initialize nodes.
- predecessor_to
- relax(edge)
Relax edges.
- reset_all_but_graph()
Call this to look for opportunities after updating the graph.
- seen_nodes
- bellmanford.bellman_ford_exec(graph, source='BTC', unique_paths=True, depth=False)
Look at the docstring of the bellman_ford method in the NegativeWeightFinder class.
(This is a static wrapper function.) If depth is true, yields all negatively weighted paths (accounting for depth) when starting with a weight of starting_amount.
- bellmanford.draw_graph_to_png(graph, to_file: str)
Draw graph to png.
- bellmanford.last_index_in_list(li: list, element)
- bellmanford.load_exchange_graph(exchange, dataframe=None, fees=False, depth=False, log=False) networkx.classes.digraph.DiGraph
Return a networkx DiGraph populated with the current ask and bid prices for each market in graph.
(represented by edges). If depth, also adds an attribute ‘depth’ to each edge which represents the current volume of orders available at the price represented by the ‘weight’ attribute of each edge.
- bellmanford.print_profit_opportunity_for_path_store_db(graph, path, round_to=8, depth=False, starting_amount=100)
Print profit opportunity for graph path.