tradingstore

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 14, 2025 License: AGPL-3.0 Imports: 14 Imported by: 0

README

Trading Store Open in Gitpod

Tests Status Go Report Card PkgGoDev

TradingStore is a Go package for storing and managing financial market data, including OHLCV (Open, High, Low, Close, Volume) price data and instrument definitions.

Features

  • Store price data with OHLCV format
  • Manage instrument definitions (symbols, exchanges, asset classes)
  • Query price and instrument data with flexible filters
  • Support for different asset classes (Currency, ETF, Index, REIT, Stock)
  • Supports multiple database storages (SQLite, MySQL, or PostgreSQL)

Usage Example

package main

import (
    "context"
    "database/sql"
    "fmt"
    "log"

    "github.com/gouniverse/tradingstore"
    _ "modernc.org/sqlite"
)

func main() {
    // Open a database connection
    db, err := sql.Open("sqlite", "trading.db")
    if err != nil {
        log.Fatal(err)
    }
    defer db.Close()

    // Create a new trading store
    store, err := tradingstore.NewStore(tradingstore.NewStoreOptions{
        PriceTableName:      "prices",
        InstrumentTableName: "instruments",
        DB:                  db,
        AutomigrateEnabled:  true,
    })
    if err != nil {
        log.Fatal(err)
    }

    ctx := context.Background()

    // Create a new instrument
    instrument := store.NewInstrument().
        SetSymbol("AAPL").
        SetExchange("NASDAQ").
        SetAssetClass("STOCK").
        SetDescription("Apple Inc.")

    if err := store.InstrumentCreate(ctx, instrument); err != nil {
        log.Fatal(err)
    }

    // Create a price entry
    price := store.NewPrice().
        SetSymbol("AAPL").
        SetExchange("NASDAQ").
        SetTime("2023-06-01T16:00:00Z").
        SetOpen("180.25").
        SetHigh("182.50").
        SetLow("179.80").
        SetClose("181.75").
        SetVolume("34250000")

    if err := store.PriceCreate(ctx, price); err != nil {
        log.Fatal(err)
    }

    // Query prices
    prices, err := store.PriceList(ctx, store.PriceQuery(ctx).
        SetSymbol("AAPL").
        SetTimeGte("2023-06-01T00:00:00Z").
        SetTimeLte("2023-06-30T23:59:59Z"))
    if err != nil {
        log.Fatal(err)
    }

    for _, p := range prices {
        fmt.Printf("AAPL on %s: Open=%s, Close=%s\n",
            p.GetTime(), p.GetOpen(), p.GetClose())
    }
}

Architecture

classDiagram
    class StoreInterface {
        <<interface>>
        +AutoMigrate() error
        +DB() *sql.DB
        +EnableDebug(bool)
        +NewPrice() PriceInterface
        +NewInstrument() InstrumentInterface
        +PriceCreate(ctx, price) error
        +PriceFindByID(ctx, id) PriceInterface
        +PriceQuery(ctx) PriceQueryInterface
        +InstrumentCreate(ctx, instrument) error
        +InstrumentFindByID(ctx, id) InstrumentInterface
        +InstrumentQuery(ctx) InstrumentQueryInterface
    }

    class Store {
        -priceTableName string
        -instrumentTableName string
        -db *sql.DB
        -dbDriverName string
        -automigrateEnabled bool
        -debugEnabled bool
        -sqlLogger *slog.Logger
        +AutoMigrate() error
        +DB() *sql.DB
        +EnableDebug(bool)
    }

    class PriceInterface {
        <<interface>>
        +Data() map[string]string
        +ID() string
        +SetID(id) PriceInterface
        +GetOpen() string
        +GetOpenFloat() float64
        +SetOpen(open) PriceInterface
        +GetHigh() string
        +GetHighFloat() float64
        +SetHigh(high) PriceInterface
        +GetLow() string
        +GetLowFloat() float64
        +SetLow(low) PriceInterface
        +GetClose() string
        +GetCloseFloat() float64
        +SetClose(close) PriceInterface
        +GetVolume() string
        +GetVolumeFloat() float64
        +SetVolume(volume) PriceInterface
        +GetTime() string
        +GetTimeCarbon() carbon.Carbon
        +SetTime(time) PriceInterface
    }

    class InstrumentInterface {
        <<interface>>
        +Data() map[string]string
        +ID() string
        +SetID(id) InstrumentInterface
        +GetSymbol() string
        +SetSymbol(symbol) InstrumentInterface
        +GetExchange() string
        +SetExchange(exchange) InstrumentInterface
        +GetAssetClass() string
        +SetAssetClass(assetClass) InstrumentInterface
        +GetDescription() string
        +SetDescription(description) InstrumentInterface
    }

    class Price {
        +DataObject
    }

    class Instrument {
        +DataObject
    }

    class PriceQueryInterface {
        <<interface>>
        +SetAssetClass(assetClass) PriceQueryInterface
        +SetExchange(exchange) PriceQueryInterface
        +Count() int
        +Get() []PriceInterface
        +SetSymbol(symbol) PriceQueryInterface
        +SetTimeGte(timeFrom) PriceQueryInterface
        +SetTimeLte(timeTo) PriceQueryInterface
    }

    class InstrumentQueryInterface {
        <<interface>>
        +SetAssetClass(assetClass) InstrumentQueryInterface
        +SetExchange(exchange) InstrumentQueryInterface
        +Count() int
        +Get() []InstrumentInterface
        +SetSymbol(symbol) InstrumentQueryInterface
        +SetSymbolLike(symbolLike) InstrumentQueryInterface
    }

    StoreInterface <|.. Store
    PriceInterface <|.. Price
    InstrumentInterface <|.. Instrument
    Store --> PriceInterface : creates
    Store --> InstrumentInterface : creates
    Store --> PriceQueryInterface : provides
    Store --> InstrumentQueryInterface : provides

License

This project is licensed under the GNU Affero General Public License v3.0 (AGPL-3.0). You can find a copy of the license at https://www.gnu.org/licenses/agpl-3.0.en.html

For commercial use, please use my contact page to obtain a commercial license.

Documentation

Index

Constants

View Source
const ASSET_CLASS_CURRENCY = "CURRENCY"
View Source
const ASSET_CLASS_ETF = "ETF"
View Source
const ASSET_CLASS_INDEX = "INDEX"
View Source
const ASSET_CLASS_REIT = "REIT"
View Source
const ASSET_CLASS_STOCK = "STOCK"
View Source
const ASSET_CLASS_UNKNOWN = "UNKNOWN"
View Source
const COLUMN_ASSET_CLASS = "asset_class"
View Source
const COLUMN_CLOSE = "close"
View Source
const COLUMN_CREATED_AT = "created_at"
View Source
const COLUMN_DELETED_AT = "deleted_at"
View Source
const COLUMN_EXCHANGE = "exchange"
View Source
const COLUMN_HIGH = "high"
View Source
const COLUMN_ID = "id"
View Source
const COLUMN_LOW = "low"
View Source
const COLUMN_OPEN = "open"
View Source
const COLUMN_SYMBOL = "symbol"
View Source
const COLUMN_TIME = "time"
View Source
const COLUMN_UPDATED_AT = "updated_at"
View Source
const COLUMN_VOLUME = "volume"
View Source
const NIL_FLOAT = -0.0000000001

Variables

This section is empty.

Functions

This section is empty.

Types

type Instrument

type Instrument struct {
	dataobject.DataObject
}

Instrument represents a trading instrument data object for storing in the database

func (*Instrument) CreatedAt

func (i *Instrument) CreatedAt() string

func (*Instrument) DeletedAt

func (i *Instrument) DeletedAt() string

