Documentation ¶
Index ¶
- Constants
- Variables
- func DbInit(dbh *shared.DbHandle) error
- func PrintAll(channel string, data []byte) error
- func SetCentralDb(Db *shared.DbHandle)
- func SetLogger(l *slogger.Logger) *slogger.Logger
- type Account
- func (a *Account) AwaitRequestResult(Id int) chan *ActionRequest
- func (a *Account) AwaitUuidNotOpen(Uuid string) chan *Order
- func (a *Account) BalanceSnapshotInsert(Tx *sql.Tx, CoinId int, Balance decimal.Decimal, Available decimal.Decimal, ...) (err error)
- func (a *Account) GetClosedOrder(uuid string) (*Order, error)
- func (a *Account) GetOpenOrderRequests() (List []*ActionRequest, errors error)
- func (a *Account) GetOpenOrders() (List *OrderList, err error)
- func (a *Account) GetRequest(Id int) (*ActionRequest, error)
- func (a *Account) Identifier() string
- func (a *Account) NewBalanceSnapshot() *BalanceSnapshot
- func (a *Account) OrderUpdatePartialFill(o *Order) error
- func (a *Account) Publish(reason EventReason, object interface{}) error
- func (a *Account) RecordStratOrder(r *ActionRequest) error
- func (a *Account) RunOrderCache(duration time.Duration, Cycle *int)
- func (a *Account) SendOrderUpdate(o *Order) *EvOrderUpdate
- func (a *Account) SendRequest(o *ActionRequest) error
- func (a *Account) SetRequest(o *ActionRequest, From string, To string) (bool, error)
- func (a *Account) WipeBalanceSnapshot(Tx *sql.Tx) (err error)
- type ActionRequest
- type ActionRequestSub
- type BalState
- type BalanceSnapshot
- type Coin
- type CoinBalance
- type EvMarketUpdate
- type EvOrderOpen
- type EvOrderUpdate
- type Event
- type EventChannel
- func (ec *EventChannel) Connect() error
- func (ec *EventChannel) Publish(channel string, data ...interface{}) error
- func (ec *EventChannel) PublishObj(channel string, object interface{}) error
- func (ec *EventChannel) StartListener(channels ...string) error
- func (ec *EventChannel) SubscribeChannels(channels ...string) error
- func (ec *EventChannel) WriteJson(Rec *sjson.JSON) error
- type EventReason
- type Exchange
- type FiatMap
- type IntervalSet
- type MarketDef
- type MarketDefsType
- func (md MarketDefsType) ById(id int) (bool, *MarketDef)
- func (md MarketDefsType) ByName(item string) (bool, *MarketDef)
- func (md MarketDefsType) ByNameOrDie(item string) *MarketDef
- func (md MarketDefsType) Equals(Old *MarketDefsType) bool
- func (mdt *MarketDefsType) List() []string
- func (md *MarketDefsType) UpdateOmarketsTable(exchangeid int) error
- type MarketQuote
- type MarketRange
- type MarketRatesType
- type Order
- func (o *Order) ExchangeName() string
- func (o *Order) FormatOrderClosedChat() string
- func (o *Order) FormatOrderOpenChat() string
- func (o *Order) FormatOrderVanished() string
- func (o *Order) Identifier() string
- func (o *Order) IsArchived() bool
- func (o *Order) RecordClosedOrder() error
- func (o *Order) RecordOpenOrder() error
- type OrderList
- type Stairway
- func (Sta *Stairway) AllSteps() []decimal.Decimal
- func (Sta *Stairway) AllStepsF() []float64
- func (Sta *Stairway) FindStepByVal(V decimal.Decimal) int
- func (Sta *Stairway) FindStepByValF64(V float64) int
- func (Sta *Stairway) StepV(c int) decimal.Decimal
- func (Sta *Stairway) StepVf(c int) float64
- func (Sta *Stairway) String() string
- type StratLastUpdate
- type StratList
- type Strategy
- type User
- func (u *User) DbInit(Db *shared.DbHandle)
- func (u *User) GetStrats() (StratList, error)
- func (u *User) Identifier() string
- func (u *User) LastStratCloses() map[int]time.Time
- func (u *User) LoadAccountsForExchange(exchange *Exchange) []*Account
- func (u *User) LoadAllAccounts() []*Account
- func (u *User) RemoveOpenOrder(Uuid string) error
- func (u *User) UuidCloseRecorded(Uuid string) bool
- type UserPreparedQueries_ro
- type UserPreparedQueries_rw
Constants ¶
Variables ¶
View Source
var CoinLookup shared.LookupTable
View Source
var Config shared.Configuration
View Source
var ExchangeBinance = Exchange{ Id: EXCHANGE_BINANCE, Name: "binance", }
View Source
var ExchangeBittrex = Exchange{ Id: EXCHANGE_BITTREX, Name: "bittrex", }
View Source
var ExchangeCoinbase = Exchange{ Id: EXCHANGE_COINBASE, Name: "coinbase", }
View Source
var ExchangeKraken = Exchange{ Id: EXCHANGE_KRAKEN, Name: "kraken", }
View Source
var ExchangeSimulator = Exchange{ Id: EXCHANGE_SIM, Name: "simulator", }
View Source
var Exchanges struct { ById map[int]*Exchange ByName map[string]*Exchange }
View Source
var MarketLookup shared.LookupTable
View Source
var OrderTranslationMapBittrex = map[string]map[string]string{ "LIMIT": map[string]string{"SELL": "LIMIT_SELL", "BUY": "LIMIT_BUY"}, "MARKET": map[string]string{"SELL": "MARKET_SELL", "BUY": "MARKET_BUY"}, }
View Source
var OrderTranslationMapCbpro = map[string]map[string]string{ "": map[string]string{"sell": "LIMIT_SELL", "buy": "LIMIT_BUY"}, "limit": map[string]string{"sell": "LIMIT_SELL", "buy": "LIMIT_BUY"}, }
View Source
var OrderTranslationMapKraken = map[string]map[string]string{}
Functions ¶
func SetCentralDb ¶
Types ¶
type Account ¶
type Account struct { User *User Exchange *Exchange CredId int Cache struct { Pending map[string]*ActionRequest PendingIds map[int]*ActionRequest ResultSub map[int]chan *ActionRequest Open map[string]*Order Closed map[string]*Order // contains filtered or unexported fields } CacheCycle int X map[string]interface{} `json:"-"` }
Account is a downstream concept tied strictly to API keys
func (*Account) AwaitRequestResult ¶
func (a *Account) AwaitRequestResult(Id int) chan *ActionRequest
func (*Account) AwaitUuidNotOpen ¶
func (*Account) BalanceSnapshotInsert ¶
func (*Account) GetOpenOrderRequests ¶
func (a *Account) GetOpenOrderRequests() (List []*ActionRequest, errors error)
func (*Account) GetOpenOrders ¶
func (*Account) GetRequest ¶
func (a *Account) GetRequest(Id int) (*ActionRequest, error)
func (*Account) Identifier ¶
func (*Account) NewBalanceSnapshot ¶
func (a *Account) NewBalanceSnapshot() *BalanceSnapshot
func (*Account) OrderUpdatePartialFill ¶
func (*Account) Publish ¶
func (a *Account) Publish(reason EventReason, object interface{}) error
func (*Account) RecordStratOrder ¶
func (a *Account) RecordStratOrder(r *ActionRequest) error
func (*Account) SendOrderUpdate ¶
func (a *Account) SendOrderUpdate(o *Order) *EvOrderUpdate
func (*Account) SendRequest ¶
func (a *Account) SendRequest(o *ActionRequest) error
func (*Account) SetRequest ¶
type ActionRequest ¶
type ActionRequest struct { Account *Account Id int Command string Status string Uuid string Market *MarketDef Qty float64 Bidlimit float64 Stratid int Label string Requested time.Time Subscribe ActionRequestSub Error error }
func (*ActionRequest) Identifier ¶
func (o *ActionRequest) Identifier() string
func (*ActionRequest) MarkAsHandled ¶
func (o *ActionRequest) MarkAsHandled(status string) error
type ActionRequestSub ¶
type ActionRequestSub struct { Id chan int Result chan *ActionRequest }
type BalanceSnapshot ¶
type BalanceSnapshot struct {
// contains filtered or unexported fields
}
func (*BalanceSnapshot) Add ¶
func (bs *BalanceSnapshot) Add(Coinid int, Balance decimal.Decimal, Available decimal.Decimal, Hold decimal.Decimal) *BalanceSnapshot
func (*BalanceSnapshot) UpdateDb ¶
func (bs *BalanceSnapshot) UpdateDb() error
type Coin ¶
type Coin interface { shared.LookupItem }
type CoinBalance ¶
type EvMarketUpdate ¶
type EvOrderOpen ¶
type EvOrderUpdate ¶
type EventChannel ¶
type EventChannel struct { FpReceiver func(channel string, data []byte) error FpOnStart func() error // contains filtered or unexported fields }
func NewEventChannel ¶
func NewEventChannel() *EventChannel
func (*EventChannel) Connect ¶
func (ec *EventChannel) Connect() error
func (*EventChannel) Publish ¶
func (ec *EventChannel) Publish(channel string, data ...interface{}) error
func (*EventChannel) PublishObj ¶
func (ec *EventChannel) PublishObj(channel string, object interface{}) error
func (*EventChannel) StartListener ¶
func (ec *EventChannel) StartListener(channels ...string) error
func (*EventChannel) SubscribeChannels ¶
func (ec *EventChannel) SubscribeChannels(channels ...string) error
type EventReason ¶
type EventReason string
const ( EV_ORDER_OPEN EventReason = "orderopen" EV_ORDER_UPDATE EventReason = "orderupdate" EV_ORDER_CLOSED EventReason = "orderclosed" EV_NEWRATES EventReason = "newrates" )
type Exchange ¶
type Exchange struct { Id int Name string Markets MarketDefsType `json:"-"` LastMarketFetch time.Time LastRateFetch time.Time LoadCount int // contains filtered or unexported fields }
func (*Exchange) GetMarketRatesDb ¶
func (exchange *Exchange) GetMarketRatesDb()
func (*Exchange) GetMarketsDb ¶
func (exchange *Exchange) GetMarketsDb(MaxAge time.Duration) MarketDefsType
func (*Exchange) Identifier ¶
type FiatMap ¶
type FiatMap struct { BtcMarket *MarketQuote EthMarket *MarketQuote EuroMarket *MarketQuote GbpMarket *MarketQuote }
type IntervalSet ¶
type IntervalSet map[string]*MarketRange
type MarketDef ¶
type MarketDef struct { shared.LookupItem `json:"MarketId"` Exchange *Exchange BaseCoin Coin QuoteCoin Coin Status string Created time.Time UsProhibited bool Notice string Precision decimal.Decimal LastRate *MarketQuote `json:"-"` }
func (*MarketDef) GetLastRateDb ¶
func (md *MarketDef) GetLastRateDb() *MarketQuote
func (*MarketDef) Identifier ¶
type MarketDefsType ¶
func NewMarketDef ¶
func NewMarketDef() MarketDefsType
func (MarketDefsType) ByNameOrDie ¶
func (md MarketDefsType) ByNameOrDie(item string) *MarketDef
func (MarketDefsType) Equals ¶
func (md MarketDefsType) Equals(Old *MarketDefsType) bool
func (*MarketDefsType) List ¶
func (mdt *MarketDefsType) List() []string
func (*MarketDefsType) UpdateOmarketsTable ¶
func (md *MarketDefsType) UpdateOmarketsTable(exchangeid int) error
type MarketQuote ¶
type MarketRange ¶
type MarketRatesType ¶
type MarketRatesType map[string]*MarketQuote
func (*MarketRatesType) PublishRates ¶
func (md *MarketRatesType) PublishRates(acct *Account) error
func (MarketRatesType) SetFiat ¶
func (md MarketRatesType) SetFiat(fm *FiatMap)
func (*MarketRatesType) WriteMarketLast ¶
func (md *MarketRatesType) WriteMarketLast(dbh *shared.DbHandle, Exchange *Exchange)
type Order ¶
type Order struct { Account *Account Uuid string Label string Type string Market *MarketDef `json:"-"` Base Coin `json:"-"` BaseCoin string Quote Coin `json:"-"` QuoteCoin string Bidlimit decimal.Decimal Quantity decimal.Decimal Filled decimal.Decimal Fee decimal.Decimal UsdTotal decimal.NullDecimal TotalPrice decimal.Decimal Created time.Time Closed time.Time }
func (*Order) ExchangeName ¶
func (*Order) FormatOrderClosedChat ¶
func (*Order) FormatOrderOpenChat ¶
func (*Order) FormatOrderVanished ¶
func (*Order) Identifier ¶
func (*Order) IsArchived ¶
func (*Order) RecordClosedOrder ¶
func (*Order) RecordOpenOrder ¶
type OrderList ¶
type Stairway ¶
type Stairway struct { Delta decimal.Decimal Ratio decimal.Decimal Minimum decimal.Decimal // contains filtered or unexported fields }
func NewStairwayF ¶
func (*Stairway) FindStepByValF64 ¶
type StratLastUpdate ¶
type Strategy ¶
type Strategy struct { Id int Exchange *Exchange Name string User *User Market *MarketDef Active bool Suspended bool Data sjson.JSON SkipBecause error }
func (*Strategy) GetOrderList ¶
func (*Strategy) Identifier ¶
type User ¶
type User struct { Username string Notices *shared.ChatTarget `json:"-"` Accounts []*Account `json:"-"` Db *shared.DbHandle `json:"-"` ClosedOrders map[string]bool `json:"-"` Events *EventChannel `json:"-"` // contains filtered or unexported fields }
User represents an individual; a user may have many accounts, but one db only. Strategies may cross accounts if they're playing cross-exchange shenanigans like arb.
func (*User) Identifier ¶
func (*User) LoadAccountsForExchange ¶
func (*User) LoadAllAccounts ¶
func (*User) RemoveOpenOrder ¶
func (*User) UuidCloseRecorded ¶
type UserPreparedQueries_ro ¶
type UserPreparedQueries_ro struct { CredSelectByExchangeId *shared.Stmt OrderArchivePresent *shared.Stmt CheckLogpoints *shared.Stmt CheckTableMaxId *shared.Stmt CredSelectAll *shared.Stmt GetUserStrats *shared.Stmt GetLastStratCloses *shared.Stmt GetOpenRequests *shared.Stmt GetRequest *shared.Stmt GetOpenOrders *shared.Stmt GetStratOrders *shared.Stmt GetClosedOrder *shared.Stmt }
type UserPreparedQueries_rw ¶
type UserPreparedQueries_rw struct { BalanceWipeForAccount *shared.Stmt BalanceInsert *shared.Stmt OrderOpenDelete *shared.Stmt OrderOpenInsert *shared.Stmt OrderOpenUpdateFill *shared.Stmt OrderArchiveInsert *shared.Stmt StratOrderUpdate *shared.Stmt UpdateLogpoint *shared.Stmt SetRequestStatusFrom *shared.Stmt SetRequestMarkHandled *shared.Stmt SetRequestProcessed *shared.Stmt RequestInsert *shared.Stmt InsertStratOrder *shared.Stmt }
Click to show internal directories.
Click to hide internal directories.