Documentation
¶
Overview ¶
Package portfolio persists bot balance snapshots (each tagged with the token's USD price at capture time) to a local SQLite database, and computes PnL from them.
There is no per-trade ledger available from the bidder daemon -- only balance snapshots (see ActionLogBalance in the bidder manager package) -- so PnL here is defined as a mark-to-market comparison: the market value of the portfolio at its earliest known snapshot vs. its latest, not a sum of realized trade gains/losses.
Index ¶
- type BotKey
- type DB
- func (d *DB) Accounts() ([]sgo.PublicKey, error)
- func (d *DB) AccountsForBot(bot BotKey) ([]sgo.PublicKey, error)
- func (d *DB) Bots() ([]BotKey, error)
- func (d *DB) Close() error
- func (d *DB) DB() *sql.DB
- func (d *DB) FilePath() string
- func (d *DB) Insert(s Snapshot) error
- func (d *DB) Positions(account sgo.PublicKey) ([]MintPosition, error)
- type MintPosition
- type Snapshot
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type BotKey ¶
BotKey identifies one bot -- a bot is exactly one market+pipeline pair, which is how the bidder daemon itself tags every balance log entry.
type DB ¶
type DB struct {
// contains filtered or unexported fields
}
DB wraps a SQLite connection holding balance_snapshot history.
func Open ¶
Open opens (or creates) the portfolio database at path and applies its schema.
func (*DB) Accounts ¶
Accounts returns every distinct account that has at least one snapshot.
func (*DB) AccountsForBot ¶
AccountsForBot returns every distinct account that has reported a balance under the given bot.
func (*DB) Bots ¶
Bots returns every distinct (market, pipeline) pair seen across all balance snapshots -- one entry per bot that has ever reported a balance.
func (*DB) DB ¶
DB returns the underlying *sql.DB, for passing to generic SQL tooling (e.g. the dashboard's table explorer) that shouldn't need its own separately-pooled connection to the same file.
type MintPosition ¶
type MintPosition struct {
Mint sgo.PublicKey
Market sgo.PublicKey
Pipeline sgo.PublicKey
StartTime time.Time
StartBalance uint64
StartDecimals *uint8
StartUSDPrice *float64
StartUSDValue *float64 // nil if StartUSDPrice unknown
LatestTime time.Time
LatestBalance uint64
LatestDecimals *uint8
LatestUSDPrice *float64
LatestUSDValue *float64
DeltaUSDValue *float64 // LatestUSDValue - StartUSDValue; nil unless both known
}
MintPosition is one mint's starting vs. current mark-to-market value within a single account's history. Market/Pipeline identify which bot (a bot is exactly one market+pipeline pair) the position's latest snapshot was reported under.
Source Files
¶
- portfolio.go