efxmfc

package module
v0.9.11-0...-148f111 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2023 License: MIT Imports: 5 Imported by: 0

README

efxmfc-go

a go wrapper for EfxMfc
한국투자증권 eFriend Expert Host DLL을 위한 Go 패키지

Licence

Example

This is a simple request tr and realdata. (efx-console)

package main

import (
    efx "efxmfc"
    "fmt"
    "os"
    "syscall"
    "time"
)

...

func main() {
    acc_cnt := efx.GetAccountCount()
    fmt.Printf("AccountCount: %d\n", acc_cnt)
    for i := 0; i < acc_cnt; i++ {
        acnt_no := efx.GetAccount(i)
        fmt.Printf("Account[%d]: %s, %s\n", i, acnt_no, efx.GetAccountBrcode(acnt_no))
    }
    efx1 := efx.NewControl(100, OnRecvData, OnRecvRealData, OnRecvError)

    var pwd string
    fmt.Print("Enter Password: ")
    fmt.Scanln(&pwd)
    wait_time := time.Now()
    if len(pwd) == 4 {
        fmt.Printf("Encrypt: %s\n\n", efx.GetEncryptPassword(pwd))
        sync_time := efx.Synchonize(efx.REQ_LIMIT_MS)
        fmt.Printf("Synchonize() elapsed time: %v, sync time: %dms\n",
            time.Since(wait_time), sync_time)
        efx.RequestAccountBalance(efx1, efx.GetAccount(acc_cnt-1), pwd)
        wait_time = time.Now()
        wait_recv_data()
    }
    fmt.Println()

    go func() {
        stock_code := []string{"254120", "081000", "005930", "294090", "149950", "052670", "078940"}
        for _, code := range stock_code {
            sync_time := efx.Synchonize(efx.REQ_LIMIT_MS)
            fmt.Printf("Synchonize() elapsed time: %v, sync time: %dms\n",
                time.Since(wait_time), sync_time)
            efx.SetSingleData(efx1, 0, "J")
            efx.SetSingleData(efx1, 1, code)
            efx.RequestData(efx1, "SCP", code)
            wait_time = time.Now()
            wait_recv_data()
        }

        var real_code string
        for _, code := range stock_code {
            str := code + "   "
            real_code += str
        }
        efx.RequestRealData(efx1, "SC_R", real_code)
        fmt.Printf("--> RequestRealData(\"SC_R\", \"%s\")\n", real_code)
    }()

    //efx.Quit(0)
    efx.MessageLoop()
    efx.Exit()
}

walk-chart

walk-chart

Documentation

Index

Constants

View Source
const REQ_LIMIT_MS uint = 10 // 초당 조회TR 및 주문TR 제한: 20ms 간 5개 TR 이하 호출

Variables

This section is empty.

Functions

func AboutBox

func AboutBox()

func ExecCmd

func ExecCmd(cmd_arg string, wait_time uint32) string

func Exit

func Exit()

func FormatNumber

func FormatNumber(N interface{}) (string, error)

func GetAccount

func GetAccount(idx int) string

func GetAccountBrcode

func GetAccountBrcode(acnt_no string) string

func GetAccountCount

func GetAccountCount() int

func GetEncryptPassword

func GetEncryptPassword(pwd string) string

func GetMultiBlockCount

func GetMultiBlockCount(h syscall.Handle) int

func GetMultiData

func GetMultiData(h syscall.Handle, n ...int) string

func GetMultiDataFloat

func GetMultiDataFloat(h syscall.Handle, n ...int) float32

func GetMultiDataInt

func GetMultiDataInt(h syscall.Handle, n ...int) int

func GetMultiFieldCount

func GetMultiFieldCount(h syscall.Handle, block_idx int, rec_idx int) int

func GetMultiRecordCount

func GetMultiRecordCount(h syscall.Handle, block_idx int) int

func GetRecvRqID

func GetRecvRqID(h syscall.Handle) int

func GetReqMessage

func GetReqMessage(h syscall.Handle) string

func GetReqMsgCode

func GetReqMsgCode(h syscall.Handle) string

func GetRtCode

func GetRtCode(h syscall.Handle) string

func GetSendRqID

func GetSendRqID(h syscall.Handle) int

func GetSingleData

func GetSingleData(h syscall.Handle, n ...int) string

func GetSingleDataFloat

func GetSingleDataFloat(h syscall.Handle, n ...int) float32

func GetSingleDataInt

func GetSingleDataInt(h syscall.Handle, n ...int) int

func GetSingleFieldCount

func GetSingleFieldCount(h syscall.Handle) int

func Init

func Init(efx_dir string, sysmsg_cb SysMsgCallback) (err error)

func IsMoreNextData

func IsMoreNextData(h syscall.Handle) bool

func LaunchApp

func LaunchApp(file_path string, args string, waitInputIdle bool, waitTerminate bool, showFlag int32) syscall.Handle

func MessageLoop

func MessageLoop()

func NewControl

func NewControl(id uint, recv_cb EventCallback, real_cb EventCallback, error_cb EventCallback) syscall.Handle

func ProcessMessage

func ProcessMessage(millisec uint) int

func PtrToString

func PtrToString(p unsafe.Pointer, max_len int) string

func Quit

func Quit(exit_code int)

func RequestAccountBalance

func RequestAccountBalance(h syscall.Handle, account string, param ...string)

func RequestData

