Compare commits
No commits in common. "fe8c55815db609be0d182eb8c7ee1ba629456218" and "1df8d90f90eb4a6e5ff80e140d41bdaf6d98b8c1" have entirely different histories.
fe8c55815d
...
1df8d90f90
@ -20,7 +20,7 @@ const element = document.getElementById('chart')
|
|||||||
|
|
||||||
|
|
||||||
function transformPoint({ X, Y }) {
|
function transformPoint({ X, Y }) {
|
||||||
return { x: new Date(X), y: Y }
|
return { x: new Date(X), y: Y * 100 }
|
||||||
}
|
}
|
||||||
|
|
||||||
const no = JSON.parse($("#chart-data").getAttribute("chart-data-p0")).map(transformPoint)
|
const no = JSON.parse($("#chart-data").getAttribute("chart-data-p0")).map(transformPoint)
|
||||||
@ -55,10 +55,8 @@ const config = {
|
|||||||
time: { unit: 'month' }
|
time: { unit: 'month' }
|
||||||
},
|
},
|
||||||
y: {
|
y: {
|
||||||
display: true,
|
|
||||||
text: 'price',
|
|
||||||
min: 0,
|
min: 0,
|
||||||
max: 1
|
max: 100
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"git.ekzyis.com/ekzyis/delphi.market/types"
|
"git.ekzyis.com/ekzyis/delphi.market/types"
|
||||||
"strconv"
|
"strconv"
|
||||||
"math"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
templ MarketForm(m types.Market, outcome int, q types.MarketQuote, uQ int) {
|
templ MarketForm(m types.Market, outcome int, q types.MarketQuote, uQ int) {
|
||||||
@ -19,16 +18,14 @@ templ MarketForm(m types.Market, outcome int, q types.MarketQuote, uQ int) {
|
|||||||
>
|
>
|
||||||
<input type="hidden" name="o" value={ fmt.Sprint(outcome) }/>
|
<input type="hidden" name="o" value={ fmt.Sprint(outcome) }/>
|
||||||
<div class="none col-span-2 htmx-request"></div>
|
<div class="none col-span-2 htmx-request"></div>
|
||||||
<label for="p">price:</label>
|
<label for="p">avg price per share:</label>
|
||||||
<div id="p">{ formatPrice(q.AvgPrice, 3) }</div>
|
<div id="p">{ formatPrice(q.AvgPrice) }</div>
|
||||||
<label for="q">shares:</label>
|
<label for="q">how many?</label>
|
||||||
<input
|
<input
|
||||||
id={ inputId(outcome) }
|
id={ inputId(outcome) }
|
||||||
name="q"
|
name="q"
|
||||||
class="text-black px-1"
|
class="text-black px-1"
|
||||||
type="number"
|
type="number"
|
||||||
step="100"
|
|
||||||
min="0"
|
|
||||||
autofocus
|
autofocus
|
||||||
hx-get={ fmt.Sprintf("/market/%d", m.Id) }
|
hx-get={ fmt.Sprintf("/market/%d", m.Id) }
|
||||||
hx-replace-url="true"
|
hx-replace-url="true"
|
||||||
@ -40,10 +37,10 @@ templ MarketForm(m types.Market, outcome int, q types.MarketQuote, uQ int) {
|
|||||||
hx-disabled-elt="next button"
|
hx-disabled-elt="next button"
|
||||||
hx-indicator={ hxIndicator(outcome) }
|
hx-indicator={ hxIndicator(outcome) }
|
||||||
/>
|
/>
|
||||||
<label for="total">total:</label>
|
<label for="total">you pay:</label>
|
||||||
<div id="total">{ formatPrice(q.TotalPrice, 3) }</div>
|
<div id="total">{ formatPrice(q.TotalPrice) }</div>
|
||||||
<label for="reward">{ "potential earn:" }</label>
|
<label for="reward">{ "if you win:" }</label>
|
||||||
<span id="reward" class={ colorize(q.Reward) }>+{ formatPrice(q.Reward, 3) }</span>
|
<div id="reward">+{ formatPrice(q.Reward) }</div>
|
||||||
<label for="uQ">you have:</label>
|
<label for="uQ">you have:</label>
|
||||||
<div id="uQ">{ fmt.Sprint(uQ) }</div>
|
<div id="uQ">{ fmt.Sprint(uQ) }</div>
|
||||||
<button type="submit" class="col-span-2">submit</button>
|
<button type="submit" class="col-span-2">submit</button>
|
||||||
@ -64,17 +61,6 @@ func hxIndicator(outcome int) string {
|
|||||||
formId(outcome), formId(outcome), formId(outcome))
|
formId(outcome), formId(outcome), formId(outcome))
|
||||||
}
|
}
|
||||||
|
|
||||||
func formatPrice(p float64, n int) string {
|
func formatPrice(p float64) string {
|
||||||
if p == 0 || math.IsNaN(p) {
|
return fmt.Sprintf("%v sats", strconv.FormatFloat(p, 'f', 3, 64))
|
||||||
return "0 sats"
|
|
||||||
}
|
|
||||||
return fmt.Sprintf("%v sats", strconv.FormatFloat(p, 'f', n, 64))
|
|
||||||
}
|
|
||||||
|
|
||||||
func colorize(f float64) string {
|
|
||||||
eps := 1e-5
|
|
||||||
if f-eps > 0 {
|
|
||||||
return "text-success"
|
|
||||||
}
|
|
||||||
return "text-reset"
|
|
||||||
}
|
}
|
Loading…
x
Reference in New Issue
Block a user