china

package
v0.2.16 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2025 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewExchange

func NewExchange(Options map[string]interface{}) (banexg.BanExchange, *errs.Error)

Types

type China

type China struct {
	*banexg.Exchange
}

func New

func New(Options map[string]interface{}) (*China, *errs.Error)

func (*China) CalcMaintMargin

func (e *China) CalcMaintMargin(symbol string, cost float64) (float64, *errs.Error)

func (*China) CancelOrder

func (e *China) CancelOrder(id string, symbol string, params map[string]interface{}) (*banexg.Order, *errs.Error)

func (*China) Close

func (e *China) Close() *errs.Error

func (*China) CreateOrder

func (e *China) CreateOrder(symbol, odType, side string, amount, price float64, params map[string]interface{}) (*banexg.Order, *errs.Error)

func (*China) EditOrder

func (e *China) EditOrder(symbol, orderId, side string, amount, price float64, params map[string]interface{}) (*banexg.Order, *errs.Error)

func (*China) FetchAccountPositions

func (e *China) FetchAccountPositions(symbols []string, params map[string]interface{}) ([]*banexg.Position, *errs.Error)

func (*China) FetchBalance

func (e *China) FetchBalance(params map[string]interface{}) (*banexg.Balances, *errs.Error)

func (*China) FetchIncomeHistory

func (e *China) FetchIncomeHistory(inType string, symbol string, since int64, limit int, params map[string]interface{}) ([]*banexg.Income, *errs.Error)

func (*China) FetchOHLCV

func (e *China) FetchOHLCV(symbol, timeframe string, since int64, limit int, params map[string]interface{}) ([]*banexg.Kline, *errs.Error)

func (*China) FetchOpenOrders

func (e *China) FetchOpenOrders(symbol string, since int64, limit int, params map[string]interface{}) ([]*banexg.Order, *errs.Error)

func (*China) FetchOrder

func (e *China) FetchOrder(symbol, orderId string, params map[string]interface{}) (*banexg.Order, *errs.Error)

func (*China) FetchOrderBook

func (e *China) FetchOrderBook(symbol string, limit int, params map[string]interface{}) (*banexg.OrderBook, *errs.Error)

func (*China) FetchOrders

func (e *China) FetchOrders(symbol string, since int64, limit int, params map[string]interface{}) ([]*banexg.Order, *errs.Error)

func (*China) FetchPositions

func (e *China) FetchPositions(symbols []string, params map[string]interface{}) ([]*banexg.Position, *errs.Error)

func (*China) FetchTicker

func (e *China) FetchTicker(symbol string, params map[string]interface{}) (*banexg.Ticker, *errs.Error)

func (*China) FetchTickerPrice

func (e *China) FetchTickerPrice(symbol string, params map[string]interface{}) (map[string]float64, *errs.Error)

func (*China) FetchTickers

func (e *China) FetchTickers(symbols []string, params map[string]interface{}) ([]*banexg.Ticker, *errs.Error)

func (*China) GetLeverage

func (e *China) GetLeverage(symbol string, notional float64, account string) (float64, float64)

func (*China) Init

func (e *China) Init() *errs.Error

func (*China) LoadLeverageBrackets

func (e *China) LoadLeverageBrackets(reload bool, params map[string]interface{}) *errs.Error

func (*China) LoadMarkets

func (e *China) LoadMarkets(reload bool, params map[string]interface{}) (banexg.MarketMap, *errs.Error)

func (*China) MapMarket

func (e *China) MapMarket(exgSID string, year int) (*banexg.Market, *errs.Error)

func (*China) SetLeverage

func (e *China) SetLeverage(leverage float64, symbol string, params map[string]interface{}) (map[string]interface{}, *errs.Error)

type CnMarkets

type CnMarkets struct {
	Exchanges map[string]*Exchange `yaml:"exchanges"`
	Contracts []*ItemMarket        `yaml:"contracts"`
	Stocks    []*ItemMarket        `yaml:"stocks"`
}

type Exchange

type Exchange struct {
	Code       string `yaml:"code"`
	Title      string `yaml:"title"`
	IndexUrl   string `yaml:"index"`
	Suffix     string `yaml:"suffix"`
	CaseLower  bool   `yaml:"case_lower"`  // 品种ID是否小写
	DateNum    int    `yaml:"date_num"`    // 年月显示后几位?4或3
	OptionDash bool   `yaml:"option_dash"` // 期权C/P左右两侧是否有短横线
}

type Fee

type Fee struct {
	Unit  string  `yaml:"unit"`
	Val   float64 `yaml:"val"`
	ValCT float64 `yaml:"val_ct"` // 平今
	ValTD float64 `yaml:"val_td"` // 日内
}

func (*Fee) ParseStd

func (f *Fee) ParseStd()

type ItemMarket

type ItemMarket struct {
	Code        string   `yaml:"code"`
	Title       string   `yaml:"title"`
	Market      string   `yaml:"market"`
	Exchange    string   `yaml:"exchange"`
	Extend      string   `yaml:"extend"`
	Alias       []string `yaml:"alias"`
	DayRanges   []string `yaml:"day_ranges"`
	NightRanges []string `yaml:"night_ranges"`
	Fee         *Fee     `yaml:"fee"`
	Multiplier  float64  `yaml:"multiplier"`    // 合约乘数;价格单位是吨,每手含multiplier吨
	PriceTick   float64  `yaml:"price_tick"`    // 最小价格变动,单位:吨
	LimitChgPct float64  `yaml:"limit_chg_pct"` // 涨跌停板,单位:百分比
	MarginPct   float64  `yaml:"margin_pct"`    // 保证金比率,单位:百分比
}

func (*ItemMarket) Resolve

func (m *ItemMarket) Resolve(bases map[string]*ItemMarket)

func (*ItemMarket) ToRawSymbol

func (m *ItemMarket) ToRawSymbol(parts []*utils2.StrType) (string, *errs.Error)

ToRawSymbol 转为交易所Symbol

func (*ItemMarket) ToStdSymbol

func (m *ItemMarket) ToStdSymbol(parts []*utils2.StrType) (string, *errs.Error)

ToStdSymbol 转为标准Symbol,注意期货的年月需要提前归一化为4位数字

Jump to

Keyboard shortcuts

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