func RequestData(h syscall.Handle, qry_name string, param string)

func RequestNextData

func RequestNextData(h syscall.Handle, qry_name string)

func RequestRealData

func RequestRealData(h syscall.Handle, qry_name string, code string)

func SetMultiBlockData

func SetMultiBlockData(h syscall.Handle, block_idx int, rec_idx int, field_idx int, data string)

func SetMultiData

func SetMultiData(h syscall.Handle, rec_idx int, field_idx int, data string)

func SetSingleData

func SetSingleData(h syscall.Handle, field_idx int, data string)

func SetSingleDataEx

func SetSingleDataEx(h syscall.Handle, block_idx int, field_idx int, data string)

func Synchonize

func Synchonize(millisec uint) uint32

func UnrequestAllRealData

func UnrequestAllRealData(h syscall.Handle)

func UnrequestRealData

func UnrequestRealData(h syscall.Handle, qry_name string, code string)

Types

type EventCallback

type EventCallback func(syscall.Handle, uint, *string, *string)

type InvestInfo

type InvestInfo struct {
	ROE float32 // 자기자본이익률
	// contains filtered or unexported fields
}

type MarketType

type MarketType int32
const (
	KOSPI MarketType = iota
	KOSDAQ
)

type MarketWarning

type MarketWarning int32
const (
	CODE_NONE MarketWarning = iota
	CODE_CAUTION
	CODE_WARNING
	CODE_DANGER
)

type StockMasterInfo

type StockMasterInfo interface {
	SeqNo() int
	StockCode() string
	StockName() string
	MarketType() MarketType
	IsETF() bool
	IsSuspension() bool            // 거래정지
	IsClearanceSale() bool         // 정리매매
	IsManagement() bool            // 관리종목
	MarketWarnCode() MarketWarning // 시장 경고 코드
	IsMarketWarning() bool         // 경고 예고 여부
	IsInsincerityNotice() bool     // 불성실 공시 여부
	IsBackdoorListing() bool       // 우회상장 여부
	IsCreditable() bool            // 신용주문 가능
	MarginRate() int               // 증거금 비율
	ParValue() int                 // 액면가
	ListingDate() string           // 상장 날짜
	ListingCount() int64
	IsNewListing() bool
	Capital() int64
	Sales() int // 매출액
	ROE() float32
	BaseDate() string // 기준년월
	IsCreditLimtOver() bool
	IsLoanable() bool      // 담보대출가능 여부
	IsStockLoanable() bool // 대주가능 여부
}

type StockMasterItem

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

func FindStockMaster

func FindStockMaster(stock_code string) *StockMasterItem

func FindStockMasterByName

func FindStockMasterByName(stock_name string) *StockMasterItem

func GetStockMasterItem

func GetStockMasterItem(seq_no int32) *StockMasterItem

func (StockMasterItem) BaseDate

func (smi StockMasterItem) BaseDate() string

func (StockMasterItem) Capital

func (smi StockMasterItem) Capital() int64

func (StockMasterItem) IsBackdoorListing

func (smi StockMasterItem) IsBackdoorListing() bool

func (StockMasterItem) IsClearanceSale

func (smi StockMasterItem) IsClearanceSale() bool

func (StockMasterItem) IsCreditLimtOver

func (smi StockMasterItem) IsCreditLimtOver() bool

func (StockMasterItem) IsCreditable

func (smi StockMasterItem) IsCreditable() bool

func (StockMasterItem) IsETF

func (smi StockMasterItem) IsETF() bool

func (StockMasterItem) IsInsincerityNotice

func (smi StockMasterItem) IsInsincerityNotice() bool

func (StockMasterItem) IsLoanable

func (smi StockMasterItem) IsLoanable() bool

func (StockMasterItem) IsManagement

func (smi StockMasterItem) IsManagement() bool

func (StockMasterItem) IsMarketWarning

func (smi StockMasterItem) IsMarketWarning() bool

func (StockMasterItem) IsNewListing

func (smi StockMasterItem) IsNewListing() bool

func (StockMasterItem) IsStockLoanable

func (smi StockMasterItem) IsStockLoanable() bool

func (StockMasterItem) IsSuspension

func (smi StockMasterItem) IsSuspension() bool

func (StockMasterItem) ListingCount

func (smi StockMasterItem) ListingCount() int64

func (StockMasterItem) ListingDate

func (smi StockMasterItem) ListingDate() string

func (StockMasterItem) MarginRate

func (smi StockMasterItem) MarginRate() int

func (StockMasterItem) MarketType

func (smi StockMasterItem) MarketType() MarketType

func (StockMasterItem) MarketWarnCode

func (smi StockMasterItem) MarketWarnCode() MarketWarning

func (StockMasterItem) ParValue

func (smi StockMasterItem) ParValue() int

func (StockMasterItem) ROE

func (smi StockMasterItem) ROE() float32

func (StockMasterItem) Sales

func (smi StockMasterItem) Sales() int

func (StockMasterItem) SeqNo

func (smi StockMasterItem) SeqNo() int

func (StockMasterItem) StockCode

func (smi StockMasterItem) StockCode() string

func (StockMasterItem) StockName

func (smi StockMasterItem) StockName() string

type SysMsgCallback

type SysMsgCallback func(syscall.Handle, uint, int)

Directories

Path Synopsis
examples

Jump to

Keyboard shortcuts

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