Bitcoin Calculator
HTML
<link rel="stylesheet" href="//netdna.bootstrapcdn.com/bootstrap/3.0.2/css/bootstrap.min.css">
<script src="//netdna.bootstrapcdn.com/bootstrap/3.0.2/js/bootstrap.min.js"></script>
<script src="//cdnjs.cloudflare.com/ajax/libs/numeral.js/1.4.5/numeral.min.js"></script>
<h3>Bought:</h3>
Price USD: <input type="text" id="btcPrice"><br/>
BTC Amount: <input type="text" id="btcAmount"><br/>
BTC Remaining: <input type="text" id="btcAmountRemaining" disabled><br/>
Cost USD: <input type="text" id="btcCost" disabled><br/>
<h3>Selling Break Even:</h3>
<input type="text" id="btcPriceSelling">
<h3>Asking:</h3>
Price USD: <input type="text" id="btcPriceAsking"><br/>
Profit USD: <input type="text" id="btcProfitAsking" disabled><br/>
Profit Percent: <input type="text" id="btcProfitPercentAsking" disabled><br/>
JavaScript
$(function(){
var TradingAgent = new Object();
//Tasks
// Move to meteor
//Fully vs Parially Observable
// Perception Action Cycle
// Deterministic ver stockastic
// Descrete vs continuous
// D
// buy sell
//Benign vs adversrial
// Agent
// Trading Agent
// Internal Memory
// Sensors (input)
// Control Panel
// Trade
// Depth
// Ticker
// Lag
// Trend
// News
// Twitter
// Rates
// Balance?
// Actuators (output)
// Trade
// Buy
// Sell
// Environment
// Market
//
// Perception Action Cycle
var percentRemaining = 0.994;
function updateMargins(){
var $btcPrice = $('#btcPrice'),
$btcAmount = $('#btcAmount'),
btcPrice = parseFloat($btcPrice.val()),
btcAmount = parseFloat($btcAmount.val()),
btcAmountRemaining = btcAmount * percentRemaining,
btcCost = btcPrice * btcAmount,
$btcAmountRemaining = $('#btcAmountRemaining'),
$btcCost = $('#btcCost'),
$btcPriceSelling = $('#btcPriceSelling'),
$btcPriceAsking = $('#btcPriceAsking'),
$btcProfitAsking = $('#btcProfitAsking'),
$btcProfitPercentAsking = $('#btcProfitPercentAsking'),
btcPriceAsking = parseFloat($btcPriceAsking.val());
$btcAmountRemaining.val(btcAmount * percentRemaining);
$btcCost.val(numeral(btcCost).format('$0,0.00'));
// Selling Break Even
btcAmountRemaining = btcAmountRemaining * percentRemaining;
var breakEvenPrice = btcCost / btcAmountRemaining;
$btcPriceSelling.val(numeral(breakEvenPrice).format('$0,0.00'));
//...