Files
m3o-go/examples/forex/README.md
2022-02-21 16:23:55 +00:00

1.4 KiB
Executable File

Forex

An m3o.com API. For example usage see m3o.com/forex/api.

Endpoints:

Quote

Get the latest quote for the forex

https://m3o.com/forex/api#Quote

package example

import(
	"fmt"
	"os"

	"go.m3o.com/forex"
)

// Get the latest quote for the forex
func GetAfxQuote() {
	forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
	rsp, err := forexService.Quote(&forex.QuoteRequest{
		Symbol: "GBPUSD",

	})
	fmt.Println(rsp, err)
	
}

History

Returns the data for the previous close

https://m3o.com/forex/api#History

package example

import(
	"fmt"
	"os"

	"go.m3o.com/forex"
)

// Returns the data for the previous close
func GetPreviousClose() {
	forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
	rsp, err := forexService.History(&forex.HistoryRequest{
		Symbol: "GBPUSD",

	})
	fmt.Println(rsp, err)
	
}

Price

Get the latest price for a given forex ticker

https://m3o.com/forex/api#Price

package example

import(
	"fmt"
	"os"

	"go.m3o.com/forex"
)

// Get the latest price for a given forex ticker
func GetAnFxPrice() {
	forexService := forex.NewForexService(os.Getenv("M3O_API_TOKEN"))
	rsp, err := forexService.Price(&forex.PriceRequest{
		Symbol: "GBPUSD",

	})
	fmt.Println(rsp, err)
	
}