connect

package module
v0.0.0-...-0b3e7cc Latest Latest
Warning

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

Go to latest
Published: May 16, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Overview

This package is for connecting to a local instance of PostgreSQL while acquiring FOREX data from Oanda.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ConnectPSQL

func ConnectPSQL(ctx context.Context, user string, password string, dbname string, sslmode string) (*pgxpool.Pool, error)

Connect to local instance of PostgreSQL.

Requires username, password, database name, and if ssl mode should use encryption or not ("enable" or "disable")

func GetStreamPSQL

func GetStreamPSQL(ctx context.Context, conn *pgxpool.Pool, password string, instrument string, token string, id string, display bool)

Get JSON Stream for Pricing endpoint - returns live Bid/Ask.

  • Parameters requires list of instruments, token, and id

See Pricing - stream endpoint

func ImportPassword_

func ImportPassword_() string

Be careful not to expose your password to the public modify password_edit.go file found in connect directory rename that file password.go and this file only has one function. This functions name needs to be edited by removing the underscore at the end of 'ImportPassword_' function. modify the return statement for the password of your PostgreSQL user that is accessing your local instance

Types

type HeartBeat

type HeartBeat struct {
	Type string `json:"type"`
	Time string `json:"time"`
}

struct for unmarshalling json data from Oanda's Pricing - stream endpoint.

Note: every 5 seconds a 'heartbeat' is sent from this endpoint to let you know the connection is still alive.

type Stream

type Stream struct {
	Type string `json:"type"`
	Time string `json:"time"`
	Bids [1]struct {
		Price     string `json:"price"`
		Liquidity int64  `json:"liquidity"`
	} `json:"bids"`
	Asks [1]struct {
		Price     string `json:"price"`
		Liquidity int64  `json:"liquidity"`
	} `json:"asks"`
	CloseOutBid string `json:"closeoutbid"`
	CloseOutAsk string `json:"closeoutask"`
	Status      string `json:"status"`
	Tradeable   bool   `json:"tradeable"`
	Instrument  string `json:"instrument"`
}

struct for unmarshalling json data from Oanda's Pricing - stream endpoint.

Jump to

Keyboard shortcuts

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