Documentation ¶
Index ¶
- Constants
- Variables
- func SimpleStratedyToJson(s *SimpleStrategy) ([]byte, error)
- func StartAgents(ctx context.Context, repos Repos) error
- type Agent
- type AgentRepo
- type AgentStatus
- type AssetAllocationStorage
- type AssetAllocationStrategy
- func (s AssetAllocationStrategy) Name() string
- func (s AssetAllocationStrategy) Parameters() []StrategyParameter
- func (s *AssetAllocationStrategy) Run(ctx context.Context, storage interface{}, exchanges []Exchange, logger Logger) error
- func (s AssetAllocationStrategy) ValidateParameter(param StrategyParameter) bool
- type Balance
- type Exchange
- type ExchangeRepo
- type Logger
- type LoggerRepo
- type Order
- type OrderFilter
- type OrderStatus
- type Pair
- type Repos
- type SimpleStorage
- type SimpleStrategy
- type SimpleTrade
- type SimpleTradeFilter
- type SimpleTradeOrder
- type SimpleTradeStatus
- type Storage
- type StorageRepo
- type Strategy
- type StrategyId
- type StrategyParameter
- type StrategyParameterType
- type StrategyRepo
- type User
- type UserFindFilter
- type UserRepo
Constants ¶
View Source
const ( ErrorAgentStatus = iota ActiveAgentStatus = iota DisableAgentStatus = iota )
Variables ¶
View Source
var Version string = "v0.3.0"
Functions ¶
func SimpleStratedyToJson ¶
func SimpleStratedyToJson(s *SimpleStrategy) ([]byte, error)
Types ¶
type Agent ¶
type Agent struct { Id int64 UserId int64 Status AgentStatus StrategyId StrategyId StrategyData []byte }
type AgentStatus ¶
type AgentStatus int
type AssetAllocationStorage ¶
type AssetAllocationStorage interface { }
type AssetAllocationStrategy ¶
type AssetAllocationStrategy struct { }
func (AssetAllocationStrategy) Name ¶
func (s AssetAllocationStrategy) Name() string
func (AssetAllocationStrategy) Parameters ¶
func (s AssetAllocationStrategy) Parameters() []StrategyParameter
func (AssetAllocationStrategy) ValidateParameter ¶
func (s AssetAllocationStrategy) ValidateParameter(param StrategyParameter) bool
type Exchange ¶
type Exchange interface { Name() string Balances(assets []string) ([]Balance, error) GetOpenOrders(filter *OrderFilter) ([]Order, error) GetHistoryOrders(pairs []Pair) ([]Order, error) LastPrice(pair Pair) (decimal.Decimal, error) Buy(pair Pair, amount decimal.Decimal) (*Order, error) Sell(pair Pair, amount decimal.Decimal, price decimal.Decimal) (*Order, error) CancelOrder(orderId string, pair Pair) error GetOrderFee(pair Pair, amount decimal.Decimal, price decimal.Decimal) (Balance, error) GetPairFee(pair Pair) (Balance, error) }
type ExchangeRepo ¶
type LoggerRepo ¶
type OrderFilter ¶
type OrderFilter struct { Ids []string Statuses []OrderStatus Pairs []Pair }
type OrderStatus ¶
type OrderStatus = int
const ( PendingOrderStatus OrderStatus = iota FillOrderStatus OrderStatus = iota CanceledOrderStatus OrderStatus = iota )
type Repos ¶
type Repos struct { Agent AgentRepo //Strategy StrategyRepo Storage StorageRepo Exchange ExchangeRepo Logger LoggerRepo }
type SimpleStorage ¶
type SimpleStorage interface { //Storage GetTrades(filter *SimpleTradeFilter) ([]SimpleTrade, error) SaveTrade(trade *SimpleTrade) error }
type SimpleStrategy ¶
type SimpleStrategy struct { Pair Pair `json:"pair"` BaseQuality decimal.Decimal `json:"base_quality"` MaxTrades int `json:"max_trades"` ProfitPercent decimal.Decimal `json:"profit_percent"` FarPricePercent decimal.Decimal `json:"far_price_percent"` }
func NewSimpleStrategyFromJson ¶
func NewSimpleStrategyFromJson(_json []byte) (*SimpleStrategy, error)
func (SimpleStrategy) Name ¶
func (s SimpleStrategy) Name() string
func (SimpleStrategy) Parameters ¶
func (s SimpleStrategy) Parameters() []StrategyParameter
func (SimpleStrategy) ValidateParameter ¶
func (s SimpleStrategy) ValidateParameter(param StrategyParameter) bool
type SimpleTrade ¶
type SimpleTrade struct { Id int Status SimpleTradeStatus Amount decimal.Decimal Buy SimpleTradeOrder Sell SimpleTradeOrder }
type SimpleTradeFilter ¶
type SimpleTradeFilter struct {
Statuses []SimpleTradeStatus
}
type SimpleTradeOrder ¶
type SimpleTradeStatus ¶
type SimpleTradeStatus = int
const ( SimpleTradeStatusBuy SimpleTradeStatus = iota SimpleTradeStatusSell SimpleTradeStatus = iota SimpleTradeStatusFinish SimpleTradeStatus = iota )
type StorageRepo ¶
type StorageRepo interface {
GetAgentStorage(agent Agent) interface{}
}
type Strategy ¶
type Strategy interface { Name() string Parameters() []StrategyParameter ValidateParameter(StrategyParameter) bool Run(ctx context.Context, storage interface{}, exchanges []Exchange, logger Logger) error }
func GetStrategyFromJson ¶
func GetStrategyFromJson(id StrategyId, data []byte) Strategy
type StrategyParameter ¶
type StrategyParameter struct { Type StrategyParameterType Name string Value interface{} }
type StrategyParameterType ¶
type StrategyParameterType = int
type StrategyRepo ¶
type UserFindFilter ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.