v0.0.0-...-38c4f6e Latest Latest

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

Go to latest
Published: Sep 2, 2019 License: MIT Imports: 29 Imported by: 0




View Source
const (
	UserAgent     = "Isutrader/0.0.1"
	TradeTypeSell = "sell"
	TradeTypeBuy  = "buy"
View Source
const (
	// Timeouts
	BenchMarkTime  = 60 * time.Second      // 負荷走行の時間
	TickerInterval = 20 * time.Millisecond // tickerのinterval

	InitTimeout   = 30 * time.Second       // Initialize のタイムアウト
	ClientTimeout = 15 * time.Second       // HTTP clientのタイムアウト
	RetireTimeout = 10 * time.Second       // clientが退役するタイムアウト時間
	RetryInterval = 500 * time.Millisecond // 50x系でエラーになったときのretry間隔

	TestTradeTimeout = 5 * time.Second  // testでのtradeは成立までの時間
	LogAllowedDelay  = 10 * time.Second // logの遅延が許される時間

	PollingInterval     = 1000 * time.Millisecond // clientのポーリング感覚
	OrderUpdateInterval = 1500 * time.Millisecond // 注文間隔
	BruteForceDelay     = 500 * time.Millisecond  // 総当たりログイン試行間隔

	AddUsersOnShare   = 3  // SNSシェアによって増えるユーザー数
	AddUsersOnNatural = 2  // 自然増で増えるユーザー数
	DefaultWorkers    = 10 // 初期
	BruteForceWorkers = 2  // ログインを試行してくるユーザー

	// Scores
	SignupScore       = 3
	SigninScore       = 3
	GetTradesScore    = 1
	PostOrdersScore   = 5
	GetOrdersScore    = 1
	DeleteOrdersScore = 5
	TradeSuccessScore = 10
	GetInfoScore      = 1
	GetTopScore       = 1

	// error
	AllowErrorMin = 20 // levelによらずここまでは許容範囲というエラー数
	AllowErrorMax = 50 // levelによらずこれ以上は許さないというエラー数


View Source
var (
	ErrAlreadyRetired = errors.New("already retired client")
View Source
var StaticFiles = []*StaticFile{
	&StaticFile{"/", 886, "3a571469b58349f869846a51327e7cff"},
	&StaticFile{"/css/app.033eaee3.css", 11992, "7bf63f337dc2e96d62aefa4c7c482732"},
	&StaticFile{"/favicon.ico", 894, "74ba79ca3f41bb01fe12454f4f13bd96"},
	&StaticFile{"/img/isucoin_logo.png", 8988, "549012f31fcf8a328bedf6b8cab2b1af"},
	&StaticFile{"/js/Chart.Financial.js", 14403, "765490c323c5073857bf15309133edee"},
	&StaticFile{"/js/Chart.min.js", 159638, "f6c8efa65711e0cbbc99ba72997ecd0e"},
	&StaticFile{"/js/app.2be81752.js", 19425, "ece197c60a70f36b87d2a390428095b9"},
	&StaticFile{"/js/chunk-vendors.3f054da5.js", 139427, "d004b96351883062178f479d06dd376a"},
	&StaticFile{"/js/moment.min.js", 51679, "8999b8b5d07e9c6077ac5ac6bc942968"},


func NewLogger

func NewLogger(out io.Writer) *log.Logger


type CandlestickData

type CandlestickData struct {
	Time  time.Time `json:"time"`
	Open  int64     `json:"open"`
	Close int64     `json:"close"`
	High  int64     `json:"high"`
	Low   int64     `json:"low"`

type Client

type Client struct {
	// contains filtered or unexported fields

func NewClient

func NewClient(base, bankid, name, password string, timeout, retire time.Duration) (*Client, error)

func (*Client) AddOrder

func (c *Client) AddOrder(ctx context.Context, ordertype string, amount, price int64) (*Order, error)

func (*Client) DeleteOrders

func (c *Client) DeleteOrders(ctx context.Context, id int64) error

func (*Client) GetOrders

func (c *Client) GetOrders(ctx context.Context) ([]Order, error)

func (*Client) Info

func (c *Client) Info(ctx context.Context, cursor int64) (*InfoResponse, error)

func (*Client) Initialize

func (c *Client) Initialize(ctx context.Context, bankep, bankid, logep, logid string) error

func (*Client) IsRetired

func (c *Client) IsRetired() bool

func (*Client) Signin

func (c *Client) Signin(ctx context.Context) error

func (*Client) Signout

func (c *Client) Signout(ctx context.Context) error

func (*Client) Signup

func (c *Client) Signup(ctx context.Context) error

func (*Client) Top

func (c *Client) Top(ctx context.Context) error

func (*Client) UserID

func (c *Client) UserID() int64

type ErrElapsedTimeOverRetire

type ErrElapsedTimeOverRetire struct {
	// contains filtered or unexported fields

func (*ErrElapsedTimeOverRetire) Error

func (e *ErrElapsedTimeOverRetire) Error() string

type ErrorWithStatus

type ErrorWithStatus struct {
	StatusCode int
	Body       string
	// contains filtered or unexported fields

func (*ErrorWithStatus) Error

func (e *ErrorWithStatus) Error() string

type FinalState

type FinalState struct {
	BaseURL string
	BankID  string
	Name    string
	Pass    string
	Orders  []Order
	Info    *InfoResponse

func (*FinalState) Check

func (s *FinalState) Check(ctx context.Context) error

type InfoResponse

type InfoResponse struct {
	Cursor          int64             `json:"cursor"`
	TradedOrders    []Order           `json:"traded_orders"`
	LowestSellPrice int64             `json:"lowest_sell_price"`
	HighestBuyPrice int64             `json:"highest_buy_price"`
	ChartBySec      []CandlestickData `json:"chart_by_sec"`
	ChartByMin      []CandlestickData `json:"chart_by_min"`
	ChartByHour     []CandlestickData `json:"chart_by_hour"`
	EnableShare     bool              `json:"enable_share"`

type Manager

type Manager struct {
	// contains filtered or unexported fields

func NewManager

func NewManager(out io.Writer, appep, bankep, logep, internalbank, internallog string, statefile string) (*Manager, error)

func (*Manager) ActiveUsers

func (c *Manager) ActiveUsers() int

func (*Manager) AddScore

func (c *Manager) AddScore(score int64)

func (*Manager) AllUsers

func (c *Manager) AllUsers() int

func (*Manager) AppendError

func (c *Manager) AppendError(e error) error

func (*Manager) Close

func (c *Manager) Close()

func (*Manager) ErrorCount

func (c *Manager) ErrorCount() int

func (*Manager) FetchNewID

func (c *Manager) FetchNewID() string

func (*Manager) FinalScore

func (c *Manager) FinalScore() int64

func (*Manager) GetErrorsString

func (c *Manager) GetErrorsString() []string

func (*Manager) GetLevel

func (c *Manager) GetLevel() uint

func (*Manager) GetLogs

func (c *Manager) GetLogs() ([]string, error)

func (*Manager) GetScore

func (c *Manager) GetScore() int64

func (*Manager) Initialize

func (c *Manager) Initialize(ctx context.Context) error

func (*Manager) Logger

func (c *Manager) Logger() *log.Logger

func (*Manager) PostTest

func (c *Manager) PostTest(ctx context.Context) error

func (*Manager) PreTest

func (c *Manager) PreTest(ctx context.Context) error

func (*Manager) RunIDFetcher

func (c *Manager) RunIDFetcher(ctx context.Context)


func (*Manager) ScenarioStart

func (c *Manager) ScenarioStart(ctx context.Context) error

func (*Manager) TotalScore

func (c *Manager) TotalScore() int64

type Order

type Order struct {
	ID        int64      `json:"id"`
	Type      string     `json:"type"`
	UserID    int64      `json:"user_id"`
	Amount    int64      `json:"amount"`
	Price     int64      `json:"price"`
	ClosedAt  *time.Time `json:"closed_at"`
	TradeID   int64      `json:"trade_id,omitempty"`
	CreatedAt time.Time  `json:"created_at"`
	User      *User      `json:"user,omitempty"`
	Trade     *Trade     `json:"trade,omitempty"`

func (*Order) Removed

func (o *Order) Removed() bool

type OrderActionResponse

type OrderActionResponse struct {
	ID int64 `json:"id"`

type PostTester

type PostTester struct {
	// contains filtered or unexported fields

func (*PostTester) Run

func (t *PostTester) Run(ctx context.Context) error

type PreTester

type PreTester struct {
	// contains filtered or unexported fields

func (*PreTester) Run

func (t *PreTester) Run(ctx context.Context) error

type Random

type Random struct {
	// contains filtered or unexported fields

func NewRandom

func NewRandom() (*Random, error)

func (*Random) ID

func (b *Random) ID() string

func (*Random) Name

func (b *Random) Name() string

func (*Random) Password

func (b *Random) Password() string

type ResponseWithElapsedTime

type ResponseWithElapsedTime struct {
	ElapsedTime time.Duration
	Hash        string

type Runner

type Runner struct {
	// contains filtered or unexported fields

func NewRunner

func NewRunner(mgr *Manager) *Runner

func (*Runner) Result

func (r *Runner) Result() portal.BenchResult

func (*Runner) Run

func (r *Runner) Run(ctx context.Context) error

type Scenario

type Scenario interface {
	Start(context.Context, chan ScoreMsg) error
	IsSignin() bool
	IsRetired() bool
	BankID() string
	Credit() int64

func NewBruteForceScenario

func NewBruteForceScenario(c *Client) Scenario

func NewExistsUserScenario

func NewExistsUserScenario(c *Client, credit, isu, unit int64, justprice bool) Scenario

func NewNormalScenario

func NewNormalScenario(c *Client, credit, isu, unit int64, justprice bool) Scenario

type ScoreBoard

type ScoreBoard struct {
	// contains filtered or unexported fields

func (*ScoreBoard) Add

func (sb *ScoreBoard) Add(p ScoreType)

func (*ScoreBoard) Dump

func (sb *ScoreBoard) Dump()

type ScoreMsg

type ScoreMsg struct {
	// contains filtered or unexported fields

type ScoreType

type ScoreType int
const (
	ScoreTypeGetTop ScoreType = 1 + iota

func (ScoreType) Score

func (st ScoreType) Score() int64

func (ScoreType) String

func (st ScoreType) String() string

type StaticFile

type StaticFile struct {
	Path string
	Size int64
	Hash string

type StatusRes

type StatusRes struct {
	OK    bool   `jon:"ok"`
	Error string `jon:"error,omitempty"`

type TestUser

type TestUser struct {
	BankID string
	Name   string
	Pass   string
	Cost   int
	Orders int
	Traded int

type Trade

type Trade struct {
	ID        int64     `json:"id"`
	Amount    int64     `json:"amount"`
	Price     int64     `json:"price"`
	CreatedAt time.Time `json:"created_at"`

type User

type User struct {
	ID        int64     `json:"id"`
	Name      string    `json:"name"`
	BankID    string    `json:"-"`
	CreatedAt time.Time `json:"-"`

Jump to

Keyboard shortcuts

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