func (*Instrument) GetAssetClass

func (instrument *Instrument) GetAssetClass() string

func (*Instrument) GetDescription

func (instrument *Instrument) GetDescription() string

func (*Instrument) GetExchange

func (instrument *Instrument) GetExchange() string

func (*Instrument) GetSymbol

func (instrument *Instrument) GetSymbol() string

func (*Instrument) ID

func (instrument *Instrument) ID() string

func (*Instrument) SetAssetClass

func (instrument *Instrument) SetAssetClass(assetClass string) InstrumentInterface

func (*Instrument) SetCreatedAt

func (i *Instrument) SetCreatedAt(createdAt string) *Instrument

func (*Instrument) SetDeletedAt

func (i *Instrument) SetDeletedAt(deletedAt string) *Instrument

func (*Instrument) SetDescription

func (instrument *Instrument) SetDescription(description string) InstrumentInterface

func (*Instrument) SetExchange

func (instrument *Instrument) SetExchange(exchange string) InstrumentInterface

func (*Instrument) SetID

func (instrument *Instrument) SetID(id string) InstrumentInterface

func (*Instrument) SetSymbol

func (instrument *Instrument) SetSymbol(symbol string) InstrumentInterface

func (*Instrument) SetUpdatedAt

func (i *Instrument) SetUpdatedAt(updatedAt string) *Instrument

func (*Instrument) UpdatedAt

func (i *Instrument) UpdatedAt() string

type InstrumentInterface

type InstrumentInterface interface {
	// from dataobject
	Data() map[string]string
	DataChanged() map[string]string
	MarkAsNotDirty()

	// setters and getters
	ID() string
	SetID(id string) InstrumentInterface

	GetSymbol() string
	SetSymbol(symbol string) InstrumentInterface

	GetExchange() string
	SetExchange(exchange string) InstrumentInterface

	GetAssetClass() string
	SetAssetClass(assetClass string) InstrumentInterface

	GetDescription() string
	SetDescription(description string) InstrumentInterface
}

func NewInstrument

func NewInstrument() InstrumentInterface

func NewInstrumentFromExistingData

func NewInstrumentFromExistingData(data map[string]string) InstrumentInterface

type InstrumentQuery

type InstrumentQuery struct {
	// contains filtered or unexported fields
}

InstrumentQuery implements the InstrumentQueryInterface

func (*InstrumentQuery) AssetClass

func (iq *InstrumentQuery) AssetClass() string

AssetClass returns the asset class

func (*InstrumentQuery) Columns

func (iq *InstrumentQuery) Columns() []string

Columns returns the columns to select

func (*InstrumentQuery) Exchange

func (iq *InstrumentQuery) Exchange() string

Exchange returns the exchange

func (*InstrumentQuery) HasAssetClass

func (iq *InstrumentQuery) HasAssetClass() bool

HasAssetClass returns true if the asset class is set

func (*InstrumentQuery) HasExchange

func (iq *InstrumentQuery) HasExchange() bool

HasExchange returns true if the exchange is set

func (*InstrumentQuery) HasID

func (iq *InstrumentQuery) HasID() bool

HasID returns true if the id is set

func (*InstrumentQuery) HasIDIn

func (iq *InstrumentQuery) HasIDIn() bool

HasIDIn returns true if the id in is set

func (*InstrumentQuery) HasLimit

func (iq *InstrumentQuery) HasLimit() bool

HasLimit returns true if the limit is set

func (*InstrumentQuery) HasOffset

func (iq *InstrumentQuery) HasOffset() bool

HasOffset returns true if the offset is set

func (*InstrumentQuery) HasOrderBy

func (iq *InstrumentQuery) HasOrderBy() bool

HasOrderBy returns true if the order by is set

func (*InstrumentQuery) HasSortDirection

func (iq *InstrumentQuery) HasSortDirection() bool

HasSortDirection returns true if the sort direction is set

func (*InstrumentQuery) HasSymbol

func (iq *InstrumentQuery) HasSymbol() bool

HasSymbol returns true if the symbol is set

func (*InstrumentQuery) HasSymbolLike

func (iq *InstrumentQuery) HasSymbolLike() bool

HasSymbolLike returns true if the symbol like is set

func (*InstrumentQuery) ID

func (iq *InstrumentQuery) ID() string

ID returns the id

func (*InstrumentQuery) IDIn

func (iq *InstrumentQuery) IDIn() []string

IDIn returns the id in

func (*InstrumentQuery) IsCountOnly

func (iq *InstrumentQuery) IsCountOnly() bool

IsCountOnly returns true if the count only option is set

func (*InstrumentQuery) Limit

func (iq *InstrumentQuery) Limit() int

Limit returns the limit

func (*InstrumentQuery) Offset

func (iq *InstrumentQuery) Offset() int

Offset returns the offset

func (*InstrumentQuery) OrderBy

func (iq *InstrumentQuery) OrderBy() string

OrderBy returns the order by

func (*InstrumentQuery) SetAssetClass

func (iq *InstrumentQuery) SetAssetClass(assetClass string) InstrumentQueryInterface

SetAssetClass sets the asset class

func (*InstrumentQuery) SetCountOnly

func (iq *InstrumentQuery) SetCountOnly(countOnly bool) InstrumentQueryInterface

SetCountOnly sets the count only option

func (*InstrumentQuery) SetExchange

func (iq *InstrumentQuery) SetExchange(exchange string) InstrumentQueryInterface

SetExchange sets the exchange

func (*InstrumentQuery) SetID

SetID sets the id

func (*InstrumentQuery) SetIDIn

func (iq *InstrumentQuery) SetIDIn(ids []string) InstrumentQueryInterface

SetIDIn sets the id in

func (*InstrumentQuery) SetLimit

func (iq *InstrumentQuery) SetLimit(limit int) InstrumentQueryInterface

SetLimit sets the limit

func (*InstrumentQuery) SetOffset

func (iq *InstrumentQuery) SetOffset(offset int) InstrumentQueryInterface

SetOffset sets the offset

func (*InstrumentQuery) SetOrderBy

func (iq *InstrumentQuery) SetOrderBy(orderBy string) InstrumentQueryInterface

SetOrderBy sets the order by

func (*InstrumentQuery) SetSortDirection

func (iq *InstrumentQuery) SetSortDirection(sortDirection string) InstrumentQueryInterface

SetSortDirection sets the sort direction

func (*InstrumentQuery) SetSymbol

func (iq *InstrumentQuery) SetSymbol(symbol string) InstrumentQueryInterface

SetSymbol sets the symbol

func (*InstrumentQuery) SetSymbolLike

func (iq *InstrumentQuery) SetSymbolLike(symbolLike string) InstrumentQueryInterface

SetSymbolLike sets the symbol like

func (*InstrumentQuery) SortDirection

func (iq *InstrumentQuery) SortDirection() string

SortDirection returns the sort direction

func (*InstrumentQuery) Symbol

func (iq *InstrumentQuery) Symbol() string

Symbol returns the symbol

func (*InstrumentQuery) SymbolLike

func (iq *InstrumentQuery) SymbolLike() string

SymbolLike returns the symbol like

func (*InstrumentQuery) Validate

func (iq *InstrumentQuery) Validate() error

Validate validates the query options

type InstrumentQueryInterface

