quote

package module
v0.0.0-...-f293390 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2023 License: MIT Imports: 22 Imported by: 0

README

go-quote

github.com/markcheno/go-quote add customize http.client

Install library

Install the package with:

go get github.com/lzy1102/quote

Library example

package main

import (
	"crypto/tls"
	"fmt"
	"github.com/lzy1102/go-quote"
	"github.com/markcheno/go-talib"
	"net/http"
	"net/url"
)

func main() {
	proxyurl, _ := url.Parse("http://127.0.0.1:10809")
	client := &http.Client{
		Transport: &http.Transport{
			Proxy:             http.ProxyURL(proxyurl),
			DisableKeepAlives: true,
			TLSClientConfig:   &tls.Config{InsecureSkipVerify: true},
		},
	}
	spy, _ := quote.NewQuoteFromYahoo("spy", "2016-01-01", "2021-04-01", quote.Daily, true, client)
	fmt.Print(spy.CSV())
	rsi2 := talib.Rsi(spy.Close, 2)
	fmt.Println(rsi2)
}

License

MIT License - see LICENSE for more details

Documentation

Overview

Package quote is free quote downloader library and cli

Downloads daily/weekly/monthly historical price quotes from Yahoo and daily/intraday data from Tiingo/Bittrex/Binance

Copyright 2019 Mark Chenoweth Licensed under terms of MIT license (see LICENSE)

Index

Constants

View Source
const ClientTimeout = 10 * time.Second

ClientTimeout - connect/read timeout for client requests

Variables

Delay - time delay in milliseconds between quote requests (default=100) Be nice, don't get blocked

Log - standard logger, disabled by default

View Source
var ValidMarkets = [...]string{"etf",

	"bittrex-btc",
	"bittrex-eth",
	"bittrex-usdt",
	"binance-bnb",
	"binance-btc",
	"binance-eth",
	"binance-usdt",

	"coinbase",
}

ValidMarkets list of markets that can be downloaded

Functions

func NewEtfFile

func NewEtfFile(filename string) error

NewEtfFile - download a list of etf symbols to a file

func NewEtfList

func NewEtfList() ([]string, error)

NewEtfList - download a list of etf symbols to an array of strings

func NewMarketFile

func NewMarketFile(market, filename string) error

NewMarketFile - download a list of market symbols to a file

func NewMarketList

func NewMarketList(market string) ([]string, error)

NewMarketList - download a list of market symbols to an array of strings

func NewSymbolsFromFile

func NewSymbolsFromFile(filename string) ([]string, error)

NewSymbolsFromFile - read symbols from a file

func ParseDateString

func ParseDateString(dt string) time.Time

ParseDateString - parse a potentially partial date string to Time

func ReadBinaryXlsx

func ReadBinaryXlsx(data []byte) (res [][]string)

func ReadCsv

func ReadCsv(file_path string) (res [][]string)

func ReadXls

func ReadXls(fileReader io.ReadSeeker) (res [][]string)

func ValidMarket

func ValidMarket(market string) bool

ValidMarket - validate market string

Types

type CodeTable

type CodeTable struct {
	Symbol      string
	ListingDate string
	Name        string
	Industry    string
}

func GetNewTable

func GetNewTable() ([]CodeTable, error)

type Period

type Period string

Period - for quote history

const (
	// Min1 - 1 Minute time period
	Min1 Period = "60"
	// Min3 - 3 Minute time period
	Min3 Period = "3m"
	// Min5 - 5 Minute time period
	Min5 Period = "300"
	// Min15 - 15 Minute time period
	Min15 Period = "900"
	// Min30 - 30 Minute time period
	Min30 Period = "1800"
	// Min60 - 60 Minute time period
	Min60 Period = "3600"
	// Hour2 - 2 hour time period
	Hour2 Period = "2h"
	// Hour4 - 4 hour time period
	Hour4 Period = "4h"
	// Hour6 - 6 hour time period
	Hour6 Period = "6h"
	// Hour8 - 8 hour time period
	Hour8 Period = "8h"
	// Hour12 - 12 hour time period
	Hour12 Period = "12h"
	// Daily time period
	Daily Period = "d"
	// Day3 - 3 day time period
	Day3 Period = "3d"
	// Weekly time period
	Weekly Period = "w"
	// Monthly time period
	Monthly Period = "m"
)

