Documentation ¶
Overview ¶
Package trader defines a trader using a moving average strategy.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Account ¶
type Account struct { Currency currency.Unit // the account's home currency. Balance decimal.Decimal // the account balance in the account's home currency. }
Account represents the current state of a standard trading account with a broker.
type Client ¶
type Client interface { // GetAccounts returns the IDs of all accounts registered with the broker. GetAccounts() (accountIDs []string, err error) // GetCurrencyPairs returns an overview of all currency pairs which can be traded. GetCurrencyPairs(accountID string) (pairs []forex.CurrencyPair, err error) // GetQuotes returns the latest price quotes for the given currency pairs. GetQuotes(accountID string, pairs []forex.CurrencyPair) (pricing []forex.Quote, err error) // GetQuoteStream returns a channel on which price quotes for the given currency pairs are streamed. GetQuoteStream(accountID string, pairs []forex.CurrencyPair) (ch chan forex.Quote, err error) // PlaceOrder places a (market) order for the given amount of units of the given currency pair. PlaceOrder(accountID string, pair forex.CurrencyPair, units decimal.Decimal) (orderID int, err error) }
Client is an interface to a generic broker which the trader can use to get price information and place trades.
type MarketOrder ¶ added in v0.2.0
type MarketOrder struct { Units decimal.Decimal Pair forex.CurrencyPair }
type Trader ¶
type Trader struct {
// contains filtered or unexported fields
}
Trader is a trader that uses moving averages (MA) to decide when to buy and sell.
func NewTrader ¶
New returns a new Trader which uses the given orderer to place orders and the given retriever to retrieve prices.
func (*Trader) SetWindowSize ¶ added in v0.3.0
SetWindowSize sets the trading window size. Window size is 0 by default -- every quote is counted.
Click to show internal directories.
Click to hide internal directories.