Home

Awesome

GoDoc License Go Report Card Go CI codecov

Indicator Alpaca

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.

Example

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()
<!-- gomarkdoc:embed:start --> <!-- Code generated by gomarkdoc. DO NOT EDIT -->

indicatoralpaca

import "github.com/cinar/indicatoralpaca"

Package indicatoralpaca provides Alpaca Markets inintegration for the Indicator technical analysis library.

Index

Constants

<a name="DefaultAlpacaBarsRepositoryTimeFrameUnit"></a>

const (
    // DefaultAlpacaBarsRepositoryTimeFrameUnit is the default time frame unit of a day.
    DefaultAlpacaBarsRepositoryTimeFrameUnit = marketdata.Day
)

<a name="AlpacaBarsRepository"></a>

type AlpacaBarsRepository

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
}

<a name="NewAlpacaBarsRepository"></a>

func NewAlpacaBarsRepository

func NewAlpacaBarsRepository(apiKey, apiSecret string) *AlpacaBarsRepository

NewAlpacaBarsRepository initializes an Alpaca Markets repository with the given API key and API secret.

<a name="NewAlpacaBarsRepositoryWithClient"></a>

func NewAlpacaBarsRepositoryWithClient

func NewAlpacaBarsRepositoryWithClient(client *marketdata.Client) *AlpacaBarsRepository

NewAlpacaBarsRepositoryWithClient initializes an Alpaca Markets repository with the given client.

<a name="AlpacaBarsRepository.Append"></a>

func (*AlpacaBarsRepository) Append

func (*AlpacaBarsRepository) Append(_ string, _ <-chan *asset.Snapshot) error

Append adds the given snapshows to the asset with the given name.

<a name="AlpacaBarsRepository.Assets"></a>

func (*AlpacaBarsRepository) Assets

func (*AlpacaBarsRepository) Assets() ([]string, error)

Assets returns the names of all assets in the repository.

<a name="AlpacaBarsRepository.Get"></a>

func (*AlpacaBarsRepository) Get

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.

<a name="AlpacaBarsRepository.GetSince"></a>

func (*AlpacaBarsRepository) GetSince

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.

<a name="AlpacaBarsRepository.LastDate"></a>

func (*AlpacaBarsRepository) LastDate

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

<!-- gomarkdoc:embed:end -->

Contributing to the Project

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.

Disclaimer

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.

License

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/>.