service

package
v0.0.0-...-7fd84a6 Latest Latest
Warning

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

Go to latest
Published: May 24, 2018 License: GPL-3.0 Imports: 30 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ETHERSCAN_RATELIMITER = common.NewRateLimiter(5, 1)
View Source
var JWT_CONTEXT_LOCK sync.Mutex
View Source
var JWT_TOKEN_LOCK sync.Mutex
View Source
var MARKETCAP_RATELIMITER = common.NewRateLimiter(10, 1)
View Source
var PLUGINS = make(map[string]*plugin.Plugin)
View Source
var PLUGINTYPE = map[string]string{
	common.INDICATOR_PLUGIN_TYPE: "indicators",
	common.STRATEGY_PLUGIN_TYPE:  "strategies",
	common.EXCHANGE_PLUGIN_TYPE:  "exchanges",
	common.WALLET_PLUGIN_TYPE:    "wallets"}

Functions

func NewFiatPriceService

func NewFiatPriceService(ctx common.Context, exchangeService ExchangeService) (common.FiatPriceService, error)

func NewMarketCapService

func NewMarketCapService(ctx common.Context) common.MarketCapService

func NewSlickChartsService

func NewSlickChartsService(ctx common.Context) common.FiatPriceService

Types

type AuthService

type AuthService interface {
	Login(username, password string) (common.UserContext, error)
	Register(username, password string) error
}

func NewLocalAuthService

func NewLocalAuthService(ctx common.Context, userDAO dao.UserDAO, userMapper mapper.UserMapper) AuthService

type AutoTradeService

type AutoTradeService interface {
	EndWorldHunger() error
}

func NewAutoTradeService

func NewAutoTradeService(ctx common.Context, exchangeService ExchangeService, chartService ChartService,
	profitService ProfitService, tradeService TradeService, strategyService StrategyService,
	userMapper mapper.UserMapper) AutoTradeService

type ChartService

type ChartService interface {
	GetCurrencyPair(chart common.Chart) *common.CurrencyPair
	GetExchange(chart common.Chart) (common.Exchange, error)
	Stream(chart common.Chart, candlesticks []common.Candlestick, strategyHandler func(price decimal.Decimal) error) error
	StopStream(chart common.Chart)
	GetChart(id uint) (common.Chart, error)
	GetCharts(autoTradeOnly bool) ([]common.Chart, error)
	GetTrades(chart common.Chart) ([]common.Trade, error)
	GetLastTrade(chart common.Chart) (common.Trade, error)
	GetIndicator(chart common.Chart, name string, candles []common.Candlestick) (common.FinancialIndicator, error)
	GetIndicators(chart common.Chart, candles []common.Candlestick) (map[string]common.FinancialIndicator, error)
	CreateIndicator(dao entity.ChartIndicator) common.FinancialIndicator
	LoadCandlesticks(chart common.Chart, exchange common.Exchange) []common.Candlestick
}

func NewChartService

func NewChartService(ctx common.Context, userDAO dao.UserDAO, chartDAO dao.ChartDAO,
	exchangeService ExchangeService, indicatorService IndicatorService) ChartService

type DefaultAutoTradeService

type DefaultAutoTradeService struct {
	AutoTradeService
	// contains filtered or unexported fields
}

func (*DefaultAutoTradeService) EndWorldHunger

func (ats *DefaultAutoTradeService) EndWorldHunger() error

type DefaultChartService

type DefaultChartService struct {
	ChartService
	// contains filtered or unexported fields
}

func (*DefaultChartService) GetChart

func (service *DefaultChartService) GetChart(id uint) (common.Chart, error)

func (*DefaultChartService) GetCharts

func (service *DefaultChartService) GetCharts(autoTradeOnly bool) ([]common.Chart, error)

func (*DefaultChartService) GetCurrencyPair

func (service *DefaultChartService) GetCurrencyPair(chart common.Chart) *common.CurrencyPair

func (*DefaultChartService) GetExchange

func (service *DefaultChartService) GetExchange(chart common.Chart) (common.Exchange, error)

func (*DefaultChartService) GetIndicator

func (service *DefaultChartService) GetIndicator(chart common.Chart, name string, candles []common.Candlestick) (common.FinancialIndicator, error)

func (*DefaultChartService) GetIndicators

func (service *DefaultChartService) GetIndicators(chart common.Chart, candles []common.Candlestick) (map[string]common.FinancialIndicator, error)

func (*DefaultChartService) GetLastTrade

func (service *DefaultChartService) GetLastTrade(chart common.Chart) (common.Trade, error)

func (*DefaultChartService) GetTrades

func (service *DefaultChartService) GetTrades(chart common.Chart) ([]common.Trade, error)

func (*DefaultChartService) LoadCandlesticks

func (service *DefaultChartService) LoadCandlesticks(chart common.Chart, exchange common.Exchange) []common.Candlestick

func (*DefaultChartService) StopStream

func (service *DefaultChartService) StopStream(chart common.Chart)

func (*DefaultChartService) Stream

func (service *DefaultChartService) Stream(chart common.Chart,
	candlesticks []common.Candlestick, strategyHandler func(price decimal.Decimal) error) error

type DefaultExchangeService

type DefaultExchangeService struct {
	ExchangeService
	// contains filtered or unexported fields
}

func (*DefaultExchangeService) CreateExchange

func (service *DefaultExchangeService) CreateExchange(exchangeName string) (common.Exchange, error)

func (*DefaultExchangeService) GetCurrencyPairs

func (service *DefaultExchangeService) GetCurrencyPairs(exchangeName string) ([]common.CurrencyPair, error)

func (*DefaultExchangeService) GetDisplayNames

func (service *DefaultExchangeService) GetDisplayNames() ([]string, error)

func (*DefaultExchangeService) GetExchange

func (service *DefaultExchangeService) GetExchange(exchangeName string) (common.Exchange, error)

func (*DefaultExchangeService) GetExchanges

func (service *DefaultExchangeService) GetExchanges() ([]common.Exchange, error)

type DefaultIndicatorService

type DefaultIndicatorService struct {
	IndicatorService
	// contains filtered or unexported fields
}

func (*DefaultIndicatorService) GetChartIndicator

func (service *DefaultIndicatorService) GetChartIndicator(chart common.Chart, name string,
	candles []common.Candlestick) (common.FinancialIndicator, error)

func (*DefaultIndicatorService) GetChartIndicators

func (service *DefaultIndicatorService) GetChartIndicators(chart common.Chart, candles []common.Candlestick) (map[string]common.FinancialIndicator, error)

func (*DefaultIndicatorService) GetIndicator

func (service *DefaultIndicatorService) GetIndicator(name string) (common.Plugin, error)

type DefaultPluginService

type DefaultPluginService struct {
	PluginService
	// contains filtered or unexported fields
}

func (*DefaultPluginService) CreateExchange

func (service *DefaultPluginService) CreateExchange(exchangeName string) (func(ctx common.Context, userExchangeEntity entity.UserExchangeEntity) common.Exchange, error)

func (*DefaultPluginService) CreateIndicator

func (service *DefaultPluginService) CreateIndicator(indicatorName string) (func(candles []common.Candlestick, params []string) (common.FinancialIndicator, error), error)

func (*DefaultPluginService) CreateStrategy

func (service *DefaultPluginService) CreateStrategy(strategyName string) (func(params *common.TradingStrategyParams) (common.TradingStrategy, error), error)

func (*DefaultPluginService) CreateWallet

func (service *DefaultPluginService) CreateWallet(currency string) (func(params *common.WalletParams) common.Wallet, error)

func (*DefaultPluginService) GetMapper

func (service *DefaultPluginService) GetMapper() mapper.PluginMapper

func (*DefaultPluginService) GetPlugin

func (service *DefaultPluginService) GetPlugin(pluginName, pluginType string) (common.Plugin, error)

func (*DefaultPluginService) GetPlugins

func (service *DefaultPluginService) GetPlugins(pluginType string) ([]string, error)

func (*DefaultPluginService) ListPlugins

func (service *DefaultPluginService) ListPlugins(pluginType string) ([]string, error)

type DefaultProfitService

type DefaultProfitService struct {
	ProfitService
	// contains filtered or unexported fields
}

func (*DefaultProfitService) Save

func (ps *DefaultProfitService) Save(profit common.Profit)

type DefaultStrategyService

type DefaultStrategyService struct {
	StrategyService
	// contains filtered or unexported fields
}

func (*DefaultStrategyService) GetChartStrategies

func (service *DefaultStrategyService) GetChartStrategies(chart common.Chart, params *common.TradingStrategyParams,
	candles []common.Candlestick) ([]common.TradingStrategy, error)

