optionscrapers

package
v1.3.6-rc-128 Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2022 License: GPL-2.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var Exchanges map[string]dia.Exchange
View Source
var OtokenControllerAddress = common.HexToAddress("0x4ccc2339F87F6c59c6893E1A678c2266cA58dC72")
View Source
var OtokenFactoryAddress = common.HexToAddress("0x7C06792Af1632E77cb27a558Dc0885338F4Bdf8E")
View Source
var PremiaMarketAddress = common.HexToAddress("0x45eBD0FC72E2056adb5c864Ea6F151ad943d94af")
View Source
var PremiaOptionAddress = common.HexToAddress("0x5920cb60B1c62dC69467bf7c6EDFcFb3f98548c0")

Functions

This section is empty.

Types

type AllOKExOptionsScrapers

type AllOKExOptionsScrapers struct {
	Scrapers []*OKExOptionsScraper
	Markets  []string
	// contains filtered or unexported fields
}

type DeribitETHOptionScraper

type DeribitETHOptionScraper struct {
	PollFrequency      int8
	ScraperIsRunning   bool
	ScraperIsRunningMu sync.Mutex

	DataStore *models.DB

	Ratelimiter *rate.Limiter
	// contains filtered or unexported fields
}

func NewDeribitETHOptionScraper

func NewDeribitETHOptionScraper() *DeribitETHOptionScraper

func (*DeribitETHOptionScraper) Channel

func (scraper *DeribitETHOptionScraper) Channel() chan *dia.OptionOrderbookDatum

func (*DeribitETHOptionScraper) FetchInstruments

func (scraper *DeribitETHOptionScraper) FetchInstruments()

func (*DeribitETHOptionScraper) GetAndStoreOptionsMeta

func (scraper *DeribitETHOptionScraper) GetAndStoreOptionsMeta() (err error)

func (*DeribitETHOptionScraper) MetaOnOptionIsAvailable

func (scraper *DeribitETHOptionScraper) MetaOnOptionIsAvailable(option DeribitInstrument) (available bool, err error)

func (*DeribitETHOptionScraper) Scrape

func (scraper *DeribitETHOptionScraper) Scrape()

type DeribitInstrument

type DeribitInstrument struct {
	TickSize                 float64 `json:"tick_size"`
	TakerCommission          float64 `json:"taker_commission"`
	Strike                   float64 `json:"strike,omitempty"`
	SettlementPeriod         string  `json:"settlement_period"`
	QuoteCurrency            string  `json:"quote_currency"`
	OptionType               string  `json:"option_type,omitempty"`
	MinTradeAmount           int     `json:"min_trade_amount"`
	MakerCommission          float64 `json:"maker_commission"`
	Kind                     string  `json:"kind"`
	IsActive                 bool    `json:"is_active"`
	InstrumentName           string  `json:"instrument_name"`
	ExpirationTimestamp      int64   `json:"expiration_timestamp"`
	CreationTimestamp        int64   `json:"creation_timestamp"`
	ContractSize             float64 `json:"contract_size"`
	BlockTradeCommission     float64 `json:"block_trade_commission"`
	BaseCurrency             string  `json:"base_currency"`
	MaxLiquidationCommission float64 `json:"max_liquidation_commission,omitempty"`
	MaxLeverage              int     `json:"max_leverage,omitempty"`
}

type DeribitInstrumentsResponse

type DeribitInstrumentsResponse struct {
	Jsonrpc string              `json:"jsonrpc"`
	Result  []DeribitInstrument `json:"result"`
	UsIn    int64               `json:"usIn"`
	UsOut   int64               `json:"usOut"`
	UsDiff  int                 `json:"usDiff"`
	Testnet bool                `json:"testnet"`
}

type DeribitOptionResponse

type DeribitOptionResponse struct {
	Jsonrpc string `json:"jsonrpc"`
	Method  string `json:"method"`
	Params  struct {
		Channel string `json:"channel"`
		Data    struct {
			Asks           [][]interface{} `json:"asks,omitempty"`
			Bids           [][]interface{} `json:"bids,omitempty"`
			ChangeID       int64           `json:"change_id"`
			InstrumentName string          `json:"instrument_name"`
			PrevChangeID   int64           `json:"prev_change_id"`
			Timestamp      int64           `json:"timestamp"`
			Type           string          `json:"type"`
		} `json:"data"`
	} `json:"params"`
}

type DeribitOptionsResponse

type DeribitOptionsResponse struct {
	Jsonrpc string              `json:"jsonrpc"`
	Result  []DeribitInstrument `json:"result"`
	UsIn    int64               `json:"usIn"`
	UsOut   int64               `json:"usOut"`
	UsDiff  int                 `json:"usDiff"`
	Testnet bool                `json:"testnet"`
}

type DeribitParam

type DeribitParam struct {
	Channels []string `json:"channels"`
}

type DeribitRequest

type DeribitRequest struct {
	Jsonrpc string      `json:"jsonrpc"`
	ID      int         `json:"id"`
	Method  string      `json:"method"`
	Params  interface{} `json:"params"`
}

type OKExInstrument

type OKExInstrument struct {
	InstrumentName        string `json:"instrument_id"`
	Underlying            string `json:"underlying"`
	SettlementCurrency    string `json:"settlement_currency"`
	MinTradeAmount        string `json:"contract_val"`
	OptionType            string `json:"option_type"`
	Strike                string `json:"strike"`
	TickSize              string `json:"tick_size"`
	LotSize               string `json:"lot_size"`
	Listing               string `json:"listing"`
	Expiration            string `json:"delivery"`
	State                 string `json:"state"`
	TradingStartTimestamp string `json:"trading_start_time"`
}

type OKExInstrumentDetail

type OKExInstrumentDetail struct {
	Category           string    `json:"category"`
	ContractVal        string    `json:"contract_val"`
	Delivery           time.Time `json:"delivery"`
	InstrumentID       string    `json:"instrument_id"`
	Listing            time.Time `json:"listing"`
	LotSize            string    `json:"lot_size"`
	OptionType         string    `json:"option_type"`
	SettlementCurrency string    `json:"settlement_currency"`
	State              string    `json:"state"`
	Strike             string    `json:"strike"`
	TickSize           string    `json:"tick_size"`
	Timestamp          time.Time `json:"timestamp"`
	TradingStartTime   time.Time `json:"trading_start_time"`
	Underlying         string    `json:"underlying"`
}

type OKExInstrumentDetails

type OKExInstrumentDetails []OKExInstrumentDetail

type OKExInstruments

type OKExInstruments struct {
	Result []OKExInstrument `json:"result"`
}

type OKExOptionState

type OKExOptionState int
const (
	PreOpen OKExOptionState = iota + 1
	Live
	Suspended
	Settlement
)

type OKExOptionsScraper

type OKExOptionsScraper struct {
	Markets []string

	// OKEx Options endpoint is a REST one and you are limited to 20 requests per 2 seconds. So you have
	// to throttle your polling frequency. This is in seconds. So you can have at most 10
	// markets running at the same time on the same ip address
	PollFrequency      int8
	ScraperIsRunning   bool
	ScraperIsRunningMu sync.Mutex
	// optionsWaitGroup   *sync.WaitGroup
	DataStore *models.DB

	Ratelimiter *rate.Limiter
	// contains filtered or unexported fields
}

func NewOKExOptionsScraper

func NewOKExOptionsScraper(pollFreq int8) *OKExOptionsScraper

func (*OKExOptionsScraper) Channel

func (s *OKExOptionsScraper) Channel() chan *dia.OptionOrderbookDatum

func (*OKExOptionsScraper) FetchInstruments

func (s *OKExOptionsScraper) FetchInstruments()

func (*OKExOptionsScraper) GetAndStoreOptionsMeta

func (s *OKExOptionsScraper) GetAndStoreOptionsMeta() (err error)

func (*OKExOptionsScraper) MetaOnOptionIsAvailable

func (s *OKExOptionsScraper) MetaOnOptionIsAvailable(option OKExInstrument) (available bool, err error)

func (*OKExOptionsScraper) Scrape

func (s *OKExOptionsScraper) Scrape()

func (*OKExOptionsScraper) ScrapeInstrument

func (s *OKExOptionsScraper) ScrapeInstrument(market string)

type OptionAttrs

type OptionAttrs struct {
	// contains filtered or unexported fields
}

type OptionsScraper

type OptionsScraper interface {
	//io.Closer
	FetchInstruments()
	Scrape()
	// Channel returns a channel that can be used to receive trades
	Channel() chan *dia.OptionOrderbookDatum
}
OptionsScraper provides common methods needed to get Option orderBook information from

exchange APIs.

func New

func New(exchange string, key string, secret string) OptionsScraper

type OpynInstrumentsResponse

type OpynInstrumentsResponse struct {
	Bids struct {
		Total   int `json:"total"`
		Page    int `json:"page"`
		PerPage int `json:"perPage"`
		Records []struct {
			Order struct {
				Signature struct {
					SignatureType int    `json:"signatureType"`
					R             string `json:"r"`
					S             string `json:"s"`
					V             int    `json:"v"`
				} `json:"signature"`
				Sender              string `json:"sender"`
				Maker               string `json:"maker"`
				Taker               string `json:"taker"`
				TakerTokenFeeAmount string `json:"takerTokenFeeAmount"`
				MakerAmount         string `json:"makerAmount"`
				TakerAmount         string `json:"takerAmount"`
				MakerToken          string `json:"makerToken"`
				TakerToken          string `json:"takerToken"`
				Salt                string `json:"salt"`
				VerifyingContract   string `json:"verifyingContract"`
				FeeRecipient        string `json:"feeRecipient"`
				Expiry              string `json:"expiry"`
				ChainID             int    `json:"chainId"`
				Pool                string `json:"pool"`
			} `json:"order"`
			MetaData struct {
				OrderHash                    string    `json:"orderHash"`
				RemainingFillableTakerAmount string    `json:"remainingFillableTakerAmount"`
				CreatedAt                    time.Time `json:"createdAt"`
			} `json:"metaData"`
		} `json:"records"`
	} `json:"bids"`
	Asks struct {
		Total   int `json:"total"`
		Page    int `json:"page"`
		PerPage int `json:"perPage"`
		Records []struct {
			Order struct {
				Signature struct {
					SignatureType int    `json:"signatureType"`
					R             string `json:"r"`
					S             string `json:"s"`
					V             int    `json:"v"`
				} `json:"signature"`
				Sender              string `json:"sender"`
				Maker               string `json:"maker"`
				Taker               string `json:"taker"`
				TakerTokenFeeAmount string `json:"takerTokenFeeAmount"`
				MakerAmount         string `json:"makerAmount"`
				TakerAmount         string `json:"takerAmount"`
				MakerToken          string `json:"makerToken"`
				TakerToken          string `json:"takerToken"`
				Salt                string `json:"salt"`
				VerifyingContract   string `json:"verifyingContract"`
				FeeRecipient        string `json:"feeRecipient"`
				Expiry              string `json:"expiry"`
				ChainID             int    `json:"chainId"`
				Pool                string `json:"pool"`
			} `json:"order"`
			MetaData struct {
				OrderHash                    string    `json:"orderHash"`
				RemainingFillableTakerAmount string    `json:"remainingFillableTakerAmount"`
				CreatedAt                    time.Time `json:"createdAt"`
			} `json:"metaData"`
		} `json:"records"`
	} `json:"asks"`
}

type OpynOptionScraper

type OpynOptionScraper struct {
	WsClient   *ethclient.Client
	RestClient *ethclient.Client

	PollFrequency      int8
	ScraperIsRunning   bool
	ScraperIsRunningMu sync.Mutex

	DataStore *models.DB

	Ratelimiter *rate.Limiter
	// contains filtered or unexported fields
}

func NewOpynETHOptionScraper

func NewOpynETHOptionScraper() *OpynOptionScraper

func (*OpynOptionScraper) Channel

func (scraper *OpynOptionScraper) Channel() chan *dia.OptionOrderbookDatum

func (*OpynOptionScraper) FetchInstruments

func (scraper *OpynOptionScraper) FetchInstruments()

func (*OpynOptionScraper) FetchMarkets

func (scraper *OpynOptionScraper) FetchMarkets()

func (*OpynOptionScraper) GetAndStoreOptionsMeta

func (scraper *OpynOptionScraper) GetAndStoreOptionsMeta() (err error)

func (*OpynOptionScraper) MetaOnOptionIsAvailable

func (scraper *OpynOptionScraper) MetaOnOptionIsAvailable(option OptionAttrs) (available bool, err error)

func (*OpynOptionScraper) Scrape

func (scraper *OpynOptionScraper) Scrape()

type PremiaScraper

type PremiaScraper struct {
	WsClient   *ethclient.Client
	RestClient *ethclient.Client

	PollFrequency      int8
	ScraperIsRunning   bool
	ScraperIsRunningMu sync.Mutex

	DataStore *models.DB

	Ratelimiter *rate.Limiter
	// contains filtered or unexported fields
}

func NewPremiaETHOptionScraper

func NewPremiaETHOptionScraper() *PremiaScraper

func (*PremiaScraper) Channel

func (scrapper *PremiaScraper) Channel() chan *dia.OptionOrderbookDatum

func (*PremiaScraper) FetchInstruments

func (scrapper *PremiaScraper) FetchInstruments()

func (*PremiaScraper) FetchMarkets

func (scrapper *PremiaScraper) FetchMarkets()

func (*PremiaScraper) Scrape

func (scrapper *PremiaScraper) Scrape()

Directories

Path Synopsis
opyncontracts
premiacontracts

Jump to

Keyboard shortcuts

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