type Quote

type Quote struct {
	Symbol    string      `json:"symbol"`
	Precision int64       `json:"-"`
	Date      []time.Time `json:"date"`
	Open      []float64   `json:"open"`
	High      []float64   `json:"high"`
	Low       []float64   `json:"low"`
	Close     []float64   `json:"close"`
	Volume    []float64   `json:"volume"`
}

Quote - stucture for historical price data

func NewQuote

func NewQuote(symbol string, bars int) Quote

NewQuote - new empty Quote struct

func NewQuoteFromBinance

func NewQuoteFromBinance(symbol string, startDate, endDate string, period Period) (Quote, error)

NewQuoteFromBinance - Binance historical prices for a symbol

func NewQuoteFromBittrex

func NewQuoteFromBittrex(symbol string, period Period) (Quote, error)

NewQuoteFromBittrex - Biitrex historical prices for a symbol

func NewQuoteFromCSV

func NewQuoteFromCSV(symbol, csv string) (Quote, error)

NewQuoteFromCSV - parse csv quote string into Quote structure

func NewQuoteFromCSVDateFormat

func NewQuoteFromCSVDateFormat(symbol, csv string, format string) (Quote, error)

NewQuoteFromCSVDateFormat - parse csv quote string into Quote structure with specified DateTime format

func NewQuoteFromCSVFile

func NewQuoteFromCSVFile(symbol, filename string) (Quote, error)

NewQuoteFromCSVFile - parse csv quote file into Quote structure

func NewQuoteFromCSVFileDateFormat

func NewQuoteFromCSVFileDateFormat(symbol, filename string, format string) (Quote, error)

NewQuoteFromCSVFileDateFormat - parse csv quote file into Quote structure with specified DateTime format

func NewQuoteFromCoinbase

func NewQuoteFromCoinbase(symbol, startDate, endDate string, period Period) (Quote, error)

NewQuoteFromCoinbase - Coinbase Pro historical prices for a symbol

func NewQuoteFromExchange

func NewQuoteFromExchange(symbol, startDate, endDate string, period Period, client *req.Client) (Quote, error)

func NewQuoteFromJSON

func NewQuoteFromJSON(jsn string) (Quote, error)

NewQuoteFromJSON - parse json quote string into Quote structure

func NewQuoteFromJSONFile

func NewQuoteFromJSONFile(filename string) (Quote, error)

NewQuoteFromJSONFile - parse json quote string into Quote structure

func NewQuoteFromTiingo

func NewQuoteFromTiingo(symbol, startDate, endDate string, token string) (Quote, error)

NewQuoteFromTiingo - Tiingo daily historical prices for a symbol

func NewQuoteFromTiingoCrypto

func NewQuoteFromTiingoCrypto(symbol, startDate, endDate string, period Period, token string) (Quote, error)

NewQuoteFromTiingoCrypto - Tiingo crypto historical prices for a symbol

func NewQuoteFromXueqiu

func NewQuoteFromXueqiu(symbol, startDate, endDate string, period Period, client *req.Client) (Quote, error)

func NewQuoteFromYahoo

func NewQuoteFromYahoo(symbol, startDate, endDate string, period Period, adjustQuote bool, client *req.Client) (Quote, error)

func (Quote) Amibroker

func (q Quote) Amibroker() string

Amibroker - convert Quote structure to csv string

func (Quote) CSV

func (q Quote) CSV() string

CSV - convert Quote structure to csv string

func (Quote) Highstock

func (q Quote) Highstock() string

Highstock - convert Quote structure to Highstock json format

func (Quote) JSON

func (q Quote) JSON(indent bool) string

JSON - convert Quote struct to json string

func (Quote) WriteAmibroker

func (q Quote) WriteAmibroker(filename string) error

WriteAmibroker - write Quote struct to csv file

func (Quote) WriteCSV

func (q Quote) WriteCSV(filename string) error

WriteCSV - write Quote struct to csv file

func (Quote) WriteHighstock

func (q Quote) WriteHighstock(filename string) error

WriteHighstock - write Quote struct to Highstock json format

func (Quote) WriteJSON

func (q Quote) WriteJSON(filename string, indent bool) error

WriteJSON - write Quote struct to json file

type Quotes

type Quotes []Quote

Quotes - an array of historical price data

func NewQuotesFromBinance

func NewQuotesFromBinance(filename string, startDate, endDate string, period Period) (Quotes, error)

NewQuotesFromBinance - create a list of prices from symbols in file

func NewQuotesFromBinanceSyms

func NewQuotesFromBinanceSyms(symbols []string, startDate, endDate string, period Period) (Quotes, error)

NewQuotesFromBinanceSyms - create a list of prices from symbols in string array

func NewQuotesFromBittrex

func NewQuotesFromBittrex(filename string, period Period) (Quotes, error)

NewQuotesFromBittrex - create a list of prices from symbols in file

func NewQuotesFromBittrexSyms

func NewQuotesFromBittrexSyms(symbols []string, period Period) (Quotes, error)

NewQuotesFromBittrexSyms - create a list of prices from symbols in string array

func NewQuotesFromCSV

func NewQuotesFromCSV(csv string) (Quotes, error)

NewQuotesFromCSV - parse csv quote string into Quotes array

func NewQuotesFromCSVFile

func NewQuotesFromCSVFile(filename string) (Quotes, error)

NewQuotesFromCSVFile - parse csv quote file into Quotes array

func NewQuotesFromCoinbase

func NewQuotesFromCoinbase(filename, startDate, endDate string, period Period) (Quotes, error)

NewQuotesFromCoinbase - create a list of prices from symbols in file

func NewQuotesFromCoinbaseSyms

func NewQuotesFromCoinbaseSyms(symbols []string, startDate, endDate string, period Period) (Quotes, error)

NewQuotesFromCoinbaseSyms - create a list of prices from symbols in string array

func NewQuotesFromJSON

func NewQuotesFromJSON(jsn string) (Quotes, error)

NewQuotesFromJSON - parse json quote string into Quote structure

func NewQuotesFromJSONFile

func NewQuotesFromJSONFile(filename string) (Quotes, error)

NewQuotesFromJSONFile - parse json quote string into Quote structure

func NewQuotesFromTiingoCryptoSyms

func NewQuotesFromTiingoCryptoSyms(symbols []string, startDate, endDate string, period Period, token string) (Quotes, error)

NewQuotesFromTiingoCryptoSyms - create a list of prices from symbols in string array

func NewQuotesFromTiingoSyms

func NewQuotesFromTiingoSyms(symbols []string, startDate, endDate string, token string) (Quotes, error)

NewQuotesFromTiingoSyms - create a list of prices from symbols in string array

func NewQuotesFromYahoo

func NewQuotesFromYahoo(filename, startDate, endDate string, period Period, adjustQuote bool, client *req.Client) (Quotes, error)

NewQuotesFromYahoo - create a list of prices from symbols in file

func NewQuotesFromYahooSyms

func NewQuotesFromYahooSyms(symbols []string, startDate, endDate string, period Period, adjustQuote bool, client *req.Client) (Quotes, error)

NewQuotesFromYahooSyms - create a list of prices from symbols in string array

func (Quotes) Amibroker

func (q Quotes) Amibroker() string

Amibroker - convert Quotes structure to csv string

func (Quotes) CSV

func (q Quotes) CSV() string

CSV - convert Quotes structure to csv string

func (Quotes) Highstock

func (q Quotes) Highstock() string

Highstock - convert Quotes structure to Highstock json format

func (Quotes) JSON

func (q Quotes) JSON(indent bool) string

JSON - convert Quotes struct to json string

func (Quotes) WriteAmibroker

func (q Quotes) WriteAmibroker(filename string) error

WriteAmibroker - write Quotes structure to file

func (Quotes) WriteCSV

func (q Quotes) WriteCSV(filename string) error

WriteCSV - write Quotes structure to file

func (Quotes) WriteHighstock

func (q Quotes) WriteHighstock(filename string) error

WriteHighstock - write Quote struct to json file in Highstock format

func (Quotes) WriteJSON

func (q Quotes) WriteJSON(filename string, indent bool) error

WriteJSON - write Quote struct to json file

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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