type InstrumentQueryInterface interface {
	// Validation
	Validate() error

	// Columns
	Columns() []string

	// Options
	SetCountOnly(countOnly bool) InstrumentQueryInterface
	IsCountOnly() bool

	// Limit, Offset
	SetLimit(limit int) InstrumentQueryInterface
	HasLimit() bool
	Limit() int
	SetOffset(offset int) InstrumentQueryInterface
	HasOffset() bool
	Offset() int

	// Order By
	SetOrderBy(orderBy string) InstrumentQueryInterface
	HasOrderBy() bool
	OrderBy() string
	SetSortDirection(sortDirection string) InstrumentQueryInterface
	HasSortDirection() bool
	SortDirection() string

	// ID
	SetID(id string) InstrumentQueryInterface
	HasID() bool
	ID() string
	SetIDIn(ids []string) InstrumentQueryInterface
	HasIDIn() bool
	IDIn() []string

	// Symbol
	SetSymbol(symbol string) InstrumentQueryInterface
	HasSymbol() bool
	Symbol() string
	SetSymbolLike(symbolLike string) InstrumentQueryInterface
	HasSymbolLike() bool
	SymbolLike() string

	// Exchange
	SetExchange(exchange string) InstrumentQueryInterface
	HasExchange() bool
	Exchange() string

	// Asset Class
	SetAssetClass(assetClass string) InstrumentQueryInterface
	HasAssetClass() bool
	AssetClass() string
}

func NewInstrumentQuery

func NewInstrumentQuery() InstrumentQueryInterface

NewInstrumentQuery creates a new instrument query

type NewStoreOptions

type NewStoreOptions struct {
	PriceTableName      string
	InstrumentTableName string
	DB                  *sql.DB
	DbDriverName        string
	AutomigrateEnabled  bool
	DebugEnabled        bool
}

NewStoreOptions define the options for creating a new tradingstore

type Price

type Price struct {
	dataobject.DataObject
}

Price represents an OHLCV data object, for storing the pricing data in the database

func (*Price) GetClose

func (price *Price) GetClose() string

func (*Price) GetCloseFloat

func (price *Price) GetCloseFloat() float64

func (*Price) GetHigh

func (price *Price) GetHigh() string

func (*Price) GetHighFloat

func (price *Price) GetHighFloat() float64

func (*Price) GetLow

func (price *Price) GetLow() string

func (*Price) GetLowFloat

func (price *Price) GetLowFloat() float64

func (*Price) GetOpen

func (price *Price) GetOpen() string

func (*Price) GetOpenFloat

func (price *Price) GetOpenFloat() float64

func (*Price) GetTime

func (price *Price) GetTime() string

Time returns the time as a Iso8601 formatted string.

Parameters: - none

Returns: - string: the time in ISO8601 format

func (*Price) GetTimeCarbon

func (price *Price) GetTimeCarbon() carbon.Carbon

func (*Price) GetVolume

func (price *Price) GetVolume() string

func (*Price) GetVolumeFloat

func (price *Price) GetVolumeFloat() float64

func (*Price) ID

func (price *Price) ID() string

func (*Price) SetClose

func (price *Price) SetClose(close string) PriceInterface

func (*Price) SetHigh

func (price *Price) SetHigh(high string) PriceInterface

func (*Price) SetID

func (price *Price) SetID(id string) PriceInterface

func (*Price) SetLow

func (price *Price) SetLow(low string) PriceInterface

func (*Price) SetOpen

func (price *Price) SetOpen(open string) PriceInterface

func (*Price) SetTime

func (price *Price) SetTime(timeUtc string) PriceInterface

SetTime sets the time for a Price, must be in UTC. The time is stored as an ISO8601 formatted string.

Parameters: - timeUtc: time in UTC format

Returns: - *Price: the Price

func (*Price) SetVolume

func (price *Price) SetVolume(volume string) PriceInterface

type PriceInterface

type PriceInterface interface {
	Data() map[string]string
	DataChanged() map[string]string
	MarkAsNotDirty()

	// setters and getters
	ID() string
	SetID(id string) PriceInterface

	GetClose() string
	GetCloseFloat() float64
	SetClose(close string) PriceInterface

	GetHigh() string
	GetHighFloat() float64
	SetHigh(high string) PriceInterface

	GetLow() string
	GetLowFloat() float64
	SetLow(low string) PriceInterface

	GetOpen() string
	GetOpenFloat() float64
	SetOpen(open string) PriceInterface

	GetTime() string
	GetTimeCarbon() carbon.Carbon
	SetTime(time string) PriceInterface

	GetVolume() string
	GetVolumeFloat() float64
	SetVolume(volume string) PriceInterface
}

