Skip to content

Instantly share code, notes, and snippets.

@saulshanabrook
Created July 16, 2012 18:14
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save saulshanabrook/3124095 to your computer and use it in GitHub Desktop.
Save saulshanabrook/3124095 to your computer and use it in GitHub Desktop.
django-arbitrage
# 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