Skip to content

Commit

Permalink
tmp
Browse files Browse the repository at this point in the history
  • Loading branch information
norwnd committed Nov 24, 2024
1 parent bc5e0c6 commit ad9d264
Show file tree
Hide file tree
Showing 9 changed files with 35 additions and 69 deletions.
2 changes: 2 additions & 0 deletions client/core/bookie.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package core

import (
"encoding/hex"
"errors"
"fmt"
"sync"
Expand Down Expand Up @@ -374,6 +375,7 @@ func (b *bookie) book() *OrderBook {
// be supplied.
func (b *bookie) minifyOrder(oid dex.Bytes, trade *msgjson.TradeNote, epoch uint64) *MiniOrder {
return &MiniOrder{
ID: hex.EncodeToString(oid),
Qty: float64(trade.Quantity) / float64(b.baseUnits.Conventional.ConversionFactor),
QtyAtomic: trade.Quantity,
Rate: calc.ConventionalRate(trade.Rate, b.baseUnits, b.quoteUnits),
Expand Down
1 change: 1 addition & 0 deletions client/core/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -726,6 +726,7 @@ func newDisplayIDFromSymbols(base, quote string) string {
// MiniOrder is minimal information about an order in a market's order book.
// Replaced MiniOrder, which had a float Qty in conventional units.
type MiniOrder struct {
ID string `json:"id"`
Qty float64 `json:"qty"`
QtyAtomic uint64 `json:"qtyAtomic"`
Rate float64 `json:"rate"`
Expand Down
4 changes: 2 additions & 2 deletions client/mm/mm_basic.go
Original file line number Diff line number Diff line change
Expand Up @@ -489,9 +489,9 @@ func (m *basicMarketMaker) rebalance(newEpoch uint64) {
}

// simple work-around for not competing with my own (bot's) orders in Bison book,
// every 20th epoch (happens every 5m) we simply revoke our orders so that we can
// every 4th epoch (happens every 60s) we simply revoke our orders so that we can
// re-book these with correct price (presumably on that very same epoch).
if newEpoch%20 == 0 {
if newEpoch%4 == 0 {
m.tryCancelOrders(m.ctx, &newEpoch, false)
}

Expand Down
1 change: 1 addition & 0 deletions client/webserver/site/src/css/colors.scss
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ body:not(.dark) {
--text-grey: #777;
--border-color: #ddd;
--hint-color: #4397cd;
--violet-color: #7F00FF;

// links
--link-color: #2a71d5;
Expand Down
6 changes: 6 additions & 0 deletions client/webserver/site/src/css/icons.scss
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,12 @@
color: var(--buy-color);
}

.ico-own-book-order::before {
content: "\e90c";
display: inline-block;
color: var(--violet-color);
}

.ico-bell::before {
content: "\e900";
}
Expand Down
23 changes: 0 additions & 23 deletions client/webserver/site/src/css/market.scss
Original file line number Diff line number Diff line change
Expand Up @@ -327,15 +327,6 @@ div[data-handler=markets] {
}
}

#epochLine,
#durBttnBox {
position: absolute;
left: 65px;
top: 5px;
background-color: var(--section-bg);
z-index: 1;
}

#durBttnBox {
.candle-dur-bttn {
background-color: var(--section-bg);
Expand All @@ -356,20 +347,6 @@ div[data-handler=markets] {
}
}

#epochLine {
@extend .flex-center;

.epoch-line {
display: inline-block;
border-top: 3px dotted #626262;
width: 25px;
height: 0;
margin-right: 5px;
position: relative;
top: 1px;
}
}

#loaderMsg {
color: #777;
}
Expand Down
3 changes: 1 addition & 2 deletions client/webserver/site/src/html/markets.tmpl
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,7 @@
</td>
<td class="text-end text-nowrap ps-2">
<span class="text-end ico-check fs13 pe-1 d-hide" data-tmpl="epoch"></span>
<span class="text-end ico-own-book-order fs13 pe-1 d-hide" data-tmpl="ownBookOrder"></span>
<span data-tmpl="rate">-</span>
</td>
</tr>
Expand Down Expand Up @@ -494,8 +495,6 @@
<span data-tmpl="status"></span>
<span data-tmpl="activeLight" class="active-indicator active"></span>
</span>
<div data-tmpl="expander" class="p-1 pointer hoverbg fs11 ico-arrowdown"></div>

<!-- <span class="fs11 ico-open ms-2"></span> -->
</div>
<div data-tmpl="details" class="order-details border-top border-bottom d-hide">
Expand Down
63 changes: 21 additions & 42 deletions client/webserver/site/src/js/markets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import {
CandleChart,
DepthLine,
CandleReporters,
DepthMarker,
Wave
} from './charts'
import { postJSON } from './http'
Expand Down Expand Up @@ -443,11 +442,6 @@ export default class MarketsPage extends BasePage {
})
setDisclaimerAckViz(State.fetchLocal(State.orderDisclaimerAckedLK))

bind(page.userOrders, 'mouseleave', () => {
this.activeMarkerRate = null
this.setDepthMarkers()
})

const stats0 = page.marketStats
const stats1 = stats0.cloneNode(true) as PageElement
stats1.classList.add('listopen')
Expand Down Expand Up @@ -1468,7 +1462,6 @@ export default class MarketsPage extends BasePage {
Doc.empty(this.page.sellRows)
return
}
Doc.show(this.page.epochLine)
this.recentMatches = data.book.recentMatches ?? []
this.refreshRecentMatchesTable()
}
Expand Down Expand Up @@ -1615,11 +1608,6 @@ export default class MarketsPage extends BasePage {
details.type.textContent = OrderUtil.orderTypeText(ord.type)
this.updateMetaOrder(mord)

Doc.bind(div, 'mouseenter', () => {
this.activeMarkerRate = ord.rate
this.setDepthMarkers()
})

const showCancel = (e: Event) => {
e.stopPropagation()
this.showCancel(div, orderID)
Expand Down Expand Up @@ -1713,7 +1701,6 @@ export default class MarketsPage extends BasePage {
app().bindTooltips(div)
}
Doc.setVis(unreadyOrders, page.unreadyOrdersMsg)
this.setDepthMarkers()
}

/*
Expand All @@ -1740,30 +1727,6 @@ export default class MarketsPage extends BasePage {
details.settled.textContent = `${(OrderUtil.settled(ord) / ord.qty * 100).toFixed(1)}%`
}

/* setMarkers sets the depth chart markers for booked orders. */
setDepthMarkers () {
const markers: Record<string, DepthMarker[]> = {
buys: [],
sells: []
}
const rateFactor = this.market.rateConversionFactor
for (const { ord } of Object.values(this.metaOrders)) {
if (ord.rate && ord.status === OrderUtil.StatusBooked) {
if (ord.sell) {
markers.sells.push({
rate: ord.rate / rateFactor,
active: ord.rate === this.activeMarkerRate
})
} else {
markers.buys.push({
rate: ord.rate / rateFactor,
active: ord.rate === this.activeMarkerRate
})
}
}
}
}

/* updateTitle update the browser title based on the midgap value and the
* selected assets.
*/
Expand Down Expand Up @@ -2474,7 +2437,6 @@ export default class MarketsPage extends BasePage {
(oldStatus === OrderUtil.StatusEpoch && ord.status === OrderUtil.StatusBooked) ||
(oldStatus === OrderUtil.StatusBooked && ord.status > OrderUtil.StatusBooked)
) {
this.setDepthMarkers()
this.updateReputation()
this.mm.readBook()
}
Expand Down Expand Up @@ -2856,9 +2818,7 @@ export default class MarketsPage extends BasePage {
*/
orderTableRow (orderBin: MiniOrder[]): OrderRow {
const tr = this.page.orderRowTmpl.cloneNode(true) as OrderRow
const { baseUnitInfo, quoteUnitInfo, cfg: { ratestep: rateStep } } = this.market
const manager = new OrderTableRowManager(tr, orderBin, baseUnitInfo, quoteUnitInfo, rateStep)
tr.manager = manager
tr.manager = new OrderTableRowManager(tr, orderBin, this.market)
return tr
}

Expand Down Expand Up @@ -3320,7 +3280,9 @@ class OrderTableRowManager {
epoch: boolean
baseUnitInfo: UnitInfo

constructor (tableRow: HTMLElement, orderBin: MiniOrder[], baseUnitInfo: UnitInfo, quoteUnitInfo: UnitInfo, rateStep: number) {
constructor (tableRow: HTMLElement, orderBin: MiniOrder[], market: CurrentMarket) {
const { baseUnitInfo, quoteUnitInfo, cfg: { ratestep: rateStep } } = market

this.tableRow = tableRow
const page = this.page = Doc.parseTemplate(tableRow)
this.orderBin = orderBin
Expand All @@ -3330,6 +3292,23 @@ class OrderTableRowManager {
this.baseUnitInfo = baseUnitInfo
const rateText = Doc.formatRateFullPrecision(this.msgRate, baseUnitInfo, quoteUnitInfo, rateStep)
Doc.setVis(this.isEpoch(), this.page.epoch)

// see if we need to add own order marker to this row
const userOrders = app().orders(market.dex.host, marketID(market.baseCfg.symbol, market.quoteCfg.symbol))
for (const bin of orderBin) {
let ownOrderSpotted = false
for (const userOrder of userOrders) {
if (userOrder.id === bin.id) {
ownOrderSpotted = true
Doc.show(this.page.ownBookOrder)
break
}
}
if (ownOrderSpotted) {
break
}
}

if (this.msgRate === 0) {
page.rate.innerText = 'market'
} else {
Expand Down
1 change: 1 addition & 0 deletions client/webserver/site/src/js/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -709,6 +709,7 @@ export interface BookUpdate {
}

export interface MiniOrder {
id: string
qty: number
qtyAtomic: number
rate: number
Expand Down

0 comments on commit ad9d264

Please sign in to comment.