tradingstore

package module
v0.3.0 Latest Latest
Warning

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

Go to latest
Published: Apr 15, 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 financial 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)
  • Dynamic price table naming with pattern price_{symbol}_{timeframe} or price_{symbol}_{exchange}_{timeframe}

Price Table Naming Convention

Price data is stored in tables following the pattern:

  • price_{lowercase(symbol)}_{lowercase(timeframe)} (default)
  • price_{lowercase(symbol)}_{lowercase(exchange)}_{lowercase(timeframe)} (when UseMultipleExchanges is enabled)

This approach allows for better data organization and improved query performance.

Queries

TradingStore provides powerful query interfaces for retrieving price and instrument data:

Price Queries
// Get all prices for AAPL in June 2023
prices, err := store.PriceList(ctx, "AAPL", "NASDAQ", TIMEFRAME_1_MINUTE,
    NewPriceQuery().
        SetTimeGte("2023-06-01T00:00:00Z").
        SetTimeLte("2023-06-30T23:59:59Z"))

// Count prices matching criteria
count, err := store.PriceCount(ctx, "AAPL", "NASDAQ", TIMEFRAME_1_MINUTE,
    NewPriceQuery())

// Check if specific price data exists
exists, err := store.PriceExists(ctx, "AAPL", "NASDAQ", TIMEFRAME_1_MINUTE,
    NewPriceQuery().SetTime("2023-06-01T16:00:00Z"))
Instrument Queries
// Get all stock instruments
instruments, err := store.InstrumentList(ctx, NewInstrumentQuery().
    SetAssetClass(ASSET_CLASS_STOCK))

// Find instruments with names containing "Apple"
instruments, err := store.InstrumentList(ctx, NewInstrumentQuery().
    SetSymbolLike("Apple"))

// Count instruments on NASDAQ
count, err := store.InstrumentCount(ctx, NewInstrumentQuery().
    SetExchange("NASDAQ"))

Usage Example

package main

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

    "github.com/dracory/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{
        PriceTableNamePrefix: "price_",
        InstrumentTableName:  "instruments",
        UseMultipleExchanges: false,
        DB:                  db,
        AutomigrateEnabled:  true,
    })
    if err != nil {
        log.Fatal(err)
    }

    ctx := context.Background()

    // Create a new instrument
    instrument := NewInstrument().
        SetSymbol("AAPL").
        SetExchange("NASDAQ").
        SetAssetClass("STOCK").
        SetDescription("Apple Inc.").
        SetTimeframes([]string{TIMEFRAME_1_MINUTE, TIMEFRAME_5_MINUTES, TIMEFRAME_1_HOUR, TIMEFRAME_1_DAY})

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

    // Create pricing tables
    err := store.AutomigratePrices()

    if err != nil {
        log.Fatal(err)
    }

    // Create a price entry
    price := NewPrice().
        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, "AAPL", "NASDAQ", TIMEFRAME_1_MINUTE, price); err != nil {
        log.Fatal(err)
    }

    // Query prices
    prices, err := store.PriceList(ctx, "AAPL", "NASDAQ", TIMEFRAME_1_MINUTE, NewPriceQuery().
        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.Time(), p.Open(), p.Close())
    }
}

Architecture

The TradingStore library is organized into three main components:

Store Component
classDiagram
    class StoreInterface {
        <<interface>>
        +AutoMigrate() error
        +AutoMigrateInstruments(ctx) error
        +AutoMigratePrices(ctx) error
        +DB() *sql.DB
        +EnableDebug(bool)
        +InstrumentCount(ctx, options) (int64, error)
        +InstrumentCreate(ctx, instrument) error
        +InstrumentDelete(ctx, instrument) error
        +InstrumentDeleteByID(ctx, id) error
        +InstrumentExists(ctx, options) (bool, error)
        +InstrumentFindByID(ctx, id) (InstrumentInterface, error)
        +InstrumentList(ctx, options) ([]InstrumentInterface, error)
        +InstrumentUpdate(ctx, instrument) error
        +PriceCount(ctx, symbol, exchange, timeframe, options) (int64, error)
        +PriceCreate(ctx, symbol, exchange, timeframe, price) error
        +PriceDelete(ctx, symbol, exchange, timeframe, price) error
        +PriceDeleteByID(ctx, symbol, exchange, timeframe, id) error
        +PriceExists(ctx, symbol, exchange, timeframe, options) (bool, error)
        +PriceFindByID(ctx, symbol, exchange, timeframe, id) (PriceInterface, error)
        +PriceList(ctx, symbol, exchange, timeframe, options) ([]PriceInterface, error)
        +PriceUpdate(ctx, symbol, exchange, timeframe, price) error
    }

    class Store {
        -priceTableNamePrefix string
        -instrumentTableName string
        -db *sql.DB
        -dbDriverName string
        -automigrateEnabled bool
        -debugEnabled bool
        -useMultipleExchanges bool
        -sqlLogger *slog.Logger
        +AutoMigrate() error
        +AutoMigrateInstruments(ctx) error
        +AutoMigratePrices(ctx) error
        +DB() *sql.DB
        +EnableDebug(bool)
        +PriceTableName(symbol, exchange, timeframe) string
    }

    StoreInterface <|.. Store
Price Component
classDiagram
    class PriceInterface {
        <<interface>>
        +Data() map[string]string
        +DataChanged() map[string]string
        +MarkAsNotDirty()
        +ID() string
        +SetID(id) PriceInterface
        +Open() string
        +OpenFloat() float64
        +SetOpen(open) PriceInterface
        +High() string
        +HighFloat() float64
        +SetHigh(high) PriceInterface
        +Low() string
        +LowFloat() float64
        +SetLow(low) PriceInterface
        +Close() string
        +CloseFloat() float64
        +SetClose(close) PriceInterface
        +Volume() string
        +VolumeFloat() float64
        +SetVolume(volume) PriceInterface
        +Time() string
        +TimeCarbon() *carbon.Carbon
        +SetTime(time) PriceInterface
    }

    class Price {
        +dataobject.DataObject
    }

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

    PriceInterface <|.. Price
Instrument Component
classDiagram
    class InstrumentInterface {
        <<interface>>
        +Data() map[string]string
        +DataChanged() map[string]string
        +MarkAsNotDirty()
        +ID() string
        +SetID(id) InstrumentInterface
        +Symbol() string
        +SetSymbol(symbol) InstrumentInterface
        +Exchange() string
        +SetExchange(exchange) InstrumentInterface
        +AssetClass() string
        +SetAssetClass(assetClass) InstrumentInterface
        +Description() string
        +SetDescription(description) InstrumentInterface
        +Timeframes() []string
        +SetTimeframes(timeframes) InstrumentInterface
    }

    class Instrument {
        +dataobject.DataObject
    }

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

    InstrumentInterface <|.. Instrument

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_DESCRIPTION = "description"
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_SOFT_DELETED_AT = "soft_deleted_at"
View Source
const COLUMN_SYMBOL = "symbol"
View Source
const COLUMN_TIME = "time"
View Source
const COLUMN_TIMEFRAMES = "timeframes"
View Source
const COLUMN_UPDATED_AT = "updated_at"
View Source
const COLUMN_VOLUME = "volume"
View Source
const NIL_FLOAT = -0.0000000001
View Source
const TIMEFRAME_15_MINUTES = "15min"
View Source
const TIMEFRAME_1_DAY = "1day"
View Source
const TIMEFRAME_1_HOUR = "1hour"
View Source
const TIMEFRAME_1_MINUTE = "1min"
View Source
const TIMEFRAME_1_MONTH = "1month"
View Source
const TIMEFRAME_1_WEEK = "1week"
View Source
const TIMEFRAME_1_YEAR = "1year"
View Source
const TIMEFRAME_30_MINUTES = "30min"
View Source
const TIMEFRAME_4_HOURS = "4hour"
View Source
const TIMEFRAME_5_MINUTES = "5min"

Variables

This section is empty.

Functions

This section is empty.

Types

type InstrumentInterface

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

	// setters and getters
	AssetClass() string
	SetAssetClass(assetClass string) InstrumentInterface

	Exchange() string
	SetExchange(exchange string) InstrumentInterface

	Description() string
	SetDescription(description string) InstrumentInterface

	ID() string
	SetID(id string) InstrumentInterface

	Symbol() string
	SetSymbol(symbol string) InstrumentInterface

	Timeframes() []string
	SetTimeframes(timeframes []string) InstrumentInterface
}

func NewInstrument

func NewInstrument() InstrumentInterface

func NewInstrumentFromExistingData

func NewInstrumentFromExistingData(data map[string]string) InstrumentInterface

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 InstrumentQuery

func InstrumentQuery() InstrumentQueryInterface

InstrumentQuery is a shortcut to create a new instrument query

func NewInstrumentQuery

func NewInstrumentQuery() InstrumentQueryInterface

NewInstrumentQuery creates a new instrument query

type NewStoreOptions

type NewStoreOptions struct {
	// PriceTableNamePrefix is the prefix of the price table
	PriceTableNamePrefix string

	// InstrumentTableName is the name of the instrument table
	InstrumentTableName string

	// UseMultipleExchanges is used to create a new price table for each exchange
	// if false, the price table will be created without the exchange name as the table name (i.e. price_btc_usdt)
	// if true, the price table will be created with the exchange name as the table name (i.e. price_btc_binance_usdt)
	UseMultipleExchanges bool

	// DB is the underlying database connection
	DB *sql.DB

	// DbDriverName is the name of the database driver
	DbDriverName string

	// AutomigrateEnabled is used to auto migrate the instrument table
	// Note: You will need to call AutoMigratePrices after creating a new instrument
	AutomigrateEnabled bool

	// DebugEnabled is used to enable debug mode
	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) Close added in v0.3.0

func (price *Price) Close() string

func (*Price) CloseFloat added in v0.3.0

func (price *Price) CloseFloat() float64

func (*Price) High added in v0.3.0

func (price *Price) High() string

func (*Price) HighFloat added in v0.3.0

func (price *Price) HighFloat() float64

func (*Price) ID

func (price *Price) ID() string

func (*Price) Low added in v0.3.0

func (price *Price) Low() string

func (*Price) LowFloat added in v0.3.0

func (price *Price) LowFloat() float64

func (*Price) Open added in v0.3.0

func (price *Price) Open() string

func (*Price) OpenFloat added in v0.3.0

func (price *Price) OpenFloat() float64

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

func (*Price) Time added in v0.3.0

func (price *Price) Time() string

Time returns the time as a Iso8601 formatted string.

Parameters: - none

Returns: - string: the time in ISO8601 format

func (*Price) TimeCarbon added in v0.3.0

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

func (*Price) Volume added in v0.3.0

func (price *Price) Volume() string

func (*Price) VolumeFloat added in v0.3.0

func (price *Price) VolumeFloat() float64

type PriceInterface

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

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

	Close() string
	CloseFloat() float64
	SetClose(close string) PriceInterface

	High() string
	HighFloat() float64
	SetHigh(high string) PriceInterface

	Low() string
	LowFloat() float64
	SetLow(low string) PriceInterface

	Open() string
	OpenFloat() float64
	SetOpen(open string) PriceInterface

	Time() string
	TimeCarbon() *carbon.Carbon
	SetTime(time string) PriceInterface

	Volume() string
	VolumeFloat() 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) AutoMigrateInstruments added in v0.3.0

func (store *Store) AutoMigrateInstruments(ctx context.Context) error

AutoMigrateInstruments auto migrates the instrument table

func (*Store) AutoMigratePrices added in v0.3.0

func (store *Store) AutoMigratePrices(ctx context.Context) error

AutoMigratePrices auto migrates the price tables It will create a price table for each instrument and each timeframe You will need to call this method when you create a new instrument

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, symbol string, exchange string, timeframe string, 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, symbol string, exchange string, timeframe string, price PriceInterface) error

PriceCreate creates a new price

func (*Store) PriceDelete

func (store *Store) PriceDelete(ctx context.Context, symbol string, exchange string, timeframe string, price PriceInterface) error

PriceDelete deletes a price

func (*Store) PriceDeleteByID

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

PriceDeleteByID deletes a price by its ID

func (*Store) PriceExists

func (store *Store) PriceExists(ctx context.Context, symbol string, exchange string, timeframe string, 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, symbol string, exchange string, timeframe string, priceID string) (PriceInterface, error)

PriceFindByID returns a price by its ID

func (*Store) PriceList

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

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

func (*Store) PriceTableName added in v0.3.0

func (store *Store) PriceTableName(symbol string, exchange string, timeframe string) string

func (*Store) PriceUpdate

func (store *Store) PriceUpdate(ctx context.Context, symbol string, exchange string, timeframe string, price PriceInterface) error

type StoreInterface

type StoreInterface interface {
	// AutoMigrateInstruments automatically creates the schema if it does not exist
	AutoMigrateInstruments(ctx context.Context) error

	// AutoMigratePrices automatically creates the price tables if they do not exist
	// It will create a price table for each instrument and each timeframe
	// You will need to call this method when you create a new instrument
	AutoMigratePrices(ctx context.Context) 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, symbol string, exchange string, timeframe string, options PriceQueryInterface) (int64, error)

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

	// PriceDelete deletes a price
	PriceDelete(ctx context.Context, symbol string, exchange string, timeframe string, price PriceInterface) error

	// PriceDeleteByID deletes a price by ID
	PriceDeleteByID(ctx context.Context, symbol string, exchange string, timeframe string, priceID string) error

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

	// PriceFindByID finds a price by its ID
	PriceFindByID(ctx context.Context, symbol string, exchange string, timeframe string, priceID string) (PriceInterface, error)

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

	// PriceUpdate updates a price
	PriceUpdate(ctx context.Context, symbol string, exchange string, timeframe string, 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