Skip to content

Instantly share code, notes, and snippets.

@stephanos
Created October 20, 2012 09:33
Show Gist options
  • Select an option

  • Save stephanos/3922775 to your computer and use it in GitHub Desktop.

Select an option

Save stephanos/3922775 to your computer and use it in GitHub Desktop.
val usdQuote = future { connection.getCurrentValue(USD) }
val chfQuote = future { connection.getCurrentValue(CHF) }
val purchase = for {
usd <- usdQuote
chf <- chfQuote
if isProfitable(usd, chf)
} yield connection.buy(amount, chf)
purchase onSuccess {
case _ => println("Purchased " + amount + " CHF")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment