Parse example bets from spreadsheet

This commit is contained in:
Austin Chen 2021-11-30 14:50:50 -08:00
parent f51a0ef1ae
commit 81c6da7c58
4 changed files with 95 additions and 2 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
.DS_Store

View File

@ -3,11 +3,11 @@
// Check out https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup // Check out https://v3.vuejs.org/api/sfc-script-setup.html#sfc-script-setup
import HelloWorld from './components/HelloWorld.vue' import HelloWorld from './components/HelloWorld.vue'
import LoginExample from './components/LoginExample.vue' import LoginExample from './components/LoginExample.vue'
import Simulator from './components/Simulator.vue'
</script> </script>
<template> <template>
<img alt="Vue logo" src="./assets/logo.png" /> <Simulator />
<LoginExample />
</template> </template>
<style> <style>

View File

@ -0,0 +1,34 @@
<template>
<div class="overflow-x-auto px-12">
<table class="table">
<thead>
<tr>
<th>Order #</th>
<th>Yes bid</th>
<th>No Bid</th>
<th>Implied Probability</th>
<th>Payout</th>
</tr>
</thead>
<tbody>
<tr v-for="(entry, i) in entries">
<th>{{ i }}</th>
<td>{{ entry.yesBid || '' }}</td>
<td>{{ entry.noBid || '' }}</td>
<td>{{ entry.prob }}</td>
<td>{{ entry.payout }}</td>
</tr>
</tbody>
</table>
</div>
</template>
<script setup lang="ts">
import { bids } from './orders'
const entries = bids.map((bid) => ({
...bid,
prob: 0.646,
payout: 1.23,
}))
</script>

View File

@ -0,0 +1,58 @@
const data = `1,9
8,
,1
1,
,1
1,
,5
5,
,5
5,
,1
1,
100,
,10
10,
,10
10,
,10
10,
,10
10,
,10
10,
,10
10,
,10
10,
,10
10,
,10
10,
,10
10,
,10
10,
,10
10,
,10
10,
,10
10,
,10
10,
,10
10,
,10
`
// Parse data into Yes/No orders
// E.g. `8,\n,1\n1,` =>
// [{yesBid: 8, noBid: 0}, {yesBid: 0, noBid: 1}, {yesBid: 1, noBid: 0}]
export const bids = data.split('\n').map((line) => {
const [yesBid, noBid] = line.split(',')
return {
yesBid: parseInt(yesBid || '0'),
noBid: parseInt(noBid || '0'),
}
})