import Portfolio from './src/portfolio';
import Asset from './src/asset';
import Percent from './src/percent';
import USD from './src/usd'; const $ = USD;

const assets = [{
  asset: Asset('VTI', $(105)),
  quantity: 0,
  ideal: Percent(30)
}, {
  asset: Asset('VBR', $(102.47)),
  quantity: 0,
  ideal: Percent(10)
}, {
  asset: Asset('VEU', $(45.79)),
  quantity: 0,
  ideal: Percent(15)
}, {
  asset: Asset('VSS', $(95.98)),
  quantity: 0,
  ideal: Percent(5)
}, {
  asset: Asset('BND', $(82.05)),
  quantity: 0,
  ideal: Percent(20)
}, {
  asset: Asset('TLT', $(123.71)),
  quantity: 0,
  ideal: Percent(15)
}, {
  asset: Asset('IAU', $(11.35)),
  quantity: 0,
  ideal: Percent(5)
}];

let portfolio = Portfolio(assets);
portfolio.load($(30000));
console.log(portfolio.assets);

@@ -743,16 +743,40 @@
 30000));
+%0A%0A// Print new portfolio
 %0Aconsole
@@ -791,16 +791,453 @@
 tfolio.assets);%0A
+%0A// Print actions%0Aportfolio.assets.forEach((allocated) =%3E %7B%0A  const unallocated = assets.find((a) =%3E a.asset.symbol === allocated.asset.symbol) %7C%7C %7B quantity: 0 %7D;%0A  const delta = allocated.quantity - unallocated.quantity;%0A  if (delta === 0) return;%0A  if (delta %3E 0)%0A    console.log(%60Buy $%7Bdelta%7D shares of $%7Ballocated.asset.symbol%7D%60);%0A  if (delta %3C 0)%0A    console.log(%60Sell $%7BMath.abs(delta)%7D shares of $%7Ballocated.asset.symbol%7D%60);%0A%7D);%0A

Print actions