func NewPrice

func NewPrice() PriceInterface

func NewPriceFromExistingData

func NewPriceFromExistingData(data map[string]string) PriceInterface

type PriceQueryInterface

type PriceQueryInterface interface {
	Validate() error

	Columns() []string
	SetColumns(columns []string) PriceQueryInterface

	HasCountOnly() bool
	IsCountOnly() bool
	SetCountOnly(countOnly bool) PriceQueryInterface

	HasTime() bool
	Time() string
	SetTime(createdAt string) PriceQueryInterface

	HasTimeGte() bool
	TimeGte() string
	SetTimeGte(createdAtGte string) PriceQueryInterface

	HasTimeLte() bool
	TimeLte() string
	SetTimeLte(createdAtLte string) PriceQueryInterface

	HasID() bool
	ID() string
	SetID(id string) PriceQueryInterface

	HasIDIn() bool
	IDIn() []string
	SetIDIn(idIn []string) PriceQueryInterface

	HasLimit() bool
	Limit() int
	SetLimit(limit int) PriceQueryInterface

	HasOffset() bool
	Offset() int
	SetOffset(offset int) PriceQueryInterface

	HasOrderBy() bool
	OrderBy() string
	SetOrderBy(orderBy string) PriceQueryInterface

	HasSortDirection() bool
	SortDirection() string
	SetSortDirection(sortDirection string) PriceQueryInterface
	// contains filtered or unexported methods
}

func NewPriceQuery

func NewPriceQuery() PriceQueryInterface

NewPriceQuery creates a new price query

func PriceQuery

func PriceQuery() PriceQueryInterface

PriceQuery is a shortcut for NewPriceQuery

type Store

type Store struct {
	// contains filtered or unexported fields
}

func (*Store) AutoMigrate

func (store *Store) AutoMigrate() error

AutoMigrate auto migrate

func (*Store) DB

func (st *Store) DB() *sql.DB

DB returns the underlying database connection

func (*Store) EnableDebug

func (st *Store) EnableDebug(debug bool)

EnableDebug - enables the debug option

func (*Store) InstrumentCount

func (store *Store) InstrumentCount(ctx context.Context, options InstrumentQueryInterface) (int64, error)

InstrumentCount returns the number of instruments based on the given query options

func (*Store) InstrumentCreate

func (store *Store) InstrumentCreate(ctx context.Context, instrument InstrumentInterface) error

InstrumentCreate creates a new instrument

func (*Store) InstrumentDelete

func (store *Store) InstrumentDelete(ctx context.Context, instrument InstrumentInterface) error

InstrumentDelete deletes an instrument

func (*Store) InstrumentDeleteByID

func (store *Store) InstrumentDeleteByID(ctx context.Context, id string) error

InstrumentDeleteByID deletes an instrument by its ID

func (*Store) InstrumentExists

func (store *Store) InstrumentExists(ctx context.Context, options InstrumentQueryInterface) (bool, error)

InstrumentExists returns true if an instrument exists based on the given query options

func (*Store) InstrumentFindByID

func (store *Store) InstrumentFindByID(ctx context.Context, id string) (InstrumentInterface, error)

InstrumentFindByID returns an instrument by its ID

func (*Store) InstrumentList

func (store *Store) InstrumentList(ctx context.Context, options InstrumentQueryInterface) ([]InstrumentInterface, error)

InstrumentList returns a list of instruments based on the given query options

func (*Store) InstrumentUpdate

func (store *Store) InstrumentUpdate(ctx context.Context, instrument InstrumentInterface) error

