CWB Trad Journal html

Developer
Size
13,903 Kb
Views
6,072

How do I make an cwb trad journal html?

What is a cwb trad journal html? How do you make a cwb trad journal html? This script and codes were developed by Nathan Gregg on 25 December 2022, Sunday.

CWB Trad Journal html Previews

CWB Trad Journal html - Script Codes HTML Codes

<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>CWB Trad Journal html</title> <meta name="viewport" content="width=device-width, initial-scale=1">
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:200" rel="stylesheet">
<link rel="stylesheet" href="https://code.jquery.com/ui/1.12.1/themes/base/jquery-ui.css"> <link rel='stylesheet prefetch' href='https://cdnjs.cloudflare.com/ajax/libs/font-awesome/4.7.0/css/font-awesome.min.css'> <link rel="stylesheet" href="css/style.css">
</head>
<body> <div>1Ƀ = <span id="bitcoin_price"></span></div>
<!-- ADD TRADE -->
<div id="add_trade_container" title="Add a new trade"> <form id="add_trade_form"> <fieldset> <div id="add_trade_fieldset"> <div class="input_holder"> <label for="add_coin">COIN</label> <input class="add_trade_input" type="text" id="add_coin" name="add_coin"/> </div> <div><span id="add_auto_fill_btn" class="journal_btn">AUTO-FILL</span></div> <!--find and auto-fill current price and date--> <div> <label for="add_date">Date Bought</label> <input class="add_trade_input" type="date" id="add_date" name="add_date"/> </div> <div> <label for="add_amt_bought">Amount Bought</label> <input class="add_trade_input" step="any" min="0" type="number" id="add_amt_bought" name="add_amt_bought"/> </div> <div> <label for="add_price_usd">Price in $</label> <input class="add_trade_input" step="any" type="number" id="add_price_usd" name="add_price_usd"/> </div> <div> <label for="add_price_btc">Price in Ƀ</label> <input class="add_trade_input" step="any" type="number" id="add_price_btc" name="add_price_btc"/> </div> <div> <input type="button" value="Add Trade" id="add_trade_btn" class="journal_btn" onclick="addTrade()"> </div> </div> </fieldset> </form>
</div>
<!-- EDIT OPEN TRADES -->
<div id="edit_open_trade_modal" class="modal"> <div class="modal-content"> <div class="modal-header"> <div>Edit Trade</div> </div> <div class="trade_info"> <div id="editing_trade_ref"></div> <div><span>Coin: </span><span id="editing_trade_info_coin">XMR</span></div> </div> <form> <fieldset id="edit_open_trade_fieldset" class="modal_fieldset"> <div> <label for="editing_opened_date">Date Opened <span id="editing_today_btn">TODAY</span></label> <input type="date" id="editing_opened_date"/> <label for="editing_amount">Amount Bought</label> <input type="number" id="editing_amount"/> <label for="editing_opened_price_usd">Price $ <span id="editing_open_auto_fill_btn">AUTO-FILL</span></label> <input type="number" id="editing_opened_price_usd"/> <label for="editing_opened_price_btc">Price Ƀ</label> <input type="number" id="editing_opened_price_btc"/> <!-- MANUAL CURRENT INPUTS--> <div class="manual_current_inputs">MANUAL INPUT FOR CURRENT DATA</div> <label class="manual_current_inputs" for="editing_current_price_usd">Current Price $</label> <input class="manual_current_inputs" type="number" id="editing_current_price_usd"/> <label class="manual_current_inputs" for="editing_current_price_btc">Current Price Ƀ</label> <input class="manual_current_inputs" type="number" id="editing_current_price_btc"/> <label class="manual_current_inputs" for="editing_current_24hr_perc">24hr +/-</label> <input class="manual_current_inputs" type="number" id="editing_current_24hr_perc"/> </div> </fieldset> <div class="trade_info"> <div><span>Total Value $: </span><span id="editing_trade_total_val_usd" class="trade_info_span"></span></div> <div><span>Total Value Ƀ: </span><span id="editing_trade_total_val_btc" class="trade_info_span"></span></div> </div> </form> <div class="modal-footer"> <button id="edit_trade_submit_btn" class="modal_button">Edit Trade</button> <button id="edit_trade_cancel_btn" class="modal_button">Cancel</button> </div> </div>
</div>
<!-- EDIT CLOSED TRADE -->
<div id="edit_closed_trade_modal" class="modal"> <div class="modal-content"> <div class="modal-header"> <div>Edit Trade</div> </div> <div class="trade_info"> <div id="editing_closed_trade_ref"></div> <div><span>Coin: </span><span id="editing_closed_trade_info_coin">XMR</span></div> </div> <form> <fieldset id="edit_closed_trade_fieldset" class="modal_fieldset"> <div> <!-- TRADE OPENED --> <label for="closed_editing_opened_date">Date Opened <span id="closed_editing_opened_today_btn">TODAY</span></label> <input type="date" id="closed_editing_opened_date"/> <label for="closed_editing_amount">Amount Bought</label> <input type="number" id="closed_editing_amount"/> <label for="closed_editing_opened_price_usd">Price $ <span id="closed_editing_opened_auto_fill_btn">AUTO-FILL</span></label> <input type="number" id="closed_editing_opened_price_usd"/> <label for="closed_editing_opened_price_btc">Price Ƀ</label> <input type="number" id="closed_editing_opened_price_btc"/> <!-- TRADE CLOSED --> <label for="closed_editing_closed_date">Date Closed <span id="closed_editing_closed_today_btn">TODAY</span></label> <input type="date" id="closed_editing_closed_date"/> <label for="closed_editing_closed_price_usd">Price $ <span id="closed_editing_closed_auto_fill_btn">AUTO-FILL</span></label> <input type="number" id="closed_editing_closed_price_usd"/> <label for="closed_editing_closed_price_btc">Price Ƀ</label> <input type="number" id="closed_editing_closed_price_btc"/> </div> </fieldset> <div class="trade_info"> <div><span>Profit $: </span><span id="closed_editing_trade_profit_usd" class="trade_info_span"></span></div> <div><span>Profit Ƀ: </span><span id="closed_editing_trade_profit_btc" class="trade_info_span"></span></div> </div> </form> <div class="modal-footer"> <button id="closed_edit_trade_submit_btn" class="modal_button">Edit Trade</button> <button id="closed_edit_trade_cancel_btn" class="modal_button">Cancel</button> </div> </div>
</div>
<!-- CLOSE TRADE -->
<div id="close_trade_modal" class="modal"> <div class="modal-content"> <div class="modal-header"> <div>Close Trade</div> </div> <div class="trade_info"> <div id="closing_trade_ref"></div> <div><span>Coin: </span><span id="closing_trade_info_coin">XMR</span></div> <div>Amount Opened: <span id="closing_trade_info_amount">12000</span></div> </div> <form> <fieldset id="close_trade_fieldset" class="modal_fieldset"> <div> <label for="date_closed">Date Closed <span id="closing_today_btn">TODAY</span></label> <input type="date" id="date_closed"/> <label for="amount_closed">Amount closed <span id="closing_all_btn">ALL</span></label> <input type="number" id="amount_closed"/> <label for="closed_price_usd">Price $ <span id="closing_auto_fill_btn">AUTO-FILL</span></label> <input type="number" id="closed_price_usd"/> <label for="closed_price_btc">Price Ƀ</label> <input type="number" id="closed_price_btc"/> </div> </fieldset> <div class="trade_info"> <div><span>Total Value $: </span><span id="closing_trade_total_val_usd" class="trade_info_span"></span></div> <div><span>Total Value Ƀ: </span><span id="closing_trade_total_val_btc" class="trade_info_span"></span></div> </div> </form> <div class="modal-footer"> <button id="close_trade_submit_btn" class="modal_button">Close Trade</button> <button id="close_trade_cancel_btn" class="modal_button">Cancel</button> </div> </div>
</div>
<!-- OPEN TRADES TABLE -->
<div class="table_topper"> <div>OPEN TRADES</div> <div><span>Currency:</span> <input type="checkbox" name="currency" id="curr_btc" value="btc" class="currency_checkbox"><i class="fa fa-btc" aria-hidden="true"></i> <input type="checkbox" name="currency" id="curr_usd" value="usd" class="currency_checkbox" checked><i class="fa fa-usd" aria-hidden="true"></i><br> </div>
</div>
<table id="open_trades_table" cellspacing="0" cellpadding="0"> <thead> <tr> <th rowspan="2" style="vertical-align:middle"><b>ACTIONS</b></th> <th rowspan="2" style="vertical-align:middle">COIN</th> <th rowspan="2" style="vertical-align:middle">AMOUNT</th> <th id="open_th_open" colspan="3" class="trade_open_bg">OPEN: <span class="totaliser_usd val_usd"> -</span> <span class="val_usd"> USD</span> / <span class="totaliser_btc val_btc"> -</span> <span class="val_btc"> BTC</span> </th> <th id="open_th_current" colspan="3" class="trade_current_bg">CURRENT: <span class="totaliser_usd val_usd"> -</span> <span class="val_usd"> USD</span> / <span class="totaliser_btc val_btc"> -</span> <span class="val_btc"> BTC</span> </th> <th id="open_th_profit" colspan="2" class="trade_profit_bg">CURRENT PROFIT: <span class="totaliser_usd val_usd"> -</span> <span class="val_usd"> USD</span> / <span class="totaliser_btc val_btc"> -</span> <span class="val_btc"> BTC</span> </th> </tr> <tr> <!--Buying--> <th>Date Opened</th> <th class="col_usd">Price $</th> <th class="col_btc">Price BTC</th> <th class="col_usd">Total Val $</th> <th class="col_btc">Total Val BTC</th> <!--Current--> <th class="col_usd">Price $</th> <th class="col_btc">Price BTC</th> <th class="col_usd">Val $</th> <th class="col_btc">Val BTC</th> <th>24hr % Change</th> <!--Current Profit--> <th class="col_usd">Profit $</th> <th class="col_usd">% Inc $</th> <th class="col_btc">Profit BTC</th> <th class="col_btc">% Inc BTC</th> </tr> </thead> <tbody> </tbody>
</table>
<!-- SHOW DELETED TRADES -->
<input type="checkbox" style="display:none;" id="deleted_open_trades_btn" class="journal_btn"><label id="deleted_open_trades_label" class="journal_btn" for="deleted_open_trades_btn">Show Deleted Trades</label>
<!-- CLOSED TRADES TABLE -->
<div class="table_topper"> <div>CLOSED TRADES</div> <div>Total Profit</div>
</div>
<table id="closed_trades_table"> <thead> <tr> <th rowspan="2" style="vertical-align:middle">Actions</th> <th rowspan="2" style="vertical-align:middle">COIN</th> <th rowspan="2" style="vertical-align:middle">AMOUNT</th> <th id="closed_th_opened" colspan="3" class="trade_open_bg">OPENED: <span class="totaliser_usd val_usd"> -</span> <span class="val_usd"> USD</span> / <span class="totaliser_btc val_btc"> -</span> <span class="val_btc"> BTC</span> </th> <th id="closed_th_closed" colspan="3" class="trade_current_bg">CLOSED <span class="totaliser_usd val_usd"> -</span> <span class="val_usd"> USD</span> / <span class="totaliser_btc val_btc"> -</span> <span class="val_btc"> BTC</span> </th> <th id="closed_th_profit" colspan="2" class="trade_profit_bg">PROFIT <span class="totaliser_usd val_usd"> -</span> <span class="val_usd"> USD</span> / <span class="totaliser_btc val_btc"> -</span> <span class="val_btc"> BTC</span> </th> </tr> <tr> <!--Buying--> <th>Date Opened</th> <th class="col_usd">Price $</th> <th class="col_btc">Price BTC</th> <th class="col_usd">Total Value $</th> <th class="col_btc">Total Value BTC</th> <!--Current--> <th>Date Closed</th> <th class="col_usd">Price $</th> <th class="col_btc">Price BTC</th> <th class="col_usd">Total Value $</th> <th class="col_btc">Total Value BTC</th> <!--Current Profit--> <th class="col_usd">Profit $</th> <th class="col_usd">% Inc $</th> <th class="col_btc">Profit BTC</th> <th class="col_btc">% Inc BTC</th> </tr> </thead> <tbody> </tbody>
</table>
<!-- SHOW DELETED TRADES -->
<input type="checkbox" style="display:none;" id="deleted_closed_trades_btn" class="journal_btn"><label id="deleted_closed_trades_label" class="journal_btn" for="deleted_closed_trades_btn">Show Deleted Trades</label>
<!--
<tr> <td class="actions"> + - x </td> <td class="coin">ETH</td> <td class="date_bought">12th April 2017</td> <td class="amount_bought">5.21</td> <td class="price_usd">10.2</td> <td class="price_btc">0.017</td> <td class="total_val_usd">51.15</td> <td class="total_val_btc">0.085</td> <td class="current_price_usd">73.70</td> <td class="current_price_btc">0.00564</td> <td class="current_val_usd">368.75</td> <td class="current_val_btc">0.2782</td> <td class="24hr_change">+11.46</td> <td class="profit_usd">317.75</td> <td class="profit_btc">0.19</td>
</tr>
--> <script src='https://cdnjs.cloudflare.com/ajax/libs/jquery/3.1.0/jquery.min.js'></script>
<script src='https://cdnjs.cloudflare.com/ajax/libs/jqueryui/1.12.1/jquery-ui.min.js'></script> <script src="js/index.js"></script>
</body>
</html>

CWB Trad Journal html - Script Codes CSS Codes

* { margin: 0; padding: 0; font-size: 100%; vertical-align: baseline; outline: none; box-sizing: border-box; font-family: "Source Sans Pro",sans-serif; border-radius: none; border-collapse:collapse;
}
html, body { height: 100%;
}
.positive { background-color: green;
}
.negative { background-color: red;
}
table { width: 100%; margin: 0 0 40px 0; border: none; margin: 10px 0;
}
tr {
}
th, td { border: 1px solid grey; padding: 3px 7px; min-width: 70px;
}
td { text-align:right;
}
td:nth-child(1){ text-align: center;
}
td:nth-child(4), td:nth-child(5), td:nth-child(6), td:nth-child(7), td:nth-child(8) { background-color: lightgreen;
}
.table_topper { display: flex; flex-flow: row nowrap; justify-content: space-between;
}
.trade_open_bg { background-color: lightgreen;
}
.trade_current_bg { background-color: lightblue;
}
.trade_profit_bg { background-color: orange;
}
table i { padding: 0 5px
}
fieldset { padding: 0; border: none; margin-top: 25px;
}
#add_trade_fieldset { display: flex; flex-flow: row nowrap; align-items: baseline;
}
#add_trade_fieldset div{ margin: 10px;
}
.modal_button, .journal_btn { background-color: #4CAF50; /* Green */ border: none; color: white; padding: 3px 10px; text-align: center; text-decoration: none; display: inline-block; font-size: 16px; cursor: pointer;
}
.close_trade_btn, .edit_trade_btn { background-color: white; /* Green */ border: none; font-size: 16px;
}
#deleted_open_trades_div { width: 50%;
}
.manual_current_inputs { display: none;
}
/* MODAL */
.modal { display: none; /* Hidden by default */ position: fixed; /* Stay in place */ z-index: 1; /* Sit on top */ padding-top: 100px; /* Location of the box */ left: 0; top: 0; width: 100%; /* Full width */ height: 100%; /* Full height */ overflow: auto; /* Enable scroll if needed */ background-color: rgb(0,0,0); /* Fallback color */ background-color: rgba(0,0,0,0.4); /* Black w/ opacity */
}
.modal-content { position: relative; background-color: #fefefe; margin: auto; border: 1px solid #888; width: 400px; box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2),0 6px 20px 0 rgba(0,0,0,0.19);
}
.modal-header { display: flex; flex-flow: row nowrap; justify-content: space-between; font-size: 1.4em; padding: 6px 16px; background-color: #5cb85c; color: white;
}
.modal-body { padding: 2px 16px;
}
.modal-footer { padding: 2px 16px; background-color: #5cb85c; color: white; display: flex; justify-content: space-around;
}
.modal-footer button{ margin: 5px;
}
/* Modal Content */
.modal_button:hover,
.modal_button:focus, .journal_btn:hover { color: #000; text-decoration: none; cursor: pointer;
}
.trade_info { padding: 5px; margin: 5px auto; width: 300px;
}
.trade_info > div{ padding: 5px; margin: 5px; display: flex; justify-content: space-between;
}
.modal_fieldset { width: 90%; margin: 0 auto;
}
.modal_fieldset > div { display: flex; flex-flow: column nowrap; justify-content: space-between; padding: 5px; margin: 5px;
}
.modal_fieldset input { margin-bottom: 10px;
}
.modal_fieldset label span { float: right; color: blue; cursor: pointer;
}
/* remove spinner wheels from number boxes */
input[type=number]::-webkit-inner-spin-button,
input[type=number]::-webkit-outer-spin-button,
input[type=date]::-webkit-inner-spin-button,
input[type=date]::-webkit-outer-spin-button{ -webkit-appearance: none; margin: 0;
}
input[type=number] { -moz-appearance: textfield;
}

CWB Trad Journal html - Script Codes JS Codes

/*
TO DO:
Unique Reference Numbers, test add trade!
currency to radio buttons, + EUR GBP, possibly add any currency
Styling colours, +ve and -ve
add images
click on coin for graphical buys/sells
*/
// SAMPLE DATA
var open_trades_data = [ { "ref":"1ABC234", "coin":"ETH", "date_opened":"2016-04-12", "amount":"5", "price_usd":"10.2", "price_btc":"0.017", "exchange": true, "manual": { "price_usd":"70", "price_btc":"0.087", "cap24hrChange":"15" } }, { "ref":"1ABC345", "coin":"XRP", "date_opened":"2016-09-03", "amount":"50000", "price_usd":".02", "price_btc":"0.000954", "exchange": true, "manual": { "price_usd":"", "price_btc":"", "cap24hrChange":"-4.69" } }, { "ref":"1ABC511", "coin":"1ST", "date_opened":"2017-03-01", "amount":"365.9", "price_usd":"0.09", "price_btc":"0.00087", "exchange": true, "manual": { "price_usd":"", "price_btc":"", "cap24hrChange":"" } }, { "ref":"1ABD700", "coin":"AGRS", "date_opened":"2017-04-24", "amount":"2100", "price_usd":"0.4", "price_btc":"0.0018", "exchange": true, "manual": { "price_usd":"0.8", "price_btc":"0.000356", "cap24hrChange":"10.4" } }, { "ref":"1ABD234", "coin":"LTC", "date_opened":"2015-12-25", "amount":"144.45", "price_usd":"0.15", "price_btc":"0.000230", "exchange": true, "manual": { "price_usd":"70", "price_btc":"0.087", "cap24hrChange":"15" } }
];
var closed_trades_data = [ { "ref":"1ABB112", "coin":"ETH", "amount": "25", "date_opened":"2016-04-30", "price_opened_usd":"10.2", "price_opened_btc":"0.017", "exchange": true, "manual": { "price_usd":"", "price_btc":"", "cap24hrChange":"" }, "date_closed":"2017-01-01", "price_closed_usd":"73.70", "price_closed_btc":"0.0564", }, { "ref":"1ABB113", "coin":"LTC", "amount": "250", "date_opened":"2015-04-30", "price_opened_usd":"0.29", "price_opened_btc":"0.0037", "exchange": true, "manual": { "price_usd":"", "price_btc":"", "cap24hrChange":"" }, "date_closed":"2016-01-01", "price_closed_usd":"3.70", "price_closed_btc":"0.0364", }
];
var coincap_data = [ {"short":"BTC","price":1342.5,"cap24hrChange":"0.44"}, {"short":"ETH","price":76.65675,"cap24hrChange":"11.46"}, {"short":"XRP","price":0.052505175,"cap24hrChange":"-4.57"}, {"short":"LTC","price":15.84415815,"cap24hrChange":"2.21"}
];
var deleted_open_trades = [ { "ref":"1ABC239", "coin":"XMR", "date_opened":"2016-05-12", "amount":"50", "price_usd":"5.20", "price_btc":"0.0057", "exchange": true, "manual": { "price_usd":"3.40", "price_btc":"0.0037", "24hr_change": -13 }, }, { "ref":"1ABC240", "coin":"LTC", "date_opened":"2016-05-11", "amount":"3000", "price_usd":"0.22", "price_btc":"0.00027", "exchange": true, "manual": { "price_usd":"", "price_btc":"", "24hr_change":"" }, }, { "ref":"1ABC242", "coin":"ETH", "date_opened":"2016-05-15", "amount":"350", "price_usd":"20.22", "price_btc":"0.037", "exchange": true, "manual": { "price_usd":"", "price_btc":"", "24hr_change":"" }, }
];
var deleted_closed_trades = [ { "ref":"1ABB197", "coin":"AGRS", "amount": "2500", "date_opened":"2016-03-15", "price_opened_usd":"0.02", "price_opened_btc":"0.00217", "exchange": true, "manual": { "price_usd":"", "price_btc":"", "cap24hrChange":"" }, "date_closed":"2017-02-02", "price_closed_usd":"75.70", "price_closed_btc":"0.0664", }, { "ref":"1ABB267", "coin":"PCSH", "amount": "250099", "date_opened":"2016-12-25", "price_opened_usd":"0.0029", "price_opened_btc":"0.000037", "exchange": true, "manual": { "price_usd":"", "price_btc":"", "cap24hrChange":"" }, "date_closed":"2017-07-19", "price_closed_usd":"1.00", "price_closed_btc":"0.364", }
];
// Global Variables
var show_deleted_open_trades = false, show_deleted_closed_trades = false, btc_price;
// Get bitcoin price
function bitcoinPrice() { for (var i = 0; i < coincap_data.length; i++){ if (coincap_data[i].short == "BTC"){ btc_price = coincap_data[i].price; } }
}
bitcoinPrice();
$('#bitcoin_price').html(btc_price);
// disable mouse scroll on number inputs
$(':input[type=number]').on('mousewheel', function(e){ e.preventDefault();
});
////////////////////
/* MAKING TABLES */
//////////////////
// Make the open trades table
function makeOpenTable(){ var $open_trades_table_body = $('#open_trades_table tbody'), open_totaliser_usd = 0, open_totaliser_btc = 0, current_totaliser_usd = 0, current_totaliser_btc = 0, open_profit_total_usd = 0, open_profit_total_btc = 0; $open_trades_table_body.empty(); // clear table function makeARow(array) { // make a row in the table using specified array for (var i = 0; i < array.length; i++ ) { // for each entry in array var is_there_a_match = false, coin_ref = array[i].coin, curr_price_usd = 0, curr_price_btc = 0, curr_val_usd = 0, curr_val_btc = 0, perc_change_24hr = 0, profit_usd = 0, profit_btc = 0, profit_perc_inc_usd = 0, profit_perc_inc_btc = 0, total_val_usd = parseFloat((array[i].amount*array[i].price_usd).toFixed(8)), total_val_btc = parseFloat((array[i].amount*array[i].price_btc).toFixed(8)); // get coincap data if (array[i].exchange == true) { // if getting data from exchange == true for (var k = 0; k < coincap_data.length; k++){ // then get coincap data if (coincap_data[k].short == coin_ref){ is_there_a_match = true; curr_price_usd = (coincap_data[k].price).toFixed(2); curr_price_btc = (curr_price_usd/btc_price).toFixed(8); curr_val_usd = parseFloat((array[i].amount*curr_price_usd).toFixed(2)); curr_val_btc = parseFloat((array[i].amount*curr_price_btc).toFixed(8)); perc_change_24hr = coincap_data[k].cap24hrChange; profit_usd = parseFloat((curr_val_usd - total_val_usd).toFixed(2)); profit_perc_inc_usd = ((profit_usd / total_val_usd) * 100).toFixed(2); profit_btc = parseFloat((curr_val_btc - total_val_btc).toFixed(8)); profit_perc_inc_btc = ((profit_btc / total_val_btc) * 100).toFixed(2); } } if (is_there_a_match == false) { // if 'get data from exchange' is on, but there is no match... array[i].exchange = false; // set exchange data to false, // alert(coin_ref + " has no exchange data. Please enter manually"); } }; if (array[i].exchange == false){ // if data from exchange == false if (array[i].manual.price_usd == "") { // and the usd input is empty curr_price_usd = "pls input manually"; } else { // or if there is a value already, get it curr_price_usd = array[i].manual.price_usd; curr_val_usd = parseFloat((array[i].amount*curr_price_usd).toFixed(2)); profit_usd = parseFloat((curr_val_usd - total_val_usd).toFixed(2)); profit_perc_inc_usd = ((profit_usd / total_val_usd) * 100).toFixed(2); } if (array[i].manual.price_usd == "") { // and the btc input is empty curr_price_btc = "pls input manually"; } else { // or not empty, get it curr_price_btc = array[i].manual.price_btc; curr_val_btc = parseFloat((array[i].amount*curr_price_btc).toFixed(8)); profit_btc = parseFloat((curr_val_btc - total_val_btc).toFixed(8)); profit_perc_inc_btc = ((profit_btc / total_val_btc) * 100).toFixed(2); } if (array[i].manual.price_usd == "") { // and the perc input is empty perc_change_24hr = "pls input manually"; } else { // or not empty, get it perc_change_24hr = array[i].manual.cap24hrChange; } }; // Add values to totalisers if (array == open_trades_data) { open_totaliser_usd = (open_totaliser_usd + total_val_usd); open_totaliser_btc = (open_totaliser_btc + total_val_btc); current_totaliser_usd = (current_totaliser_usd + curr_val_usd); current_totaliser_btc = (current_totaliser_btc + curr_val_btc); open_profit_total_usd = (open_profit_total_usd + profit_usd); open_profit_total_btc = (open_profit_total_btc + profit_btc); } // make html var $tr = $('<tr></tr>'), $td_coin = $('<td>' + coin_ref + '</td>'), $td_amount_opened = $('<td>' + array[i].amount + '</td>'), $td_date_opened = $('<td>' + array[i].date_opened + '</td>'), $td_price_usd = $('<td class="col_usd">' + array[i].price_usd + '</td>'), $td_price_btc = $('<td class="col_btc">' + array[i].price_btc + '</td>'), $td_total_val_usd = $('<td class="col_usd">' + total_val_usd + '</td>'), $td_total_val_btc = $('<td class="col_btc">' + total_val_btc + '</td>'), $td_curr_price_usd = $('<td class="col_usd" style="background-color:red;">' + curr_price_usd + '</td>'), $td_curr_price_btc = $('<td class="col_btc">' + curr_price_btc + '</td>'), $td_curr_val_usd = $('<td class="col_usd">' + curr_val_usd + '</td>'), $td_curr_val_btc = $('<td class="col_btc">' + curr_val_btc + '</td>'), $td_perc_change_24hr = $('<td>' + perc_change_24hr + '</td>'), $td_profit_usd = $('<td class="col_usd">' + profit_usd + '</td>'), $td_profit_perc_inc_usd = $('<td class="col_usd">' + profit_perc_inc_usd + '</td>'), $td_profit_btc = $('<td class="col_btc">' + profit_btc + '</td>'), $td_profit_perc_inc_btc = $('<td class="col_btc">' + profit_perc_inc_btc + '</td>'); // actions icons if (array == open_trades_data) { var $td_actions = $('<td><i class="fa fa-pencil-square-o edit_opened_btn" title="Edit" aria-hidden="true" data-blah="' + array[i].ref + '"></i><i class="fa fa-flag-checkered" title="Close" aria-hidden="true" data-blah="' + array[i].ref + '"></i><i class="fa fa-trash trash_trade_opened" title="Trash" aria-hidden="true" data-blah="' + array[i].ref + '"></i></td>'); // Exchange icon red or green if (array[i].exchange == true) { var $exchange_icon = $('<i class="fa fa-exchange" title="Live Prices From Exchange" aria-hidden="true" data-blah="' + array[i].ref + '" style="color:green"></i>'); } else { var $exchange_icon = $('<i class="fa fa-exchange" title="Live Prices From Exchange" aria-hidden="true" data-blah="' + array[i].ref + '" style="color:red"></i>'); } } else if (array == deleted_open_trades){ var $td_actions = $('<td><i class="fa fa-undo reinstate_opened" title="Reinstate This Trade" aria-hidden="true" data-blah="' + array[i].ref + '"></i><i class="fa fa-trash delete_forever_opened style="color:red;" title="Delete Forever!" aria-hidden="true" data-blah="' + array[i].ref + '"></i></td>'); } $td_actions.append($exchange_icon); $tr.append($td_actions) .append($td_coin) .append($td_amount_opened) .append($td_date_opened) .append($td_price_usd) .append($td_price_btc) .append($td_total_val_usd) .append($td_total_val_btc) .append($td_curr_price_usd) .append($td_curr_price_btc) .append($td_curr_val_usd) .append($td_curr_val_btc) .append($td_perc_change_24hr) .append($td_profit_usd) .append($td_profit_perc_inc_usd) .append($td_profit_btc) .append($td_profit_perc_inc_btc); $open_trades_table_body.append($tr); } }; // End Make A Row // add open trades rows makeARow(open_trades_data); // add deleted trades rows if (show_deleted_open_trades == true) { makeARow(deleted_open_trades); // Click the "Reinstate Trade" button $(".reinstate_opened").on('click', function (e) { e.preventDefault(); var this_ref = $(this).data("blah"); if (confirm("Are you sure you want reinstate this trade?") == true) { for (var n = 0; n < deleted_open_trades.length; n++ ) { // for each trade in array var opened_ref = deleted_open_trades[n].ref; if (this_ref == opened_ref) { // match the reference var push_data = deleted_open_trades.splice(n, 1); // remove entry from "open" array, save to variable open_trades_data.push(push_data[0]); // push data to deleted trades break; } } makeOpenTable(); } }); // Click the "Reinstate Trade" button $(".delete_forever_opened").on('click', function (e) { e.preventDefault(); var this_ref = $(this).data("blah"); if (confirm("Ddelete this trade forever? You will not be able to recover it.") == true) { for (var n = 0; n < deleted_open_trades.length; n++ ) { // for each trade in array var opened_ref = deleted_open_trades[n].ref; if (this_ref == opened_ref) { // match the reference deleted_open_trades.splice(n, 1); // remove entry from "open" array break; } } makeOpenTable(); }; }); // end delete forever }; // // insert totalisers $('#open_th_open .totaliser_usd').html(open_totaliser_usd.toFixed(0)); $('#open_th_open .totaliser_btc').html(open_totaliser_btc.toFixed(2)); $('#open_th_current .totaliser_usd').html(current_totaliser_usd.toFixed(0)); $('#open_th_current .totaliser_btc').html(current_totaliser_btc.toFixed(2)); $('#open_th_profit .totaliser_usd').html(open_profit_total_usd.toFixed(0)); $('#open_th_profit .totaliser_btc').html(open_profit_total_btc.toFixed(2)); // Click the "close" button $(".fa-flag-checkered").on('click', function (e) { e.preventDefault(); var this_ref = $(this).data("blah"); close_trade_modal.style.display = "block"; // (should be able to call this as a seperate function) for (var l = 0; l < open_trades_data.length; l++ ) { // loop through array var trade_ref = open_trades_data[l].ref; if (this_ref == trade_ref) { // if the index matches var coin = open_trades_data[l].coin, // get coin amount = open_trades_data[l].amount, // and amount date_opened = open_trades_data[l].date_opened; $("#closing_trade_ref").html(trade_ref); $("#closing_trade_date").html(date_opened); $("#closing_trade_info_coin").html(coin); // append to modal $("#closing_trade_info_amount").html(amount); } } }); // Click the "edit" button $(".edit_opened_btn").on('click', function (e) { e.preventDefault(); var this_ref = $(this).data("blah"); edit_open_trade_modal.style.display = "block"; for (var m = 0; m < open_trades_data.length; m++ ) { // loop through array var trade_ref = open_trades_data[m].ref; // get each ref if (this_ref == trade_ref) { // if the ref matches var coin = open_trades_data[m].coin, // get coin date_opened = open_trades_data[m].date_opened, amount = open_trades_data[m].amount, price_usd = open_trades_data[m].price_usd, price_btc = open_trades_data[m].price_btc, exchange = open_trades_data[m].exchange, manual_price_usd = open_trades_data[m].manual.price_usd, manual_price_btc = open_trades_data[m].manual.price_btc, manual_24hr_change = open_trades_data[m].manual.cap24hrChange; $("#editing_trade_ref").html(trade_ref); $("#editing_trade_info_coin").html(coin); $("#editing_opened_date").val(date_opened); $("#editing_amount").val(amount); $('#editing_opened_price_usd').val(price_usd); $('#editing_opened_price_btc').val(price_btc); $('#editing_current_price_usd').val(manual_price_usd); $('#editing_current_price_btc').val(manual_price_btc); $('#editing_current_24hr_perc').val(manual_24hr_change); if (exchange == false) { $('.manual_current_inputs').each(function(){$(this).css({"display":"block"});}); } else { $('.manual_current_inputs').each(function(){$(this).css({"display":"none"});}); } } } }); // Click the "trash" button $(".trash_trade_opened").on('click', function (e) { e.preventDefault(); var $this = $(this), this_ref = $this.data("blah"); // get the trade ref if (confirm("Are you sure you want to delete this trade?") == true) { for (var n = 0; n < open_trades_data.length; n++ ) { // for each trade in array var opened_ref = open_trades_data[n].ref; if (this_ref == opened_ref) { // match the reference var push_data = open_trades_data.splice(n, 1); // remove entry from "open" array, save to variable deleted_open_trades.push(push_data[0]); // push data to deleted trades break; } } makeOpenTable(); } }); // get live data from exchange OR use manual data $(".fa-exchange").on('click', function (e) { e.preventDefault(); var $this = $(this), this_ref = $this.data("blah"); for (var n = 0; n < open_trades_data.length; n++ ) { // for each trade in array var opened_ref = open_trades_data[n].ref; if (this_ref == opened_ref) { // match the reference if (open_trades_data[n].exchange == true) { open_trades_data[n].exchange = false; makeOpenTable(); } else { open_trades_data[n].exchange = true; makeOpenTable(); } } } }); currencyColumns();
}
makeOpenTable();
// Show deleted open trades button
$('#deleted_open_trades_btn').click(function(){ if (this.checked) { show_deleted_open_trades = true; document.getElementById('deleted_open_trades_label').innerHTML = "Hide Deleted Trades"; makeOpenTable(); } else { show_deleted_open_trades = false; document.getElementById('deleted_open_trades_label').innerHTML = "Show Deleted Trades"; makeOpenTable(); }
})
// Make closed trades table
function makeClosedTable(){ var $closed_trades_table_body = $('#closed_trades_table tbody'), opened_totaliser_usd = 0, opened_totaliser_btc = 0, closed_totaliser_usd = 0, closed_totaliser_btc = 0, closed_profit_total_usd = 0, closed_profit_total_btc = 0; // cache table $closed_trades_table_body.empty(); // clear table function makeRows(array) { for (var i = 0; i < array.length; i++ ) { // for each object (trade) in array var coin_ref = array[i].coin, date_opened = array[i].date_opened, amount = array[i].amount, price_opened_usd = array[i].price_opened_usd, price_opened_btc = array[i].price_opened_btc, total_val_open_usd = parseFloat((amount * price_opened_usd).toFixed(2)), total_val_open_btc = parseFloat((amount * price_opened_btc).toFixed(8)), date_closed = array[i].date_closed, price_closed_usd = array[i].price_closed_usd, price_closed_btc = array[i].price_closed_btc, total_val_closed_usd = parseFloat((amount * price_closed_usd).toFixed(2)), total_val_closed_btc = parseFloat((amount * price_closed_btc).toFixed(8)), closed_profit_usd = parseFloat((total_val_closed_usd - total_val_open_usd).toFixed(2)), profit_inc_usd = ((closed_profit_usd / total_val_open_usd) * 100).toFixed(2), closed_profit_btc = parseFloat((total_val_closed_btc - total_val_open_btc).toFixed(8)), profit_inc_btc = ((closed_profit_btc / total_val_open_btc) * 100).toFixed(2); // Add values to totalisers if (array == closed_trades_data) { opened_totaliser_usd = (opened_totaliser_usd + total_val_open_usd); opened_totaliser_btc = (opened_totaliser_btc + total_val_open_btc); closed_totaliser_usd = (closed_totaliser_usd + total_val_closed_usd); closed_totaliser_btc = (closed_totaliser_btc + total_val_closed_btc); closed_profit_total_usd = (closed_profit_total_usd + closed_profit_usd); closed_profit_total_btc = (closed_profit_total_btc + closed_profit_btc); } // make html	var $tr = $('<tr></tr>'), $td_coin = $('<td>' + coin_ref + '</td>'), $td_amount_closed = $('<td>' + amount + '</td>'), $td_date_opened = $('<td>' + date_opened + '</td>'), $td_price_open_usd = $('<td class="col_usd">' + price_opened_usd + '</td>'), $td_price_open_btc = $('<td class="col_btc">' + price_opened_btc + '</td>'), $td_total_val_open_usd = $('<td class="col_usd">' + total_val_open_usd + '</td>'), $td_total_val_open_btc = $('<td class="col_btc">' + total_val_open_btc + '</td>'), $td_date_closed = $('<td>' + date_closed + '</td>'), $td_price_closed_usd = $('<td class="col_usd">' + price_closed_usd + '</td>'), $td_price_closed_btc = $('<td class="col_btc">' + price_closed_btc + '</td>'), $td_total_val_closed_usd = $('<td class="col_usd">' + total_val_closed_usd + '</td>'), $td_total_val_closed_btc = $('<td class="col_btc">' + total_val_closed_btc + '</td>'), $td_profit_usd = $('<td class="col_usd">' + closed_profit_usd + '</td>'), $td_profit_perc_inc_usd = $('<td class="col_usd">' + profit_inc_usd + '</td>'), $td_profit_btc = $('<td class="col_btc">' + closed_profit_btc + '</td>'), $td_profit_perc_inc_btc = $('<td class="col_btc">' + profit_inc_btc + '</td>'); if (array == closed_trades_data) { var $td_actions = $('<td><i class="fa fa-pencil-square-o edit_closed_btn" title="Edit" aria-hidden="true" data-blah="' + array[i].ref + '"></i><i class="fa fa-trash trash_trade_closed" title="Trash" aria-hidden="true" data-blah="' + array[i].ref + '"></i></td>'); } else if (array == deleted_closed_trades){ var $td_actions = $('<td><i class="fa fa-undo reinstate_closed" title="Reinstate This Trade" aria-hidden="true" data-blah="' + array[i].ref + '"></i><i class="fa fa-trash delete_forever_closed" style="color:red;" title="Delete Forever!" aria-hidden="true" data-blah="' + array[i].ref + '"></i></td>'); } $tr.append($td_actions) .append($td_coin) .append($td_amount_closed) .append($td_date_opened) .append($td_price_open_usd) .append($td_price_open_btc) .append($td_total_val_open_usd) .append($td_total_val_open_btc) .append($td_date_closed) .append($td_price_closed_usd) .append($td_price_closed_btc) .append($td_total_val_closed_usd) .append($td_total_val_closed_btc) .append($td_profit_usd) .append($td_profit_perc_inc_usd) .append($td_profit_btc) .append($td_profit_perc_inc_btc); $closed_trades_table_body.append($tr); } } // end makeRows makeRows(closed_trades_data); // add deleted trades rows if (show_deleted_closed_trades == true) { makeRows(deleted_closed_trades); // Click the "Reinstate Trade" button $(".reinstate_closed").on('click', function (e) { e.preventDefault(); var this_ref = $(this).data("blah"); if (confirm("Are you sure you want reinstate this trade?") == true) { for (var n = 0; n < deleted_closed_trades.length; n++ ) { // for each trade in array var opened_ref = deleted_closed_trades[n].ref; if (this_ref == opened_ref) { // match the reference var push_data = deleted_closed_trades.splice(n, 1); // remove entry from "open" array, save to variable closed_trades_data.push(push_data[0]); // push data to deleted trades break; } } makeClosedTable(); } }); // Click the "delete forever" button $(".delete_forever_closed").on('click', function (e) { e.preventDefault(); var this_ref = $(this).data("blah"); if (confirm("Ddelete this trade forever? You will not be able to recover it.") == true) { for (var n = 0; n < deleted_closed_trades.length; n++ ) { // for each trade in array var opened_ref = deleted_closed_trades[n].ref; if (this_ref == opened_ref) { // match the reference deleted_closed_trades.splice(n, 1); // remove entry from "open" array break; } } makeClosedTable(); }; }); // end delete forever }; // insert totalisers $('#closed_th_opened .totaliser_usd').html(opened_totaliser_usd.toFixed(0)); $('#closed_th_opened .totaliser_btc').html(opened_totaliser_btc.toFixed(2)); $('#closed_th_closed .totaliser_usd').html(closed_totaliser_usd.toFixed(0)); $('#closed_th_closed .totaliser_btc').html(closed_totaliser_btc.toFixed(2)); $('#closed_th_profit .totaliser_usd').html(closed_profit_total_usd.toFixed(0)); $('#closed_th_profit .totaliser_btc').html(closed_profit_total_btc.toFixed(2)); // Click the "edit" button $(".edit_closed_btn").on('click', function (e) { e.preventDefault(); var this_ref = $(this).data("blah"); for (var m = 0; m < closed_trades_data.length; m++ ) { // loop through array var trade_ref = closed_trades_data[m].ref; // get each ref if (this_ref == trade_ref) { // if the ref matches var coin = closed_trades_data[m].coin, // get coin date_opened = closed_trades_data[m].date_opened, amount = closed_trades_data[m].amount, opened_price_usd = closed_trades_data[m].price_opened_usd, opened_price_btc = closed_trades_data[m].price_opened_btc, closed_date = closed_trades_data[m].date_closed, closed_price_usd = closed_trades_data[m].price_closed_usd, closed_price_btc = closed_trades_data[m].price_closed_btc; $("#editing_closed_trade_ref").html(trade_ref); $("#editing_closed_trade_info_coin").html(coin); $("#closed_editing_opened_date").val(date_opened); $("#closed_editing_amount").val(amount); $('#closed_editing_opened_price_usd').val(opened_price_usd); $('#closed_editing_opened_price_btc').val(opened_price_btc); $('#closed_editing_closed_date').val(closed_date); $('#closed_editing_closed_price_usd').val(closed_price_usd); $('#closed_editing_closed_price_btc').val(closed_price_btc); edit_closed_trade_modal.style.display = "block"; } } }); // Click the "trash" button $(".trash_trade_closed").on('click', function (e) { e.preventDefault(); var $this = $(this), this_ref = $this.data("blah"); // get the trade ref if (confirm("Are you sure you want to delete this trade?") == true) { for (var n = 0; n < closed_trades_data.length; n++ ) { // for each trade in array var opened_ref = closed_trades_data[n].ref; if (this_ref == opened_ref) { // match the reference var push_data = closed_trades_data.splice(n, 1); // remove entry from "open" array, save to variable deleted_closed_trades.push(push_data[0]); // push data to deleted trades break; } } makeClosedTable(); } }); currencyColumns();
}
makeClosedTable();
// Show deleted closed trades button
$('#deleted_closed_trades_btn').click(function(){ if (this.checked) { show_deleted_closed_trades = true; document.getElementById('deleted_closed_trades_label').innerHTML = "Hide Deleted Trades"; makeClosedTable(); } else { show_deleted_closed_trades = false; document.getElementById('deleted_closed_trades_label').innerHTML = "Show Deleted Trades"; makeClosedTable(); }
})
// Add a trade to the open trade table using form
function addTrade() { var coin = document.getElementById('add_coin').value.toUpperCase(), date = document.getElementById('add_date').value, amount = document.getElementById('add_amt_bought').value, price_usd = document.getElementById('add_price_usd').value, price_btc = document.getElementById('add_price_btc').value; /* Need to add reference in. But need to work out how to get correct number */ // var ref = ; open_trades_data.push({ // "ref":ref, "coin":coin, "date_opened":date, "amount":amount, "price_usd":price_usd, "price_btc":price_btc, "exchange": true, "manual": { "price_usd":"70", "price_btc":"0.087", "cap24hrChange":"15" } }); makeOpenTable(); $(".add_trade_input").each(function() { $(this).val(""); });
};
// auto complete Coin
var availableTags = ["BTC","ETH","XRP","LTC","XEM","DASH","ETC","XMR","XLM","STEEM","GNT","REP","MAID","DOGE","ZEC","GNO","STRAT","BTS","WAVES","BCN","DGD","FCT","DCR","PIVX","SNGLS","ARDR","GAME","USDT","LSK","SC","PPC","ICN","RLC","NXT","GBYTE","SYS","NMC","1ST","EMC","KMD","EMC2","ARK","NXS","SJCX","ANS","MLN","LKK","XCP","WINGS","XAUR","BTCD","BAY","DGB","BCY","YBC","TRST","NAV","NLG","POT","CRBIT","EAC","SWT","XZC","AMP","BLK","TIME","MONA","UBQ","AGRS","ZCL","CLAM","CRW","IOC","EDG","RBY","VTC","NVC","NXC","LBC","VSL","ION","GRC","EXP","BURST","RADS","XPM","MUE","PASC","TIPS","OMNI","BLOCK","XBC","VIA","UNITY","SLR","HEAT","FTC","BELA","SIB","NAUT","SHIFT","ENRG","AEON","VRC","POSW","GAM","MUSE","IFC","MEC","PINK","NEOS","FAIR","VPN","AC","EDR","WDC","COINO","FLO","XMS","FFC","GSM","MRY","ASC","XXX","LFO","LEO","ELC","DIME","OMC","XQN","TP1","BTCS","DVC","BTX","DAO","SPR","CC","CGA","BKS","CYC","UNC","OPAL","PFC","XGR","IEC","UTC","APC","LTS","XBS","XAU","BUK","GML","VTA","BTG","TBC","PEERPLAYS","NTC","ACCI","BFX","VGC","GAY","GDC","SDC","SAFEX","XVC","AUR","PLU","XBY","NOTE","CLOAK","UNO","QRK","DGC","FLDC","RDD","VRS","CELL","XCN","SBD","DMD","JINN","ZCC","CURE","GLD","MOON","BTM","OBITS","XDN","BITCNY","RIC","OK","SPHR","BOST","WBB","CAGE","VNL","VTR","DEX","TAG","JBS","BBR","GRS","SRC","ICASH","BLOCKPAY","XVG","ZET","YOC","BTA","RISE","ADZ","TIX","INSANE","START","HUC","BITUSD","ZEIT","BRX","TRIG","MAX","HKG","BRK","SLK","LOG","MED","NBT","PANGEA","ABY","EFL","SCOT","BLITZ","VLT","XST","PND","MINT","XTC","IXC","CSC","TRUMP","BITB","GEO","EXCL","FCN","BTB","QORA","FIMK","MYR","NAS","TRC","CANN","VOX","PTC","ECC","SWIFT","NSR","CDN","XMG","DEM","KORE","VOOT","UIS","XCR","RBT","J","GLC","RBR","POST","TRUST","XWC","I0C","ORB","PLS","SMC","THC","BILS","JLH","DOPE","BYC","XSI","MZC","GRE","TOR","007","LTBC","DP","BLU","RBIES","ONEC","LOT","NRS","QTL","8BIT","TES","FC2","PTS","PIGGY","LDOGE","BABCOIN","KOBO","CBX","SLG","SF0","MRKT","XPY","GB","SXC","BITZ","BRIT","NKA","INFX","LXC","NOBL","MAC","CZC","ANC","BITS","LEAF","KR","HPC","HTML5","CREVA","FLT","UNB","NET","BITBTC","LTB","CNMT","SMLY","GAIA","MARYJ","SWARM","LIQUID","METAL","NTRN","TIT","HEX","XC","ESP2","EXE","SUPER","NXTV","ERY","TRI","CAP","QCN","MMNXT","FST","KARM","FRC","GCN","NXTPRIVACY","SKYNET","42","XPD","TRK","COMM","EXC","PXC","AMBER","DIEM","GAP","ACOIN","UFO","TEK","FRSH","CCN","BLC","YAC","BANX","EMD","PHS","NYAN","HYP","SYNC","ARG","BSTY","HBN","AU","RED","XDP","DEBUNE","COL","HYPER","GP","PXI","HZ","CORG","GUN","ARCO","C2","FIBRE","BQC","PRIVATEBET","STV","XJO","BIC","NODE","XCO","FLAP","U","BOB","BITGOLD","MMC","URO","CTM","BCX","XCH","RBBT","BVC","420G","CRYPT","FRK","MGW","BUN","ADN","PRT","CESC","BTQ","CYP","DTC","DRKC","URC","SOON","POP","EUC","RPC","CON","KDC","TRON","SLING","HAL","SONG","ICB","MRS","PHO","SHA","ARCH","LKY","MCN","ARI","QBK","PLNC","SPT","NEC","BLZ","CRAVE","NTR","COOL","LTCD","NXTTY","HVC","DARK","RIN","OC","VIOR","ZRC","SMBR","LSD","GEMZ","SFR","USDE","ELS","APEX","AM","XLB","SCORE","TAGR","JAY","DICE","HIRO","VCOIN","MEOW","SSD","SPA","NXTI","NOXT","CLR","RZR","SAT2","NYC","CACH","CASH","BET","ELT","CRAIG","MWC","TOP","DSB","BTCRY","GUE","DRZ","ZED","SHLD","XAI","DBL","LYC","YUM","ZS","GUA","CF","ANAL","ROS","BEN","ALN","QSLV","RT2","CRACK","JUDGE","SOLE","FIC","MTR","MAIA","1CR","GLYPH","PMP","MNE","GHC","CNL","JKC","P7C","ULTC","UTIL","PSEUD","SHADE","NMB","OSC","KUMA","AXR","CAIX","VDO","RIPO","QB","HAM","ISR","TAK","PYC","SOL","ROOT","EKN","MNC","COV","NRB","XDQ","ORO","CRT","CKC","BAT","LGD","TCO" ];
$( "#add_coin" ).autocomplete({ source: availableTags
});
// Show/Hide currency columns
function currencyColumns() { if (document.getElementById('curr_usd').checked) { $(".col_usd").each(function(){$(this).css({"display":"table-cell"});}); } else { $(".col_usd").each(function(){$(this).css({"display":"none"});}); } if (document.getElementById('curr_btc').checked) { $(".col_btc").each(function(){$(this).css({"display":"table-cell"});}); } else { $(".col_btc").each(function(){$(this).css({"display":"none"});}); } var checkbox_length = document.querySelectorAll('.currency_checkbox:checked').length; if(checkbox_length == 2){ document.getElementById("open_th_open").colSpan = "5"; document.getElementById("open_th_current").colSpan = "5"; document.getElementById("open_th_profit").colSpan = "4"; document.getElementById("closed_th_opened").colSpan = "5"; document.getElementById("closed_th_closed").colSpan = "5"; document.getElementById("closed_th_profit").colSpan = "4"; } else if (checkbox_length == 1){ document.getElementById("open_th_open").colSpan = "3"; document.getElementById("open_th_current").colSpan = "3"; document.getElementById("open_th_profit").colSpan = "2"; document.getElementById("closed_th_opened").colSpan = "3"; document.getElementById("closed_th_closed").colSpan = "3"; document.getElementById("closed_th_profit").colSpan = "2"; } else if (checkbox_length == 0){ document.getElementById("open_th_open").colSpan = "1"; document.getElementById("open_th_current").colSpan = "1"; document.getElementById("open_th_profit").colSpan = "1"; document.getElementById("closed_th_opened").colSpan = "1"; document.getElementById("closed_th_closed").colSpan = "1"; document.getElementById("closed_th_profit").colSpan = "1"; };
}
$("#curr_usd, #curr_btc").click(function (){ currencyColumns();
})
currencyColumns();
///////////////////////////////
/* CLOSING / EDITING TRADES */
/////////////////////////////
// Get the modals
var close_trade_modal = document.getElementById('close_trade_modal');
var edit_open_trade_modal = document.getElementById('edit_open_trade_modal')
var edit_closed_trade_modal = document.getElementById('edit_closed_trade_modal')
// When the user clicks anywhere outside of the modal, close it
window.onclick = function(event) { if (event.target == close_trade_modal) { close_trade_modal.style.display = "none"; } else if (event.target == edit_open_trade_modal) { edit_open_trade_modal.style.display = "none"; } else if (event.target == edit_closed_trade_modal) { edit_closed_trade_modal.style.display = "none"; }
}
// On keyup calc total vals, Closing modal
$('#close_trade_fieldset').keyup(function(){ var $val_usd_span = $('#closing_trade_total_val_usd'), $val_btc_span = $('#closing_trade_total_val_btc'), amount = $('#amount_closed').val(), // possible ID duplication ?!?!?! closed_price_usd = $('#closed_price_usd').val(), closed_price_btc = $('#closed_price_btc').val(), usd_calc = (amount * closed_price_usd).toFixed(2), btc_calc = (amount * closed_price_btc).toFixed(8); $val_usd_span.html(usd_calc); $val_btc_span.html(btc_calc);
});
// On keyup calc total vals, Editing open trades modal
$('#edit_open_trade_fieldset').keyup(function(){ var $val_usd_span = $('#editing_trade_total_val_usd'), $val_btc_span = $('#editing_trade_total_val_btc'), amount = $('#editing_amount').val(), closed_price_usd = $('#editing_opened_price_usd').val(), closed_price_btc = $('#editing_opened_price_btc').val(), usd_calc = (amount * closed_price_usd).toFixed(2), btc_calc = (amount * closed_price_btc).toFixed(8); $val_usd_span.html(usd_calc); $val_btc_span.html(btc_calc);
});
// On keyup calc total vals, Editing closed trades modal
$('#edit_closed_trade_fieldset').keyup(function(){ var $val_usd_span = $('#closed_editing_trade_profit_usd'), $val_btc_span = $('#closed_editing_trade_profit_btc'), amount = $('#closed_editing_amount').val(), opened_price_usd = $('#closed_editing_opened_price_usd').val(), opened_price_btc = $('#closed_editing_opened_price_btc').val(), opened_value_usd = amount * opened_price_usd, opened_value_btc = amount * opened_price_btc, closed_price_usd = $('#closed_editing_closed_price_usd').val(), closed_price_btc = $('#closed_editing_closed_price_btc').val(), closed_value_usd = amount * closed_price_usd, closed_value_btc = amount * closed_price_btc, profit_calc_usd = (closed_value_usd - opened_value_usd).toFixed(2), profit_calc_btc = (closed_value_btc - opened_value_btc).toFixed(8); $val_usd_span.html(profit_calc_usd); $val_btc_span.html(profit_calc_usd);
});
// CLOSE TRADE submit
$('#close_trade_submit_btn').click(function(){ // Get the closing data var trade_ref = $('#closing_trade_ref').html(), coin = $('#closing_trade_info_coin').html(), // amount_opened = $('#closing_trade_info_amount').html(), date_closed = $('#date_closed').val(), amount_closed = $('#amount_closed').val(), closed_price_usd = $('#closed_price_usd').val(), closed_price_btc = $('#closed_price_btc').val(), date_opened, amount_opened, price_opened_usd, price_opened_btc; // Get the opened data for (var i = 0; i < open_trades_data.length; i++ ) { // for each object (trade) in array var opened_ref = open_trades_data[i].ref; if (trade_ref == opened_ref) { var date_opened = open_trades_data[i].date_opened, amount_opened = open_trades_data[i].amount, price_opened_usd = open_trades_data[i].price_usd, price_opened_btc = open_trades_data[i].price_btc; } } // check amount closed and refer to open_trades_data if (amount_opened == amount_closed) { // if everything closed close_trade_modal.style.display = "none"; for (var i = 0; i < open_trades_data.length; i++ ) { // for each trade in array var opened_ref = open_trades_data[i].ref; if (trade_ref == opened_ref) { // match the reference open_trades_data.splice(i, 1); // remove entry from "open" array break; } } closed_trades_data.push({ // add the output to the closed trades array "ref":trade_ref, "coin":coin, "amount": amount_closed, "date_opened":date_opened, "price_opened_usd":price_opened_usd, "price_opened_btc":price_opened_btc, "date_closed":date_closed, "price_closed_usd":closed_price_usd, "price_closed_btc":closed_price_btc, }); $(".modal_fieldset input").each(function() { // Clear form $(this).val(""); }); $(".trade_info_span").each(function() { $(this).html(""); }); makeOpenTable(); makeClosedTable(); // remake the tables } else if (amount_opened > amount_closed){ // if less was removed close_trade_modal.style.display = "none"; for (var i = 0; i < open_trades_data.length; i++ ) { // for each trade in array var opened_ref = open_trades_data[i].ref; if (trade_ref == opened_ref) { // match the reference open_trades_data[i].amount = amount_opened - amount_closed; // deduct amount from "open" array } } closed_trades_data.push({ // add the output to the closed trades array "ref":trade_ref, "coin":coin, "amount": amount_closed, "date_opened":date_opened, "price_opened_usd":price_opened_usd, "price_opened_btc":price_opened_btc, "date_closed":date_closed, "price_closed_usd":closed_price_usd, "price_closed_btc":closed_price_btc, }); $(".modal_fieldset input").each(function() { // Clear form $(this).val(""); }); $(".trade_info_span").each(function() { $(this).html(""); }); makeOpenTable(); makeClosedTable(); } else if (amount_opened < amount_closed){ // if more was closed if (confirm("Are you sure you want to close more than you have?") == true) { close_trade_modal.style.display = "none"; for (var i = 0; i < open_trades_data.length; i++ ) { // for each trade in array var opened_ref = open_trades_data[i].ref; if (trade_ref == opened_ref) { // match the reference open_trades_data.splice(i, 1); // remove entry from "open" array break; } } closed_trades_data.push({ // add the output to the closed trades array "ref":trade_ref, "coin":coin, "amount": amount_closed, "date_opened":date_opened, "price_opened_usd":price_opened_usd, "price_opened_btc":price_opened_btc, "date_closed":date_closed, "price_closed_usd":closed_price_usd, "price_closed_btc":closed_price_btc, }); $(".modal_fieldset input").each(function() { // Clear form $(this).val(""); }); $(".trade_info_span").each(function() { $(this).html(""); }); makeOpenTable(); makeClosedTable(); // remake the tables } else { close_trade_modal.style.display = "none"; $(".modal_fieldset input").each(function() { // Clear form $(this).val(""); }); $(".trade_info_span").each(function() { $(this).html(""); }); } }
});
// EDIT OPEN TRADE submit
$('#edit_trade_submit_btn').click(function(){ var trade_ref = $('#editing_trade_ref').html(), opened_date = $('#editing_opened_date').val(), amount = $('#editing_amount').val(), price_usd = $('#editing_opened_price_usd').val(), price_btc = $('#editing_opened_price_btc').val(), manual_price_usd = $('#editing_current_price_usd').val(), manual_price_btc = $('#editing_current_price_btc').val(), manual_24hr_change = $('#editing_current_24hr_perc').val(); for (var i = 0; i < open_trades_data.length; i++ ) { // for each trade in array var opened_ref = open_trades_data[i].ref; if (trade_ref == opened_ref) { // match the reference open_trades_data[i].date_opened = opened_date; open_trades_data[i].amount = amount; open_trades_data[i].price_usd = price_usd; open_trades_data[i].price_btc = price_btc; open_trades_data[i].manual.price_usd = manual_price_usd, open_trades_data[i].manual.price_btc = manual_price_btc, open_trades_data[i].manual.cap24hrChange = manual_24hr_change; } } edit_open_trade_modal.style.display = "none"; makeOpenTable();
});
// EDIT CLOSED TRADE submit
$('#closed_edit_trade_submit_btn').click(function(){ var trade_ref = $('#editing_closed_trade_ref').html(), opened_date = $('#closed_editing_opened_date').val(), amount = $('#closed_editing_amount').val(), opened_price_usd = $('#closed_editing_opened_price_usd').val(), opened_price_btc = $('#closed_editing_opened_price_btc').val(), closed_date = $('#closed_editing_closed_date').val(), closed_price_usd = $('#closed_editing_closed_price_usd').val(), closed_price_btc = $('#closed_editing_closed_price_btc').val(); for (var i = 0; i < closed_trades_data.length; i++ ) { // for each trade in array var opened_ref = closed_trades_data[i].ref; if (trade_ref == opened_ref) { // match the reference closed_trades_data[i].date_opened = opened_date; closed_trades_data[i].amount = amount; closed_trades_data[i].price_opened_usd = opened_price_usd; closed_trades_data[i].price_opened_btc = opened_price_btc; closed_trades_data[i].date_closed = closed_date; closed_trades_data[i].price_closed_usd = closed_price_usd; closed_trades_data[i].price_closed_btc = closed_price_btc; } } edit_closed_trade_modal.style.display = "none"; makeClosedTable();
});
// CANCEL modal button
$('#close_trade_cancel_btn, #edit_trade_cancel_btn, #closed_edit_trade_cancel_btn').click(function(){ close_trade_modal.style.display = "none"; edit_open_trade_modal.style.display = "none"; edit_closed_trade_modal.style.display = "none"; $(".modal_fieldset input").each(function() { // Clear form $(this).val(""); }); $(".trade_info_span").each(function() { $(this).html(""); });
});
// TODAYS DATE button
$('#editing_today_btn').click(function(){ document.getElementById("editing_opened_date").valueAsDate = new Date();
});
$('#closing_today_btn').click(function(){ document.getElementById("date_closed").valueAsDate = new Date();
});
$('#closed_editing_opened_today_btn').click(function(){ document.getElementById("closed_editing_opened_date").valueAsDate = new Date();
});
$('#closed_editing_closed_today_btn').click(function(){ document.getElementById("closed_editing_closed_date").valueAsDate = new Date();
});
// AMOUNT ALL button
$('#closing_all_btn').click(function(){ var amount_opened = $('#closing_trade_info_amount').html(); $('#amount_closed').val(amount_opened);
});
// Autofill button
$('#add_auto_fill_btn').click(function(){ var coin = $('#add_coin').val().toUpperCase(); for (var i = 0; i < coincap_data.length; i++){ var coincap = coincap_data[i].short; if (coincap == coin){ var price_usd = coincap_data[i].price, price_btc = (price_usd/btc_price); } $('#add_price_usd').val(price_usd); $('#add_price_btc').val(price_btc); document.getElementById("add_date").valueAsDate = new Date(); }
})
$('#editing_open_auto_fill_btn').click(function(){ var coin = $('#editing_trade_info_coin').html(); for (var i = 0; i < coincap_data.length; i++){ var coincap = coincap_data[i].short; if (coincap == coin){ var price_usd = coincap_data[i].price, price_btc = (price_usd/btc_price).toFixed(8); } $('#editing_opened_price_usd').val(price_usd); $('#editing_opened_price_btc').val(price_btc); }
})
$('#closed_editing_opened_auto_fill_btn').click(function(){ var coin = $('#editing_closed_trade_info_coin').html(); alert(coin); for (var i = 0; i < coincap_data.length; i++){ var coincap = coincap_data[i].short; if (coincap == coin){ var price_usd = coincap_data[i].price, price_btc = (price_usd/btc_price).toFixed(8); } $('#closed_editing_opened_price_usd').val(price_usd); $('#closed_editing_opened_price_btc').val(price_btc); }
})
$('#closed_editing_closed_auto_fill_btn').click(function(){ var coin = $('#editing_closed_trade_info_coin').html(); for (var i = 0; i < coincap_data.length; i++){ var coincap = coincap_data[i].short; if (coincap == coin){ var price_usd = coincap_data[i].price, price_btc = (price_usd/btc_price).toFixed(8); } $('#closed_editing_closed_price_usd').val(price_usd); $('#closed_editing_closed_price_btc').val(price_btc); }
})
$('#closing_auto_fill_btn').click(function(){ var coin = $('#closing_trade_info_coin').html(); for (var i = 0; i < coincap_data.length; i++){ var coincap = coincap_data[i].short; if (coincap == coin){ var price_usd = coincap_data[i].price, price_btc = (price_usd/btc_price).toFixed(8); } $('#closed_price_usd').val(price_usd); $('#closed_price_btc').val(price_btc); }
})
/*
*/
CWB Trad Journal html - Script Codes
CWB Trad Journal html - Script Codes
Home Page Home
Developer Nathan Gregg
Username nathansonic
Uploaded December 25, 2022
Rating 3
Size 13,903 Kb
Views 6,072
Do you need developer help for CWB Trad Journal html?

Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!

Nathan Gregg (nathansonic) Script Codes
Create amazing blog posts with AI!

Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!