Skip to content

Commit

Permalink
Add data table + version update
Browse files Browse the repository at this point in the history
  • Loading branch information
samgozman committed May 18, 2021
1 parent 4ddcebf commit cbf0865
Show file tree
Hide file tree
Showing 5 changed files with 59 additions and 10 deletions.
4 changes: 2 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tightshorts",
"version": "1.0.3",
"version": "1.0.4",
"description": "Tight Shorts - Finra short sale volume",
"scripts": {
"build": "parcel build web/main.html web/static/liveChart.html",
Expand Down
15 changes: 14 additions & 1 deletion web/css/styles.css
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
margin: -4px 0px;
}

a.navbar-item.is-active,
a.navbar-item.is-active,
a.navbar-item.is-active:not(:focus):not(:hover) {
background-color: #fafafa;
}
Expand Down Expand Up @@ -43,6 +43,12 @@ a.navbar-item.is-active:not(:focus):not(:hover) {
overflow: hidden;
}

/* Table */
.table-container {
max-height: 360px;
overflow-y: auto;
}

/* Octocat */
.octocat {
border: 0;
Expand All @@ -65,4 +71,11 @@ a.navbar-item.is-active:not(:focus):not(:hover) {

.qrcode {
max-width: 140px;
}

/* Responsive fixes */
@media (max-width: 410px) {
.table>tbody {
font-size: 0.7em;
}
}
30 changes: 25 additions & 5 deletions web/js/chart.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,24 @@ import resizeDetector from 'element-resize-detector'
import Legend from './Legend.mjs'
import color from './color.mjs'

// Gen table
const table_tbody = document.getElementById('table-body')

const createTableRow = (table, data, sv, sev, vol) => {
let row = table.insertRow()
row.insertCell(0).innerHTML = data.replace(/T(.*)/g, '')
row.insertCell(1).innerHTML = sv
row.insertCell(2).innerHTML = sev
row.insertCell(3).innerHTML = vol
}

// Define chart properties
const chartPercent = createChart(document.getElementById('chartPercent'), {
width: 800,
height: 360,
localization: {
locale: 'en-US',
},
locale: 'en-US',
},
rightPriceScale: {
scaleMargins: {
top: 0.1,
Expand Down Expand Up @@ -45,8 +56,8 @@ const chartVolume = createChart(document.getElementById('chartVolume'), {
width: 800,
height: 360,
localization: {
locale: 'en-US',
},
locale: 'en-US',
},
rightPriceScale: {
scaleMargins: {
top: 0.1,
Expand Down Expand Up @@ -198,7 +209,6 @@ document.getElementById('search').addEventListener('submit', async (e) => {
// Fetch data
const ticker = document.getElementById('input_ticker').value.toUpperCase()
try {
// const _csrf = document.getElementById('_csrf').value
const response = await getResponse(ticker)

const data_shortVolumeRatio = []
Expand All @@ -208,6 +218,9 @@ document.getElementById('search').addEventListener('submit', async (e) => {
const data_shortVolume = []
const data_shortExemptVolume = []

// Clear table
table_tbody.innerHTML = ''

// Prepare data
for (const el of response.volume) {
data_shortVolumeRatio.push({
Expand Down Expand Up @@ -258,6 +271,13 @@ document.getElementById('search').addEventListener('submit', async (e) => {
},
})

// Generate table
let reversed_array = response.volume
reversed_array.reverse()
for (const [i, el] of reversed_array.entries()) {
if (i < 30) createTableRow(table_tbody, el.date, el.shortVolume, el.shortExemptVolume, el.totalVolume)
}

// Load tragingview live chart
document.getElementById('iframe_chart').src = 'static/liveChart.html?stock=' + ticker
} catch (error) {
Expand Down
18 changes: 17 additions & 1 deletion web/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,23 @@ <h1 class="title is-3"> Tight Shorts <sup class="is-size-7">
</div>
</div>
<div class="column is-half is-full-mobile">
<p>Placeholder for table</p>
<!-- Table -->
<div class="table-container">
<table class="table is-hoverable is-fullwidth">
<thead>
<tr>
<th>Date</th>
<th><abbr title="Short Volume">SV</abbr></th>
<th><abbr title="Short Exempt Volume">SEV</abbr></th>
<th><abbr title="Total volume">Vol</abbr></th>
</tr>
</thead>
<tbody id="table-body">
<!-- Table: elements -->
</tbody>
</table>
</div>
<!-- Table: ends -->
</div>
</div>
<p><strong>Disclaimer:</strong> The data on the chart is limited to the combined trading volume on the
Expand Down

0 comments on commit cbf0865

Please sign in to comment.