InstrumentUpdate updates an instrument

func (*Store) PriceCount

func (store *Store) PriceCount(ctx context.Context, options PriceQueryInterface) (int64, error)

PriceCount returns the number of prices based on the given query options

func (*Store) PriceCreate

func (store *Store) PriceCreate(ctx context.Context, price PriceInterface) error

PriceCreate creates a new price

func (*Store) PriceDelete

func (store *Store) PriceDelete(ctx context.Context, price PriceInterface) error

PriceDelete deletes a price

func (*Store) PriceDeleteByID

func (store *Store) PriceDeleteByID(ctx context.Context, id string) error

PriceDeleteByID deletes a price by its ID

func (*Store) PriceExists

func (store *Store) PriceExists(ctx context.Context, options PriceQueryInterface) (bool, error)

PriceExists returns true if a price exists based on the given query options

func (*Store) PriceFindByID

func (store *Store) PriceFindByID(ctx context.Context, id string) (PriceInterface, error)

PriceFindByID returns a price by its ID

func (*Store) PriceList

func (store *Store) PriceList(ctx context.Context, options PriceQueryInterface) ([]PriceInterface, error)

PriceList returns a list of prices based on the given query options

func (*Store) PriceUpdate

func (store *Store) PriceUpdate(ctx context.Context, price PriceInterface) error

type StoreInterface

type StoreInterface interface {
	// AutoMigrate automatically creates the schema if it does not exist
	AutoMigrate() error

	// DB returns the underlying sql.DB connection
	DB() *sql.DB

	// EnableDebug enables debug mode
	EnableDebug(bool)

	// InstrumentCount returns the number of instruments that match the criteria
	InstrumentCount(ctx context.Context, options InstrumentQueryInterface) (int64, error)

	// InstrumentCreate creates a new instrument in the database
	InstrumentCreate(ctx context.Context, instrument InstrumentInterface) error

	// InstrumentDelete deletes an instrument
	InstrumentDelete(ctx context.Context, instrument InstrumentInterface) error

	// InstrumentDeleteByID deletes an instrument by ID
	InstrumentDeleteByID(ctx context.Context, id string) error

	// InstrumentExists checks if an instrument exists by checking a number of criteria
	InstrumentExists(ctx context.Context, options InstrumentQueryInterface) (bool, error)

	// InstrumentFindByID finds an instrument by its ID
	InstrumentFindByID(ctx context.Context, id string) (InstrumentInterface, error)

	// InstrumentList returns a list of instruments from the database based on criteria
	InstrumentList(ctx context.Context, options InstrumentQueryInterface) ([]InstrumentInterface, error)

	// InstrumentUpdate updates an instrument
	InstrumentUpdate(ctx context.Context, instrument InstrumentInterface) error

	// PriceCount returns the number of prices that match the criteria
	PriceCount(ctx context.Context, options PriceQueryInterface) (int64, error)

	// PriceCreate creates a new price in the database
	PriceCreate(ctx context.Context, price PriceInterface) error

	// PriceDelete deletes a price
	PriceDelete(ctx context.Context, price PriceInterface) error

	// PriceDeleteByID deletes a price by ID
	PriceDeleteByID(ctx context.Context, id string) error

	// PriceExists checks if a price exists by checking a number of criteria
	PriceExists(ctx context.Context, options PriceQueryInterface) (bool, error)

	// PriceFindByID finds a price by its ID
	PriceFindByID(ctx context.Context, id string) (PriceInterface, error)

	// PriceList returns a list of prices from the database based on criteria
	PriceList(ctx context.Context, options PriceQueryInterface) ([]PriceInterface, error)

	// PriceUpdate updates a price
	PriceUpdate(ctx context.Context, price PriceInterface) error
}

StoreInterface defines the interface for a store

func NewStore

func NewStore(opts NewStoreOptions) (StoreInterface, error)

NewStore creates a new trading store

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL