Created
July 16, 2012 18:14
-
-
Save saulshanabrook/3124095 to your computer and use it in GitHub Desktop.
django-arbitrage
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Note: this isn't python. It just has some syntax highlighting to make it more readable | |
# First pair is stocks x, y with a difference of z (ex. 60, 80 with a difference of 20) | |
x + z == y # 80 - 20 = 60 | |
z == y - x # 20 = 80 - 60 | |
# Buy smaller (x), sell larger (y) | |
balance == -(x + (100 - y)) # -(60 + (100 - 80)) | |
== -(x + 100 - y) # -(60 + 100 - 80) | |
== -(-(y - x) + 100 ) # -(-(20 - 60) + 100)) | |
== -(-z + 100) # -(-20 + 100) | |
== z - 100 # 20 - 100 | |
# -80 | |
profits == balance + 100 # -80 + 100 | |
== z - 100 + 100 # 20 - 100 + 100 | |
== z # 20 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment