Documentation ¶
Index ¶
- Variables
- type AccountService
- func (s *AccountService) Create(a *types.Account) error
- func (s *AccountService) FindOrCreate(addr string) (*types.Account, error)
- func (s *AccountService) GetAll() ([]types.Account, error)
- func (s *AccountService) GetByAddress(a string) (*types.Account, error)
- func (s *AccountService) GetByID(id bson.ObjectId) (*types.Account, error)
- func (s *AccountService) GetTokenBalance(owner string, token string) (*types.TokenBalance, error)
- func (s *AccountService) GetTokenBalances(owner string) (map[string]*types.TokenBalance, error)
- type InfoService
- type OHLCVService
- func (s *OHLCVService) GetOHLCV(pairs []types.PairAssets, duration int64, unit string, timeInterval ...int64) ([]*types.Tick, error)
- func (s *OHLCVService) Subscribe(conn *ws.Client, p *types.SubscriptionPayload)
- func (s *OHLCVService) Unsubscribe(conn *ws.Client)
- func (s *OHLCVService) UnsubscribeChannel(conn *ws.Client, p *types.SubscriptionPayload)
- type OrderBookService
- func (s *OrderBookService) GetOrderBook(bt, qt string) (map[string]interface{}, error)
- func (s *OrderBookService) GetRawOrderBook(bt, qt string) (*types.RawOrderBook, error)
- func (s *OrderBookService) SubscribeOrderBook(c *ws.Client, bt, qt string)
- func (s *OrderBookService) SubscribeRawOrderBook(c *ws.Client, bt, qt string)
- func (s *OrderBookService) UnsubscribeOrderBook(c *ws.Client)
- func (s *OrderBookService) UnsubscribeOrderBookChannel(c *ws.Client, bt, qt string)
- func (s *OrderBookService) UnsubscribeRawOrderBook(c *ws.Client)
- func (s *OrderBookService) UnsubscribeRawOrderBookChannel(c *ws.Client, bt, qt string)
- type OrderService
- func (s *OrderService) AdjustBalancesForUncommittedTrades(address string, balances map[string]int64) map[string]int64
- func (s *OrderService) CancelExpiredOrders()
- func (s *OrderService) CancelOrder(oc *types.OrderCancel) error
- func (s *OrderService) CancelOrdersSignedByRevokedSigner(address string, signer string)
- func (s *OrderService) CheckIfBalancesAreSufficientAndCancel(address string, balances map[string]int64)
- func (s *OrderService) FixOrderStatus(o *types.Order)
- func (s *OrderService) GetByHash(hash string) (*types.Order, error)
- func (s *OrderService) GetByHashes(hashes []string) ([]*types.Order, error)
- func (s *OrderService) GetByID(id bson.ObjectId) (*types.Order, error)
- func (s *OrderService) GetByUserAddress(addr string, limit ...int) ([]*types.Order, error)
- func (s *OrderService) GetCurrentByUserAddress(addr string, limit ...int) ([]*types.Order, error)
- func (s *OrderService) GetHistoryByUserAddress(addr string, limit ...int) ([]*types.Order, error)
- func (s *OrderService) GetSenderAddresses(oc *types.OrderCancel) (string, string, error)
- func (s *OrderService) HandleEngineResponse(res *types.EngineResponse) error
- func (s *OrderService) HandleOperatorMessages(msg *types.OperatorMessage) error
- func (s *OrderService) NewOrder(o *types.Order) (e error)
- type PairService
- func (s *PairService) Create(pair *types.Pair) error
- func (s *PairService) CreatePairs(asset string) ([]*types.Pair, error)
- func (s *PairService) GetAll() ([]types.Pair, error)
- func (s *PairService) GetAllExactTokenPairData() ([]*types.PairData, error)
- func (s *PairService) GetAllSimplifiedTokenPairData() ([]*types.SimplifiedPairAPIData, error)
- func (s *PairService) GetAllTokenPairData() ([]*types.PairAPIData, error)
- func (s *PairService) GetByAsset(bt, qt string) (*types.Pair, error)
- func (s *PairService) GetByID(id bson.ObjectId) (*types.Pair, error)
- func (s *PairService) GetListedPairs() ([]types.Pair, error)
- func (s *PairService) GetTokenPairData(bt, qt string) ([]*types.Tick, error)
- func (s *PairService) GetUnlistedPairs() ([]types.Pair, error)
- type PriceService
- type TokenService
- func (s *TokenService) CheckByAssetOrSymbol(assetOrSymbol string) (*types.Token, error)
- func (s *TokenService) Create(token *types.Token) error
- func (s *TokenService) GetAll() ([]types.Token, error)
- func (s *TokenService) GetBaseTokens() ([]types.Token, error)
- func (s *TokenService) GetByAsset(asset string) (*types.Token, error)
- func (s *TokenService) GetByAssetOrSymbol(assetOrSymbol string) (*types.Token, error)
- func (s *TokenService) GetByID(id bson.ObjectId) (*types.Token, error)
- func (s *TokenService) GetBySymbol(symbol string) (*types.Token, error)
- func (s *TokenService) GetListedBaseTokens() ([]types.Token, error)
- func (s *TokenService) GetListedTokens() ([]types.Token, error)
- func (s *TokenService) GetQuoteTokens() ([]types.Token, error)
- func (s *TokenService) GetUnlistedTokens() ([]types.Token, error)
- type TradeService
- func (s *TradeService) GetAllTradesByPairAssets(bt, qt string) ([]*types.Trade, error)
- func (s *TradeService) GetByHash(h string) (*types.Trade, error)
- func (s *TradeService) GetByHashes(hashes []string) ([]*types.Trade, error)
- func (s *TradeService) GetByMakerOrderHash(h string) ([]*types.Trade, error)
- func (s *TradeService) GetByOrderHashes(hashes []string) ([]*types.Trade, error)
- func (s *TradeService) GetByPairName(p string) ([]*types.Trade, error)
- func (s *TradeService) GetByTakerOrderHash(h string) ([]*types.Trade, error)
- func (s *TradeService) GetByTriggerUnitHash(h string) ([]*types.Trade, error)
- func (s *TradeService) GetByUserAddress(a string) ([]*types.Trade, error)
- func (s *TradeService) GetSortedTrades(bt, qt string, n int) ([]*types.Trade, error)
- func (s *TradeService) GetSortedTradesByUserAddress(a string, limit ...int) ([]*types.Trade, error)
- func (s *TradeService) Subscribe(c *ws.Client, bt, qt string)
- func (s *TradeService) Unsubscribe(c *ws.Client)
- func (s *TradeService) UnsubscribeChannel(c *ws.Client, bt, qt string)
- func (s *TradeService) UpdatePendingTrade(t *types.Trade, txh string) (*types.Trade, error)
- func (s *TradeService) UpdateSuccessfulTrade(t *types.Trade) (*types.Trade, error)
- func (s *TradeService) UpdateTradeStatus(t *types.Trade, status string) (*types.Trade, error)
- func (s *TradeService) UpdateTradeTxHash(tr *types.Trade, txh string) error
- type ValidatorService
Constants ¶
This section is empty.
Variables ¶
var ErrAccountExists = errors.New("Account already Exists")
var ErrAccountNotFound = errors.New("Account not found")
var ErrBaseTokenNotFound = errors.New("BaseToken not found")
var ErrNoAsset = errors.New("Asset not found")
var ErrPairExists = errors.New("Pairs already exists")
var ErrPairNotFound = errors.New("Pair not found")
var ErrQuoteTokenInvalid = errors.New("Quote Token Invalid (not a quote)")
var ErrQuoteTokenNotFound = errors.New("QuoteToken not found")
var ErrTokenExists = errors.New("Token already exists")
Functions ¶
This section is empty.
Types ¶
type AccountService ¶
type AccountService struct { AccountDao interfaces.AccountDao TokenDao interfaces.TokenDao }
func NewAccountService ¶
func NewAccountService( AccountDao interfaces.AccountDao, TokenDao interfaces.TokenDao, ) *AccountService
NewAddressService returns a new instance of accountService
func (*AccountService) FindOrCreate ¶
func (s *AccountService) FindOrCreate(addr string) (*types.Account, error)
func (*AccountService) GetByAddress ¶
func (s *AccountService) GetByAddress(a string) (*types.Account, error)
func (*AccountService) GetTokenBalance ¶
func (s *AccountService) GetTokenBalance(owner string, token string) (*types.TokenBalance, error)
func (*AccountService) GetTokenBalances ¶
func (s *AccountService) GetTokenBalances(owner string) (map[string]*types.TokenBalance, error)
type InfoService ¶
type InfoService struct {
// contains filtered or unexported fields
}
func NewInfoService ¶
func NewInfoService( pairDao interfaces.PairDao, tokenDao interfaces.TokenDao, tradeDao interfaces.TradeDao, orderDao interfaces.OrderDao, priceService interfaces.PriceService, ) *InfoService
func (*InfoService) GetExchangeData ¶
func (s *InfoService) GetExchangeData() (*types.ExchangeData, error)
func (*InfoService) GetExchangeStats ¶
func (s *InfoService) GetExchangeStats() (*types.ExchangeStats, error)
func (*InfoService) GetPairStats ¶
func (s *InfoService) GetPairStats() (*types.PairStats, error)
type OHLCVService ¶
type OHLCVService struct {
// contains filtered or unexported fields
}
func NewOHLCVService ¶
func NewOHLCVService(TradeDao interfaces.TradeDao) *OHLCVService
func (*OHLCVService) GetOHLCV ¶
func (s *OHLCVService) GetOHLCV(pairs []types.PairAssets, duration int64, unit string, timeInterval ...int64) ([]*types.Tick, error)
GetOHLCV fetches OHLCV data using pairName: can be "" for fetching data for all pairs duration: in integer unit: sec,min,hour,day,week,month,yr timeInterval: 0-2 entries (0 argument: latest data,1st argument: from timestamp, 2nd argument: to timestamp)
func (*OHLCVService) Subscribe ¶
func (s *OHLCVService) Subscribe(conn *ws.Client, p *types.SubscriptionPayload)
Subscribe handles all the subscription messages for ticks corresponding to a pair It calls the corresponding channel's subscription method and sends trade history back on the connection
func (*OHLCVService) Unsubscribe ¶
func (s *OHLCVService) Unsubscribe(conn *ws.Client)
Unsubscribe handles all the unsubscription messages for ticks corresponding to a pair
func (*OHLCVService) UnsubscribeChannel ¶
func (s *OHLCVService) UnsubscribeChannel(conn *ws.Client, p *types.SubscriptionPayload)
Unsubscribe handles all the unsubscription messages for ticks corresponding to a pair
type OrderBookService ¶
type OrderBookService struct {
// contains filtered or unexported fields
}
PairService struct with daos required, responsible for communicating with daos. PairService functions are responsible for interacting with daos and implements business logics.
func NewOrderBookService ¶
func NewOrderBookService( pairDao interfaces.PairDao, tokenDao interfaces.TokenDao, orderDao interfaces.OrderDao, ) *OrderBookService
NewPairService returns a new instance of balance service
func (*OrderBookService) GetOrderBook ¶
func (s *OrderBookService) GetOrderBook(bt, qt string) (map[string]interface{}, error)
GetOrderBook
func (*OrderBookService) GetRawOrderBook ¶
func (s *OrderBookService) GetRawOrderBook(bt, qt string) (*types.RawOrderBook, error)
GetRawOrderBook fetches complete orderbook from engine
func (*OrderBookService) SubscribeOrderBook ¶
func (s *OrderBookService) SubscribeOrderBook(c *ws.Client, bt, qt string)
SubscribeOrderBook is responsible for handling incoming orderbook subscription messages It makes an entry of connection in pairSocket corresponding to pair,unit and duration
func (*OrderBookService) SubscribeRawOrderBook ¶
func (s *OrderBookService) SubscribeRawOrderBook(c *ws.Client, bt, qt string)
SubscribeRawOrderBook is responsible for handling incoming orderbook subscription messages It makes an entry of connection in pairSocket corresponding to pair,unit and duration
func (*OrderBookService) UnsubscribeOrderBook ¶
func (s *OrderBookService) UnsubscribeOrderBook(c *ws.Client)
UnsubscribeOrderBook is responsible for handling incoming orderbook unsubscription messages
func (*OrderBookService) UnsubscribeOrderBookChannel ¶
func (s *OrderBookService) UnsubscribeOrderBookChannel(c *ws.Client, bt, qt string)
func (*OrderBookService) UnsubscribeRawOrderBook ¶
func (s *OrderBookService) UnsubscribeRawOrderBook(c *ws.Client)
UnsubscribeRawOrderBook is responsible for handling incoming orderbook unsubscription messages
func (*OrderBookService) UnsubscribeRawOrderBookChannel ¶
func (s *OrderBookService) UnsubscribeRawOrderBookChannel(c *ws.Client, bt, qt string)
type OrderService ¶
type OrderService struct {
// contains filtered or unexported fields
}
OrderService
func NewOrderService ¶
func NewOrderService( orderDao interfaces.OrderDao, pairDao interfaces.PairDao, accountDao interfaces.AccountDao, tradeDao interfaces.TradeDao, validator interfaces.ValidatorService, broker *rabbitmq.Connection, ) *OrderService
NewOrderService returns a new instance of orderservice
func (*OrderService) AdjustBalancesForUncommittedTrades ¶
func (*OrderService) CancelExpiredOrders ¶
func (s *OrderService) CancelExpiredOrders()
func (*OrderService) CancelOrder ¶
func (s *OrderService) CancelOrder(oc *types.OrderCancel) error
CancelOrder handles the cancellation order requests. Only Orders which are OPEN or NEW i.e. Not yet filled/partially filled can be cancelled
func (*OrderService) CancelOrdersSignedByRevokedSigner ¶
func (s *OrderService) CancelOrdersSignedByRevokedSigner(address string, signer string)
func (*OrderService) CheckIfBalancesAreSufficientAndCancel ¶
func (s *OrderService) CheckIfBalancesAreSufficientAndCancel(address string, balances map[string]int64)
func (*OrderService) FixOrderStatus ¶
func (s *OrderService) FixOrderStatus(o *types.Order)
func (*OrderService) GetByHash ¶
func (s *OrderService) GetByHash(hash string) (*types.Order, error)
GetByHash fetches all trades corresponding to a trade hash
func (*OrderService) GetByHashes ¶
func (s *OrderService) GetByHashes(hashes []string) ([]*types.Order, error)
func (*OrderService) GetByUserAddress ¶
GetByUserAddress fetches all the orders placed by passed user address
func (*OrderService) GetCurrentByUserAddress ¶
GetCurrentByUserAddress function fetches list of open/partial orders from order collection based on user address. Returns array of Order type struct
func (*OrderService) GetHistoryByUserAddress ¶
GetHistoryByUserAddress function fetches list of orders which are not in open/partial order status from order collection based on user address. Returns array of Order type struct
func (*OrderService) GetSenderAddresses ¶
func (s *OrderService) GetSenderAddresses(oc *types.OrderCancel) (string, string, error)
func (*OrderService) HandleEngineResponse ¶
func (s *OrderService) HandleEngineResponse(res *types.EngineResponse) error
HandleEngineResponse listens to messages incoming from the engine and handles websocket responses and database updates accordingly
func (*OrderService) HandleOperatorMessages ¶
func (s *OrderService) HandleOperatorMessages(msg *types.OperatorMessage) error
func (*OrderService) NewOrder ¶
func (s *OrderService) NewOrder(o *types.Order) (e error)
NewOrder validates if the passed order is valid or not based on user's available funds and order data. If valid: Order is inserted in DB with order status as new and order is publiched on rabbitmq queue for matching engine to process the order
type PairService ¶
type PairService struct {
// contains filtered or unexported fields
}
PairService struct with daos required, responsible for communicating with daos. PairService functions are responsible for interacting with daos and implements business logics.
func NewPairService ¶
func NewPairService( pairDao interfaces.PairDao, tokenDao interfaces.TokenDao, tradeDao interfaces.TradeDao, orderDao interfaces.OrderDao, provider interfaces.ObyteProvider, ) *PairService
NewPairService returns a new instance of balance service
func (*PairService) Create ¶
func (s *PairService) Create(pair *types.Pair) error
Create function is responsible for inserting new pair in DB. It checks for existence of tokens in DB first
func (*PairService) CreatePairs ¶
func (s *PairService) CreatePairs(asset string) ([]*types.Pair, error)
func (*PairService) GetAll ¶
func (s *PairService) GetAll() ([]types.Pair, error)
GetAll is reponsible for fetching all the pairs in the DB
func (*PairService) GetAllExactTokenPairData ¶
func (s *PairService) GetAllExactTokenPairData() ([]*types.PairData, error)
func (*PairService) GetAllSimplifiedTokenPairData ¶
func (s *PairService) GetAllSimplifiedTokenPairData() ([]*types.SimplifiedPairAPIData, error)
func (*PairService) GetAllTokenPairData ¶
func (s *PairService) GetAllTokenPairData() ([]*types.PairAPIData, error)
Return a simplified version of the pair data
func (*PairService) GetByAsset ¶
func (s *PairService) GetByAsset(bt, qt string) (*types.Pair, error)
GetByAsset fetches details of a pair using asset IDs of its constituting tokens
func (*PairService) GetListedPairs ¶
func (s *PairService) GetListedPairs() ([]types.Pair, error)
func (*PairService) GetTokenPairData ¶
func (s *PairService) GetTokenPairData(bt, qt string) ([]*types.Tick, error)
func (*PairService) GetUnlistedPairs ¶
func (s *PairService) GetUnlistedPairs() ([]types.Pair, error)
type PriceService ¶
type PriceService struct{}
func NewPriceService ¶
func NewPriceService() *PriceService
func (*PriceService) GetDollarMarketPrices ¶
func (s *PriceService) GetDollarMarketPrices(baseCurrencies []string) (map[string]float64, error)
func (*PriceService) GetMultipleMarketPrices ¶
type TokenService ¶
type TokenService struct {
// contains filtered or unexported fields
}
TokenService struct with daos required, responsible for communicating with daos. TokenService functions are responsible for interacting with daos and implements business logics.
func NewTokenService ¶
func NewTokenService(tokenDao interfaces.TokenDao, provider interfaces.ObyteProvider) *TokenService
NewTokenService returns a new instance of TokenService
func (*TokenService) CheckByAssetOrSymbol ¶
func (s *TokenService) CheckByAssetOrSymbol(assetOrSymbol string) (*types.Token, error)
func (*TokenService) Create ¶
func (s *TokenService) Create(token *types.Token) error
Create inserts a new token into the database
func (*TokenService) GetAll ¶
func (s *TokenService) GetAll() ([]types.Token, error)
GetAll fetches all the tokens from db
func (*TokenService) GetBaseTokens ¶
func (s *TokenService) GetBaseTokens() ([]types.Token, error)
GetBase fetches all the quote tokens from db
func (*TokenService) GetByAsset ¶
func (s *TokenService) GetByAsset(asset string) (*types.Token, error)
GetByAsset fetches the detailed document of a token using its asset ID
func (*TokenService) GetByAssetOrSymbol ¶
func (s *TokenService) GetByAssetOrSymbol(assetOrSymbol string) (*types.Token, error)
GetByAssetOrSymbol fetches the detailed document of a token using its asset ID or symbol
func (*TokenService) GetBySymbol ¶
func (s *TokenService) GetBySymbol(symbol string) (*types.Token, error)
GetBySymbol fetches the detailed document of a token using its symbol
func (*TokenService) GetListedBaseTokens ¶
func (s *TokenService) GetListedBaseTokens() ([]types.Token, error)
func (*TokenService) GetListedTokens ¶
func (s *TokenService) GetListedTokens() ([]types.Token, error)
func (*TokenService) GetQuoteTokens ¶
func (s *TokenService) GetQuoteTokens() ([]types.Token, error)
GetQuote fetches all the quote tokens from db
func (*TokenService) GetUnlistedTokens ¶
func (s *TokenService) GetUnlistedTokens() ([]types.Token, error)
type TradeService ¶
type TradeService struct {
// contains filtered or unexported fields
}
TradeService struct with daos required, responsible for communicating with daos. TradeService functions are responsible for interacting with daos and implements business logics.
func NewTradeService ¶
func NewTradeService(TradeDao interfaces.TradeDao) *TradeService
NewTradeService returns a new instance of TradeService
func (*TradeService) GetAllTradesByPairAssets ¶
func (s *TradeService) GetAllTradesByPairAssets(bt, qt string) ([]*types.Trade, error)
GetByPairAssets fetches all the trades corresponding to a pair using pair's asset IDs
func (*TradeService) GetByHash ¶
func (s *TradeService) GetByHash(h string) (*types.Trade, error)
GetByHash fetches all trades corresponding to a trade hash
func (*TradeService) GetByHashes ¶
func (s *TradeService) GetByHashes(hashes []string) ([]*types.Trade, error)
func (*TradeService) GetByMakerOrderHash ¶
func (s *TradeService) GetByMakerOrderHash(h string) ([]*types.Trade, error)
func (*TradeService) GetByOrderHashes ¶
func (s *TradeService) GetByOrderHashes(hashes []string) ([]*types.Trade, error)
func (*TradeService) GetByPairName ¶
func (s *TradeService) GetByPairName(p string) ([]*types.Trade, error)
GetByPairName fetches all the trades corresponding to a pair using pair's name
func (*TradeService) GetByTakerOrderHash ¶
func (s *TradeService) GetByTakerOrderHash(h string) ([]*types.Trade, error)
func (*TradeService) GetByTriggerUnitHash ¶
func (s *TradeService) GetByTriggerUnitHash(h string) ([]*types.Trade, error)
func (*TradeService) GetByUserAddress ¶
func (s *TradeService) GetByUserAddress(a string) ([]*types.Trade, error)
GetByUserAddress fetches all the trades corresponding to a user address
func (*TradeService) GetSortedTrades ¶
func (*TradeService) GetSortedTradesByUserAddress ¶
func (*TradeService) Subscribe ¶
func (s *TradeService) Subscribe(c *ws.Client, bt, qt string)
Subscribe
func (*TradeService) UnsubscribeChannel ¶
func (s *TradeService) UnsubscribeChannel(c *ws.Client, bt, qt string)
Unsubscribe
func (*TradeService) UpdatePendingTrade ¶
func (*TradeService) UpdateSuccessfulTrade ¶
func (*TradeService) UpdateTradeStatus ¶
func (*TradeService) UpdateTradeTxHash ¶
func (s *TradeService) UpdateTradeTxHash(tr *types.Trade, txh string) error
type ValidatorService ¶
type ValidatorService struct {
// contains filtered or unexported fields
}
func NewValidatorService ¶
func NewValidatorService( obyteProvider interfaces.ObyteProvider, accountDao interfaces.AccountDao, orderDao interfaces.OrderDao, pairDao interfaces.PairDao, ) *ValidatorService
func (*ValidatorService) ValidateAvailableBalance ¶
func (*ValidatorService) ValidateBalance ¶
func (s *ValidatorService) ValidateBalance(o *types.Order) error
func (*ValidatorService) ValidateOperatorAddress ¶
func (s *ValidatorService) ValidateOperatorAddress(o *types.Order) error