Skip to content

Instantly share code, notes, and snippets.

@elvio
elvio / user.html
Last active August 29, 2015 14:27
User events sample for Foxplan (http://www.github.com/elvio/foxplan)
<html>
<head>
<script>
var ws = new WebSocket("ws://localhost:8080/ws/mobile");
function formatMessage(m) {
return JSON.stringify(m);
}
function joinRoom(code) {
allocations = %{"IAU" => 10, "TLT" => 10, "VGSH" => 10, "VTI" => 10}
orders = Rebalancex.rebalance_portfolio(allocations)
defmodule Rebalancex do
alias Rebalancex.Quote
@underweight 0.25
@overweight 0.27
def rebalance_portfolio(allocations, quote_service \\ Quote) do
portfolio = %{cash: 0, allocations: allocations}
prices = get_prices(allocations, quote_service)