func (*DefaultStrategyService) GetChartStrategy

func (service *DefaultStrategyService) GetChartStrategy(chart common.Chart, name string, candles []common.Candlestick) (common.TradingStrategy, error)

func (*DefaultStrategyService) GetStrategy

func (service *DefaultStrategyService) GetStrategy(name string) (common.Plugin, error)

type DefaultTradeService

type DefaultTradeService struct {
	TradeService
	// contains filtered or unexported fields
}

func (*DefaultTradeService) Buy

func (ts *DefaultTradeService) Buy(exchange common.Exchange, trade common.Trade)

func (*DefaultTradeService) GetLastTrade

func (ts *DefaultTradeService) GetLastTrade(chart common.Chart) common.Trade

func (*DefaultTradeService) Save

func (ts *DefaultTradeService) Save(dto common.Trade)

func (*DefaultTradeService) Sell

func (ts *DefaultTradeService) Sell(exchange common.Exchange, trade common.Trade)

type DefaultUserService

type DefaultUserService struct {
	UserService
	// contains filtered or unexported fields
}

func (*DefaultUserService) CreateExchange

func (service *DefaultUserService) CreateExchange(userCryptoExchange common.UserCryptoExchange) (common.UserCryptoExchange, error)

func (*DefaultUserService) CreateToken

func (service *DefaultUserService) CreateToken(token common.EthereumToken) error

func (*DefaultUserService) CreateUser

func (service *DefaultUserService) CreateUser(user common.UserContext)

func (*DefaultUserService) CreateWallet

func (service *DefaultUserService) CreateWallet(wallet common.UserCryptoWallet) error

func (*DefaultUserService) DeleteExchange

func (service *DefaultUserService) DeleteExchange(exchangeName string) error

func (*DefaultUserService) GetConfiguredExchanges

func (service *DefaultUserService) GetConfiguredExchanges() []common.UserCryptoExchange

func (*DefaultUserService) GetCurrentUser

func (service *DefaultUserService) GetCurrentUser() (common.UserContext, error)

func (*DefaultUserService) GetExchange

func (service *DefaultUserService) GetExchange(user common.UserContext, name string, currencyPair *common.CurrencyPair) (common.Exchange, error)

func (*DefaultUserService) GetExchangeSummary

func (service *DefaultUserService) GetExchangeSummary(currencyPair *common.CurrencyPair) ([]common.CryptoExchangeSummary, error)

func (*DefaultUserService) GetToken

func (service *DefaultUserService) GetToken(symbol string) (common.EthereumToken, error)

func (*DefaultUserService) GetTokens

func (service *DefaultUserService) GetTokens() ([]common.EthereumToken, error)

func (*DefaultUserService) GetTokensFor

func (service *DefaultUserService) GetTokensFor(wallet string) ([]common.EthereumToken, error)

func (*DefaultUserService) GetUserById

func (service *DefaultUserService) GetUserById(userId uint) (common.UserContext, error)

func (*DefaultUserService) GetUserByName

func (service *DefaultUserService) GetUserByName(username string) (common.UserContext, error)

func (*DefaultUserService) GetWallet

func (service *DefaultUserService) GetWallet(currency string) (common.UserCryptoWallet, error)

func (*DefaultUserService) GetWalletPlugins

func (service *DefaultUserService) GetWalletPlugins() ([]common.Wallet, error)

func (*DefaultUserService) GetWallets

func (service *DefaultUserService) GetWallets() []common.UserCryptoWallet

type EtherScanGetLastPrice

type EtherScanGetLastPrice struct {
	//BTC          string `json:"ethbtc"`
	//BTCTimestamp string `json:"ethbtc_timestamp"`
	USD string `json:"ethusd"`
}

type EtherScanGetLastPriceResponse

type EtherScanGetLastPriceResponse struct {
	Status  string                `json:"status"`
	Message string                `json:"message"`
	Result  EtherScanGetLastPrice `json:"result"`
}

type EtherScanGetTransactionsResponse

type EtherScanGetTransactionsResponse struct {
	Status  string        `json:"status"`
	Message string        `json:"message"`
	Result  []EtherScanTx `json:"result"`
}

type EtherScanResponse

type EtherScanResponse struct {
	Status  string `json:"status"`
	Message string `json:"message"`
	Result  string `json:"result"`
}

type EtherScanTx

type EtherScanTx struct {
	Timestamp       string `json:"timestamp"`
	From            string `json:"from"`
	To              string `json:"to"`
	Value           string `json:"value"`
	Gas             string `json:"gas"`
	GasPrice        string `json:"gasPrice"`
	GasUsed         string `json:"gasUsed"`
	ContractAddress string `json:"contractAddress"`
}

type EthereumService

type EthereumService interface {
	GetPrice() decimal.Decimal
	GetWallet(address string) (common.UserCryptoWallet, error)
	GetTransactions() ([]common.Transaction, error)
	GetTransactionsFor(address string) ([]common.Transaction, error)
	GetAccounts() ([]common.UserContext, error)
	AuthService
	TokenService
}

func NewEthereumService

func NewEthereumService(ctx common.Context, userDAO dao.UserDAO, userMapper mapper.UserMapper,
	marketcapService common.MarketCapService, exchangeService ExchangeService) (EthereumService, error)

func NewEthereumWebClient

func NewEthereumWebClient(ctx common.Context, userDAO dao.UserDAO, authService AuthService,
	marketcapService common.MarketCapService, fiatPriceService common.FiatPriceService) (EthereumService, error)

type EthereumServiceImpl

type EthereumServiceImpl struct {
	EthereumService
	// contains filtered or unexported fields
}

func (*EthereumServiceImpl) GetAccounts

func (facade *EthereumServiceImpl) GetAccounts() ([]common.UserContext, error)

func (*EthereumServiceImpl) GetToken

func (facade *EthereumServiceImpl) GetToken(walletAddress, contractAddress string) (common.EthereumToken, error)

func (*EthereumServiceImpl) GetTokenTransactions

func (facade *EthereumServiceImpl) GetTokenTransactions(contractAddress string) ([]common.Transaction, error)

func (*EthereumServiceImpl) GetTransactions

func (facade *EthereumServiceImpl) GetTransactions() ([]common.Transaction, error)

func (*EthereumServiceImpl) GetTransactionsFor

func (facade *EthereumServiceImpl) GetTransactionsFor(address string) ([]common.Transaction, error)

func (*EthereumServiceImpl) GetWallet

func (facade *EthereumServiceImpl) GetWallet(address string) (common.UserCryptoWallet, error)

func (*EthereumServiceImpl) Login

func (facade *EthereumServiceImpl) Login(username, password string) (common.UserContext, error)

func (*EthereumServiceImpl) Register

func (facade *EthereumServiceImpl) Register(username, password string) error

type EthereumWebClient

type EthereumWebClient struct {
	EthereumService
	// contains filtered or unexported fields
}

func (*EthereumWebClient) GetAccounts

func (service *EthereumWebClient) GetAccounts() ([]common.UserContext, error)

func (*EthereumWebClient) GetPrice

func (service *EthereumWebClient) GetPrice() decimal.Decimal

func (*EthereumWebClient) GetToken

func (service *EthereumWebClient) GetToken(walletAddress, contractAddress string) (common.EthereumToken, error)

func (*EthereumWebClient) GetTokenTransactions

func (service *EthereumWebClient) GetTokenTransactions(contractAddress string) ([]common.Transaction, error)

func (*EthereumWebClient) GetTransactions

func (service *EthereumWebClient) GetTransactions() ([]common.Transaction, error)

func (*EthereumWebClient) GetTransactionsFor

func (service *EthereumWebClient) GetTransactionsFor(address string) ([]common.Transaction, error)

func (*EthereumWebClient) GetWallet

func (service *EthereumWebClient) GetWallet(address string) (common.UserCryptoWallet, error)

func (*EthereumWebClient) Login

func (service *EthereumWebClient) Login(username, password string) (common.UserContext, error)

func (*EthereumWebClient) Register

func (service *EthereumWebClient) Register(username, password string) error

type ExchangeService

type ExchangeService interface {
	CreateExchange(exchangeName string) (common.Exchange, error)
	GetDisplayNames() ([]string, error)
	GetExchanges() ([]common.Exchange, error)
	GetExchange(name string) (common.Exchange, error)
	GetCurrencyPairs(exchangeName string) ([]common.CurrencyPair, error)
}

func NewExchangeService

func NewExchangeService(ctx common.Context, userDAO dao.UserDAO, userMapper mapper.UserMapper,
	userExchangeMapper mapper.UserExchangeMapper, pluginService PluginService) ExchangeService

