Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug fix for FMV with stocks, options, forex, or crypto #376

Merged
merged 2 commits into from
Dec 14, 2023

Conversation

justinpolygon
Copy link
Contributor

This PR addresses a bug related to the support of BusinessFairMarketValue (FMV) in different market types. Previously, our supports function in the Market type only checked if a topic was within predefined min-max ranges for each market type (Stocks, Options, Forex, Crypto). This implementation did not account for FMV, which falls outside these ranges but is relevant and essential for these market types.

Changes Made:

  • Modified the supports function to include a check for BusinessFairMarketValue.
  • Ensured FMV is now supported for Stocks, Options, Forex, and Crypto markets.
  • Added a clarifying comment in the code to explain the rationale behind the additional check for FMV.

Impact:

  • This fix allows FMV to be recognized as a supported topic in the relevant market types, aligning the functionality with our intended feature set.

Here's a text script:

package main

import (
	"os"
	"os/signal"

	polygonws "github.com/polygon-io/client-go/websocket"
	"github.com/polygon-io/client-go/websocket/models"
	"github.com/sirupsen/logrus"
)

func main() {
	log := logrus.New()
	log.SetLevel(logrus.DebugLevel)
	log.SetFormatter(&logrus.JSONFormatter{})
	c, err := polygonws.New(polygonws.Config{
		APIKey: os.Getenv("POLYGON_API_KEY"),
		Feed:   polygonws.BusinessFeed,
		Market: polygonws.Stocks,
		Log:    log,
	})
	if err != nil {
		log.Fatal(err)
	}
	defer c.Close()

	// FMV
	_ = c.Subscribe(polygonws.BusinessFairMarketValue, "*")

	if err := c.Connect(); err != nil {
		log.Error(err)
		return
	}

	sigint := make(chan os.Signal, 1)
	signal.Notify(sigint, os.Interrupt)

	for {
		select {
		case <-sigint:
			return
		case <-c.Error():
			return
		case out, more := <-c.Output():
			if !more {
				return
			}
			switch out.(type) {
			case models.FairMarketValue:
				log.WithFields(logrus.Fields{"fmv": out}).Info()
			default:
				log.WithFields(logrus.Fields{"unknown": out}).Info()
			}
		}
	}
}

@justinpolygon
Copy link
Contributor Author

I'm not sure what the lint errors are about these are unrelated to my change.

@ttong-ai
Copy link

Would you be able to merge this and publish a new release? We are waiting for this release :-)

Seems we hit a snack with outdated checks and updating them clears with error.
@justinpolygon justinpolygon merged commit f38129e into master Dec 14, 2023
16 checks passed
@justinpolygon justinpolygon deleted the jw-market-fmv-fix branch December 14, 2023 22:50
@justinpolygon
Copy link
Contributor Author

@ttong-ai FYI - v1.16.2 has been released with this fix.

Adam-Mustafa pushed a commit to FinTronners/polygon-client-go that referenced this pull request Mar 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants