Indicator Alpaca provides Alpaca Markets integration for Indicator Golang module that provides a rich set of technical analysis indicators, strategies, and a framework for backtesting.
This example showcases Alpaca Markets data access within the Indicator library.
// Initialize a new Alpaca Markets repository
repository := indicatoralpaca.NewAlpacaBarsRepository("key", "secret")
// Make any necessary changes in GetBarsRequest
repository.GetBarsRequestTempalte.Adjustment = "raw"
repository.GetBarsRequestTemplate.Currency = "usd"
// Use the Alpaca Markets repository in backtesting
backtest := strategy.NewBacktest(repository, "output")
backtest.Names = append(backtest.Names, "brk-b")
backtest.Strategies = append(backtest.Strategies, trend.NewAroonStrategy())
err = backtest.Run()
import "github.com/cinar/indicatoralpaca"
Package indicatoralpaca provides Alpaca Markets inintegration for the Indicator technical analysis library.
- Constants
- type AlpacaBarsRepository
- func NewAlpacaBarsRepository(apiKey, apiSecret string) *AlpacaBarsRepository
- func NewAlpacaBarsRepositoryWithClient(client *marketdata.Client) *AlpacaBarsRepository
- func (*AlpacaBarsRepository) Append(_ string, _ <-chan *asset.Snapshot) error
- func (*AlpacaBarsRepository) Assets() ([]string, error)
- func (r *AlpacaBarsRepository) Get(name string) (<-chan *asset.Snapshot, error)
- func (r *AlpacaBarsRepository) GetSince(name string, date time.Time) (<-chan *asset.Snapshot, error)
- func (r *AlpacaBarsRepository) LastDate(name string) (time.Time, error)
const (
// DefaultAlpacaBarsRepositoryTimeFrameUnit is the default time frame unit of a day.
DefaultAlpacaBarsRepositoryTimeFrameUnit = marketdata.Day
)
AlpacaBarsRepository provides access to financial market data, retrieving asset snapshots, by interacting with the Alpaca Markets API. To use this repository, you'll need a valid API key from https://alpaca.markets.
type AlpacaBarsRepository struct {
// GetBarsRequestTemplate is the request template used to get the bars.
GetBarsRequestTemplate marketdata.GetBarsRequest
// contains filtered or unexported fields
}
func NewAlpacaBarsRepository(apiKey, apiSecret string) *AlpacaBarsRepository
NewAlpacaBarsRepository initializes an Alpaca Markets repository with the given API key and API secret.
func NewAlpacaBarsRepositoryWithClient(client *marketdata.Client) *AlpacaBarsRepository
NewAlpacaBarsRepositoryWithClient initializes an Alpaca Markets repository with the given client.
func (*AlpacaBarsRepository) Append(_ string, _ <-chan *asset.Snapshot) error
Append adds the given snapshows to the asset with the given name.
func (*AlpacaBarsRepository) Assets() ([]string, error)
Assets returns the names of all assets in the repository.
func (r *AlpacaBarsRepository) Get(name string) (<-chan *asset.Snapshot, error)
Get attempts to return a channel of snapshots for the asset with the given name.
func (r *AlpacaBarsRepository) GetSince(name string, date time.Time) (<-chan *asset.Snapshot, error)
GetSince attempts to return a channel of snapshots for the asset with the given name since the given date.
func (r *AlpacaBarsRepository) LastDate(name string) (time.Time, error)
LastDate returns the date of the last snapshot for the asset with the given name.
Generated by gomarkdoc
Anyone can contribute to Indicator library. Please make sure to read our Contributor Covenant Code of Conduct guide first. Follow the How to Contribute to Indicator to contribute. Signining a Contributor Agreement is also required to contribute to the project.
The information provided on this project is strictly for informational purposes and is not to be construed as advice or solicitation to buy or sell any security.
Indicator libary dual-licensed under GNU AGPLv3 License and a commercial license. For free use and modifications of the code, you can use the AGPLv3 license. If you require commercial license with different terms, please contact me.
Copyright (c) 2021-2024 Onur Cinar.
The source code is provided under GNU AGPLv3 License.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU Affero General Public License as published
by the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details.
You should have received a copy of the GNU Affero General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.