type FiatPriceServiceImpl

type FiatPriceServiceImpl struct {
	common.FiatPriceService
	// contains filtered or unexported fields
}

func (*FiatPriceServiceImpl) GetPriceAt

func (service *FiatPriceServiceImpl) GetPriceAt(currency string, date time.Time) (*common.Candlestick, error)

type GethService

type GethService interface {
	Authenticate(address, passphrase string) error
	CreateAccount(passphrase string) (common.UserContext, error)
	DeleteAccount(passphrase string) error
	AuthService
	TokenService
}

func NewGethService

func NewGethService(ctx common.Context, userDAO dao.UserDAO, userMapper mapper.UserMapper) (GethService, error)

type GethServiceImpl

type GethServiceImpl struct {
	EthereumService
	// contains filtered or unexported fields
}

func (*GethServiceImpl) Authenticate

func (geth *GethServiceImpl) Authenticate(address, passphrase string) error

func (*GethServiceImpl) CreateAccount

func (geth *GethServiceImpl) CreateAccount(passphrase string) (common.UserContext, error)

func (*GethServiceImpl) DeleteAccount

func (geth *GethServiceImpl) DeleteAccount(passphrase string) error

func (*GethServiceImpl) GetAccounts

func (geth *GethServiceImpl) GetAccounts() ([]common.UserContext, error)

func (*GethServiceImpl) GetToken

func (geth *GethServiceImpl) GetToken(walletAddress string, contractAddress string) (common.EthereumToken, error)

func (*GethServiceImpl) GetTokenTransactions

func (geth *GethServiceImpl) GetTokenTransactions(contractAddress string) ([]common.Transaction, error)

func (*GethServiceImpl) GetTransactions

func (geth *GethServiceImpl) GetTransactions() ([]common.Transaction, error)

func (*GethServiceImpl) GetTransactionsFor

func (geth *GethServiceImpl) GetTransactionsFor(address string) ([]common.Transaction, error)

func (*GethServiceImpl) GetWallet

func (geth *GethServiceImpl) GetWallet(address string) (common.UserCryptoWallet, error)

func (*GethServiceImpl) Login

func (geth *GethServiceImpl) Login(username, password string) (common.UserContext, error)

func (*GethServiceImpl) Register

func (geth *GethServiceImpl) Register(username, password string) error

type IndicatorService

type IndicatorService interface {
	GetIndicator(name string) (common.Plugin, error)
	GetChartIndicator(chart common.Chart, name string, candles []common.Candlestick) (common.FinancialIndicator, error)
	GetChartIndicators(chart common.Chart, candles []common.Candlestick) (map[string]common.FinancialIndicator, error)
}

func NewIndicatorService

func NewIndicatorService(ctx common.Context, chartIndicatorDAO dao.ChartIndicatorDAO, pluginService PluginService) IndicatorService

type JsonWebTokenClaims

type JsonWebTokenClaims struct {
	Id            uint   `json:"user_id"`
	Username      string `json:"username"`
	LocalCurrency string `json:"local_currency"`
	Etherbase     string `json:"etherbase"`
	Keystore      string `json:"keystore"`
	jwt.StandardClaims
}

type JsonWebTokenService

type JsonWebTokenService interface {
	ParseToken(r *http.Request, extractor request.Extractor) (*jwt.Token, *JsonWebTokenClaims, error)
	GenerateToken(w http.ResponseWriter, req *http.Request)
	Validate(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)
	Middleware
}

func CreateJsonWebTokenService

func CreateJsonWebTokenService(ctx common.Context, databaseManager common.DatabaseManager, authService AuthService,
	jsonWriter common.HttpWriter, expiration int64, rsaKeyPair common.KeyPair) JsonWebTokenService

func NewJsonWebTokenService

func NewJsonWebTokenService(ctx common.Context, databaseManager common.DatabaseManager,
	authService AuthService, jsonWriter common.HttpWriter) (JsonWebTokenService, error)

type JsonWebTokenServiceImpl

type JsonWebTokenServiceImpl struct {
	JsonWebTokenService
	Middleware
	// contains filtered or unexported fields
}

func (*JsonWebTokenServiceImpl) CreateContext

func (service *JsonWebTokenServiceImpl) CreateContext(w http.ResponseWriter, r *http.Request) (common.Context, error)

func (*JsonWebTokenServiceImpl) GenerateToken

func (service *JsonWebTokenServiceImpl) GenerateToken(w http.ResponseWriter, req *http.Request)

func (*JsonWebTokenServiceImpl) GetContext

func (service *JsonWebTokenServiceImpl) GetContext(userID uint) common.Context

func (*JsonWebTokenServiceImpl) ParseToken

func (service *JsonWebTokenServiceImpl) ParseToken(r *http.Request, extractor request.Extractor) (*jwt.Token, *JsonWebTokenClaims, error)

func (*JsonWebTokenServiceImpl) Validate

func (service *JsonWebTokenServiceImpl) Validate(w http.ResponseWriter, r *http.Request, next http.HandlerFunc)

type LocalAuthService

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

func (*LocalAuthService) Login

func (service *LocalAuthService) Login(username, password string) (common.UserContext, error)

func (*LocalAuthService) Register

func (service *LocalAuthService) Register(username, password string) error

type MarketCapServiceImpl

type MarketCapServiceImpl struct {
	Markets      []common.MarketCap
	GlobalMarket *common.GlobalMarketCap
	// contains filtered or unexported fields
}

func (*MarketCapServiceImpl) GetGlobalMarket

func (m *MarketCapServiceImpl) GetGlobalMarket(currency string) *common.GlobalMarketCap

func (*MarketCapServiceImpl) GetMarket

func (service *MarketCapServiceImpl) GetMarket(symbol string) common.MarketCap

func (*MarketCapServiceImpl) GetMarkets

func (m *MarketCapServiceImpl) GetMarkets() []common.MarketCap

func (*MarketCapServiceImpl) GetMarketsByPercentChange1H

func (m *MarketCapServiceImpl) GetMarketsByPercentChange1H(order string) []common.MarketCap

func (*MarketCapServiceImpl) GetMarketsByPercentChange24H

func (m *MarketCapServiceImpl) GetMarketsByPercentChange24H(order string) []common.MarketCap

func (*MarketCapServiceImpl) GetMarketsByPercentChange7D

func (m *MarketCapServiceImpl) GetMarketsByPercentChange7D(order string) []common.MarketCap

func (*MarketCapServiceImpl) GetMarketsByPrice

func (m *MarketCapServiceImpl) GetMarketsByPrice(order string) []common.MarketCap

func (*MarketCapServiceImpl) GetMarketsByTopPerformers

func (m *MarketCapServiceImpl) GetMarketsByTopPerformers(order string) []common.MarketCap

func (*MarketCapServiceImpl) GetTrendingMarkets

func (m *MarketCapServiceImpl) GetTrendingMarkets(order string) []common.MarketCap

type Middleware

type Middleware interface {
	CreateContext(w http.ResponseWriter, r *http.Request) (common.Context, error)
	GetContext(userID uint) common.Context
}

type PluginService

type PluginService interface {
	GetMapper() mapper.PluginMapper
	GetPlugin(pluginName, pluginType string) (common.Plugin, error)
	GetPlugins(pluginType string) ([]string, error)
	ListPlugins(pluginType string) ([]string, error)
	CreateIndicator(indicatorName string) (func(candles []common.Candlestick, params []string) (common.FinancialIndicator, error), error)
	CreateStrategy(strategyName string) (func(params *common.TradingStrategyParams) (common.TradingStrategy, error), error)
	CreateExchange(exchangeName string) (func(ctx common.Context, userExchangeEntity entity.UserExchangeEntity) common.Exchange, error)
	CreateWallet(currency string) (func(params *common.WalletParams) common.Wallet, error)
}

func CreatePluginService

func CreatePluginService(ctx common.Context, pluginRoot string, pluginDAO dao.PluginDAO,
	pluginMapper mapper.PluginMapper) PluginService

func NewPluginService

func NewPluginService(ctx common.Context, pluginDAO dao.PluginDAO, pluginMapper mapper.PluginMapper) PluginService

type PortfolioService

type PortfolioService interface {
	Build(user common.UserContext, currencyPair *common.CurrencyPair) (common.Portfolio, error)
	Queue(user common.UserContext) (<-chan common.Portfolio, error)
	Stream(user common.UserContext, currencyPair *common.CurrencyPair) (<-chan common.Portfolio, error)
	Stop(user common.UserContext)
	IsStreaming(user common.UserContext) bool
}

func NewPortfolioService

func NewPortfolioService(ctx common.Context, marketcapService common.MarketCapService,
	userService UserService, ethereumService EthereumService) PortfolioService

type PortfolioServiceImpl

type PortfolioServiceImpl struct {
	PortfolioService
	// contains filtered or unexported fields
}

func (*PortfolioServiceImpl) Build

func (ps *PortfolioServiceImpl) Build(user common.UserContext, currencyPair *common.CurrencyPair) (common.Portfolio, error)

func (*PortfolioServiceImpl) IsStreaming

func (ps *PortfolioServiceImpl) IsStreaming(user common.UserContext) bool

func (*PortfolioServiceImpl) Queue

func (ps *PortfolioServiceImpl) Queue(user common.UserContext) (<-chan common.Portfolio, error)

func (*PortfolioServiceImpl) Stop

func (ps *PortfolioServiceImpl) Stop(user common.UserContext)

func (*PortfolioServiceImpl) Stream

func (ps *PortfolioServiceImpl) Stream(user common.UserContext, currencyPair *common.CurrencyPair) (<-chan common.Portfolio, error)

type PriceStream

type PriceStream interface {
	Listen(priceChange chan common.PriceChange) common.PriceChange
	SubscribeToPrice(listener common.PriceListener)
	SubscribeToPeriod(listener common.PeriodListener)
}

func NewPriceStream

func NewPriceStream(period int) PriceStream

type PriceStreamImpl

type PriceStreamImpl struct {
	Period int       // total seconds per candlestick
	Start  time.Time // timestamp of first candlestick
	Volume int
	// contains filtered or unexported fields
}

func (*PriceStreamImpl) Listen

func (ps *PriceStreamImpl) Listen(priceChange chan common.PriceChange) common.PriceChange

func (*PriceStreamImpl) SubscribeToPeriod

func (ps *PriceStreamImpl) SubscribeToPeriod(listener common.PeriodListener)

func (*PriceStreamImpl) SubscribeToPrice

func (ps *PriceStreamImpl) SubscribeToPrice(listener common.PriceListener)

type ProfitService

type ProfitService interface {
	Save(profit common.Profit)
	Find()
}

func NewProfitService

func NewProfitService(ctx common.Context, profitDAO dao.ProfitDAO) ProfitService

type SlickCharts

type SlickCharts struct {
	common.FiatPriceService
	// contains filtered or unexported fields
}

func (*SlickCharts) GetPriceAt

func (sc *SlickCharts) GetPriceAt(currency string, targetDay time.Time) (*common.Candlestick, error)

func (*SlickCharts) GetPriceHistory

func (sc *SlickCharts) GetPriceHistory(currency string) []common.Candlestick

type SlickChartsResponse

type SlickChartsResponse struct {
	Time   int64   `json:"time"`
	Open   float64 `json:"open"`
	High   float64 `json:"high"`
	Low    float64 `json:"low"`
	Close  float64 `json:"close"`
	Volume float64 `json:"volume"`
}

type StrategyService

type StrategyService interface {
	GetStrategy(name string) (common.Plugin, error)
	GetChartStrategy(chart common.Chart, name string, candles []common.Candlestick) (common.TradingStrategy, error)
	GetChartStrategies(chart common.Chart, params *common.TradingStrategyParams, candles []common.Candlestick) ([]common.TradingStrategy, error)
}

func NewStrategyService

func NewStrategyService(ctx common.Context, chartStrategyDAO dao.ChartStrategyDAO, pluginService PluginService,
	indicatorService IndicatorService, chartMapper mapper.ChartMapper) StrategyService

type TokenService

type TokenService interface {
	GetToken(walletAddress, contractAddress string) (common.EthereumToken, error)
	GetTokenTransactions(contractAddress string) ([]common.Transaction, error)
}

type TradeService

type TradeService interface {
	GetMapper() mapper.TradeMapper
	Save(dto common.Trade)
	GetLastTrade(chart common.Chart) common.Trade
	GetTradeHistory() []common.Transaction
	GetTransactionMapper() mapper.TransactionMapper
}

func NewTradeService

func NewTradeService(ctx common.Context, tradeDAO dao.TradeDAO, tradeMapper mapper.TradeMapper) TradeService

type TransactionService

