eod

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jun 22, 2022 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Copyright 2022 SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2022 SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Copyright 2022 SPDX-License-Identifier: Apache-2.0

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrInvalidConfig = errors.New("one of CompositeFigi or FileName must be set on a component")
)

Functions

func PrintEod

func PrintEod(quotes []*Eod)

PrintEod prints EOD quotes to the screen

func SaveAdjCloseToDb

func SaveAdjCloseToDb(ctx context.Context, conn PgxIface, prices []*Eod) error

SaveAdjCloseToDb updates database record with adjusted close value

func UpdateSyntheticHistory

func UpdateSyntheticHistory(ctx context.Context, conn *pgx.Conn, asset *SyntheticAsset, history []*Eod) error

UpdateSyntheticHistory updates the database with the synthetic asset

Types

type Eod

type Eod struct {
	EventDate     time.Time
	EventDateStr  string `csv:"date"`
	Ticker        string
	CompositeFigi string
	Close         float64
	AdjClose      float64 `csv:"adjClose"`
	Dividend      float64
	SplitFactor   float64
}

func AdjustAssetEodPrice

func AdjustAssetEodPrice(ctx context.Context, conn PgxIface, compositeFigi string) ([]*Eod, error)

func BuildSyntheticHistory

func BuildSyntheticHistory(ctx context.Context, asset *SyntheticAsset, history []*Eod) ([]*Eod, error)

BuildSyntheticHistory iterates over all the components of a synthetic asset and calculates

func LoadEodHistory

func LoadEodHistory(ctx context.Context, conn *pgx.Conn, asset *SyntheticAsset) []*Eod

loadEodHistory reads recent EOD quotes from eod

type PercentChange

type PercentChange struct {
	Date    time.Time
	Percent float64
}

type PgxIface

type PgxIface interface {
	Begin(context.Context) (pgx.Tx, error)
	Exec(context.Context, string, ...interface{}) (pgconn.CommandTag, error)
	QueryRow(context.Context, string, ...interface{}) pgx.Row
	Query(context.Context, string, ...interface{}) (pgx.Rows, error)
}

type SyntheticAsset

type SyntheticAsset struct {
	Category      string
	Components    []*SyntheticComponent
	CompositeFigi string
	Name          string
	StartDate     time.Time
	Symbol        string
}

type SyntheticComponent

type SyntheticComponent struct {
	CompositeFigi string
	FileName      string
	Name          string
	Start         time.Time
	Source        []string
	Symbol        string
	End           time.Time
}

Jump to

Keyboard shortcuts

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