indicatoralpaca

package module
v1.3.1 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2024 License: AGPL-3.0 Imports: 5 Imported by: 0

README

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()

indicatoralpaca

import "github.com/cinar/indicatoralpaca"

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

Index

Constants

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

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
}

func NewAlpacaBarsRepository
func NewAlpacaBarsRepository(apiKey, apiSecret string) *AlpacaBarsRepository

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

func NewAlpacaBarsRepositoryWithClient
func NewAlpacaBarsRepositoryWithClient(client *marketdata.Client) *AlpacaBarsRepository

NewAlpacaBarsRepositoryWithClient initializes an Alpaca Markets repository with the given client.

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

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

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

Assets returns the names of all assets in the repository.

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.

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.

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

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

Documentation

Overview

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

Index

Constants

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

Variables

This section is empty.

Functions

This section is empty.

Types

type AlpacaBarsRepository added in v1.0.1

type AlpacaBarsRepository struct {

	// GetBarsRequestTemplate is the request template used to get the bars.
	GetBarsRequestTemplate marketdata.GetBarsRequest
	// contains filtered or unexported fields
}

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.

func NewAlpacaBarsRepository added in v1.0.1

func NewAlpacaBarsRepository(apiKey, apiSecret string) *AlpacaBarsRepository

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

func NewAlpacaBarsRepositoryWithClient added in v1.0.1

func NewAlpacaBarsRepositoryWithClient(client *marketdata.Client) *AlpacaBarsRepository

NewAlpacaBarsRepositoryWithClient initializes an Alpaca Markets repository with the given client.

func (*AlpacaBarsRepository) Append added in v1.0.1

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

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

func (*AlpacaBarsRepository) Assets added in v1.0.1

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

Assets returns the names of all assets in the repository.

func (*AlpacaBarsRepository) Get added in v1.0.1

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 (*AlpacaBarsRepository) GetSince added in v1.0.1

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 (*AlpacaBarsRepository) LastDate added in v1.0.1

func (r *AlpacaBarsRepository) LastDate(name string) (time.Time, error)

LastDate returns the date of the last snapshot for the asset with the given name.

Jump to

Keyboard shortcuts

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