bot

package
v0.0.0-...-2d0da97 Latest Latest
Warning

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

Go to latest
Published: Dec 22, 2022 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const K = 0.5 // 돌파 상수

Variables

This section is empty.

Functions

This section is empty.

Types

type Account

type Account struct {
	Currency    string  `structs:"currency"`      // 기준 단위
	Balance     float64 `structs:"balance"`       // 수량
	AvgBuyPrice float64 `structs:"avg_buy_price"` // 매수 평균가
}

하나의 계정을 나타낸다. upbit.Accounts 에 대해서는 별도로 변환하지 않기 때문에 테스트용도로만 쓴다.

type Accounts

type Accounts interface {
	// contains filtered or unexported methods
}

type Bot

type Bot struct {
	*client.Client
	*client.QuotationClient
	// contains filtered or unexported fields
}

func New

func New(strategies []Strategy) *Bot

새로운 봇을 만든다. 봇에 사용할 계정과 전략을 받는다.

func (*Bot) Run

func (b *Bot) Run() error

봇을 실행한다. 다음과 같은 일이 발생한다.

1. 계좌를 조회하여 현재 가지고 있는 코인에 대해 틱과 전략를 실행한다. 2. 디텍터를 실행하여 predicate 에 부합하는 종목을 탐색하여 보고, 탐색된 종목에 대해 틱과 전략를 실행한다.

func (*Bot) SetAccounts

func (b *Bot) SetAccounts(accounts Accounts)

봇에서 사용할 계정을 설정한다.

type FakeAccounts

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

FakeAccounts 는 테스트용 계정을 나타내며, 이는 dbName 에 있는 파일에 영구적으로 저장 될 것이다. 계정 정보가 업비트 서버에 저장되어 있는 것을 시뮬레이트 하기 위함이다. 또한 FakeAccounts 는 Accounts 인터페이스를 따른다.

func NewFakeAccounts

func NewFakeAccounts(dbname string, krw float64) (*FakeAccounts, error)

NewFakeAccounts 는 새로운 FakeAccounts 를 만든다. faccDbName 에 해당하는 boltDB 를 만들고 krw 만큼의 자금을 faccAccountsBucketName 에 할당한다.

type PenetrationStrategy

type PenetrationStrategy struct{}

변동성 돌파전략이다. 상승장에 구입한다.

type Strategy

type Strategy interface {
	// contains filtered or unexported methods
}

type UpbitAccounts

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

UpbitAccounts 는 실제 업비트 계정을 의미한다. 실제로 업비트에 자금을 주문하고 조회하기 때문에 실제 테스트는 어렵다. (업비트엔 샌드박스 모드가 없다.)

func NewUpbitAccounts

func NewUpbitAccounts(b *Bot) (*UpbitAccounts, error)

NewUpbitAccounts 는 업비트로부터 실제 계정을 가져와 새로운 UpbitAccounts 를 반환한다.

Jump to

Keyboard shortcuts

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