type TransactionService interface {
	GetMapper() mapper.TransactionMapper
	GetHistory(order string) ([]common.Transaction, error)
	GetOrderHistory() []common.Transaction
	GetDepositHistory() []common.Transaction
	GetWithdrawalHistory() []common.Transaction
	GetImportedTransactions() []common.Transaction
	UpdateCategory(id, category string) error
	ImportCSV(file, exchange string) ([]common.Transaction, error)
	Synchronize() ([]common.Transaction, error)
}

func NewTransactionService

func NewTransactionService(ctx common.Context, transactionDAO dao.TransactionDAO, transactionMapper mapper.TransactionMapper,
	exchangeService ExchangeService, userService UserService, ethereumService EthereumService,
	fiatPriceService common.FiatPriceService) TransactionService

type TransactionServiceImpl

type TransactionServiceImpl struct {
	TransactionService
	// contains filtered or unexported fields
}

func (*TransactionServiceImpl) GetDepositHistory

func (service *TransactionServiceImpl) GetDepositHistory() []common.Transaction

func (*TransactionServiceImpl) GetHistory

func (service *TransactionServiceImpl) GetHistory(order string) ([]common.Transaction, error)

func (*TransactionServiceImpl) GetImportedTransactions

func (service *TransactionServiceImpl) GetImportedTransactions() []common.Transaction

func (*TransactionServiceImpl) GetMapper

func (service *TransactionServiceImpl) GetMapper() mapper.TransactionMapper

func (*TransactionServiceImpl) GetOrderHistory

func (service *TransactionServiceImpl) GetOrderHistory() []common.Transaction

func (*TransactionServiceImpl) GetWalletHistory

func (service *TransactionServiceImpl) GetWalletHistory() ([]common.Transaction, error)

func (*TransactionServiceImpl) GetWithdrawalHistory

func (service *TransactionServiceImpl) GetWithdrawalHistory() []common.Transaction

func (*TransactionServiceImpl) ImportCSV

func (service *TransactionServiceImpl) ImportCSV(file, exchangeName string) ([]common.Transaction, error)

func (*TransactionServiceImpl) Sort

func (service *TransactionServiceImpl) Sort(txs *[]common.Transaction)

func (*TransactionServiceImpl) Synchronize

func (service *TransactionServiceImpl) Synchronize() ([]common.Transaction, error)

func (*TransactionServiceImpl) UpdateCategory

func (service *TransactionServiceImpl) UpdateCategory(id, category string) error

type UserCredentials

type UserCredentials struct {
	Username string `json:"username"`
	Password string `json:"password"`
}

type UserService

type UserService interface {
	CreateUser(user common.UserContext)
	GetCurrentUser() (common.UserContext, error)
	GetUserById(userId uint) (common.UserContext, error)
	GetUserByName(username string) (common.UserContext, error)
	GetExchange(user common.UserContext, name string, currencyPair *common.CurrencyPair) (common.Exchange, error)
	GetConfiguredExchanges() []common.UserCryptoExchange
	GetExchangeSummary(currencyPair *common.CurrencyPair) ([]common.CryptoExchangeSummary, error)
	GetWallet(currency string) (common.UserCryptoWallet, error)
	GetWallets() []common.UserCryptoWallet
	GetWalletPlugins() ([]common.Wallet, error)
	GetTokensFor(wallet string) ([]common.EthereumToken, error)
	GetTokens() ([]common.EthereumToken, error)
	CreateToken(token common.EthereumToken) error
	CreateWallet(wallet common.UserCryptoWallet) error
	CreateExchange(userCryptoExchange common.UserCryptoExchange) (common.UserCryptoExchange, error)
	DeleteExchange(exchangeName string) error
}

func NewUserService

func NewUserService(ctx common.Context, userDAO dao.UserDAO,
	userMapper mapper.UserMapper, userExchangeMapper mapper.UserExchangeMapper,
	marketcapService common.MarketCapService, ethereumService EthereumService,
	exchangeService ExchangeService, walletService WalletService) UserService

type WalletService

type WalletService interface {
	CreateWallet(currency, address string) (common.Wallet, error)
}

func NewWalletService

func NewWalletService(ctx common.Context, pluginService PluginService, fiatPriceService common.FiatPriceService) WalletService

type WalletServiceImpl

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

func (*WalletServiceImpl) CreateWallet

func (service *WalletServiceImpl) CreateWallet(currency, address string) (common.Wallet, error)

Jump to

Keyboard shortcuts

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