command

package
v1.12.5 Latest Latest
Warning

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

Go to latest
Published: Jul 8, 2023 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Application = "stock"
	MinVersion  = "1.5.18" // 版本号
)
View Source
var (
	ProgressBarIndex                    = 1     // 进度条索引
	CpuAvx2                bool         = false // AVX2加速状态
	CpuNum                 int                  // cpu数量
	StoreSnapshotTimeBegin = "09:25:00"         // 缓存快照数据的开始时间
	StoreSnapshotTimeEnd   = "09:29:59"         // 缓存快照数据的结束时间
	SectorMinChangeRate    = 0.10               // 板块开盘最小涨幅
	SectorMinVolume        = 1e8                // 板块开盘最低成交金额
)
View Source
var CmdPrint = &cobra.Command{
	Use:     "print",
	Example: Application + " print sh000001",
	Short:   "打印K线概要",

	Run: func(cmd *cobra.Command, args []string) {
		if len(exchangeCode) > 0 {
			printExchange(exchangeCode)
		} else if len(f10Code) > 0 {
			printF10(f10Code)
		} else {
			if len(args) != 1 {
				fmt.Println(cmd.Help())
				return
			}

			securityCode := args[0]
			printKline(securityCode)
		}
	},
}

CmdPrint 打印命令

View Source
var CmdRepair = &cobra.Command{
	Use:     "repair",
	Example: Application + " repair --all",
	Short:   "修复历史数据",

	Run: func(cmd *cobra.Command, args []string) {
		if bRepairAll {
			handleRepairAll(&ProgressBarIndex)
		}
	},
}

CmdRepair 修复数据

View Source
var CmdService = &cobra.Command{
	Use:     "service",
	Example: Application + " service install | remove | start | stop | status",
	Short:   "守护进程/服务",

	Run: func(cmd *cobra.Command, args []string) {
		if len(args) > 0 {
			serviceCommand = args[0]
		}
		daemonKind := daemon.SystemDaemon
		switch runtime.GOOS {
		case "darwin":
			daemonKind = daemon.UserAgent
		}
		srv, err := daemon.New(Application, serviceDescription, daemonKind)
		if err != nil {
			fmt.Println("Error: ", err)
			os.Exit(1)
		}
		service := &Service{srv}
		replacer := strings.NewReplacer("${ROOT_PATH}", cache.GetRootPath(), "${LOG_PATH}", cache.GetLoggerPath())
		properties := replacer.Replace(propertyList)
		_ = service.SetTemplate(properties)
		status, err := service.Manage()
		if err != nil {
			fmt.Println(status, "\nError: ", err)
			os.Exit(1)
		}
		fmt.Println(status)
	},
}

CmdService 守护进程

View Source
var CmdUpdate = &cobra.Command{
	Use:     "update",
	Example: Application + " update --all",

	Args: func(cmd *cobra.Command, args []string) error {
		return nil
	},
	Short: "更新股市数据",
	Long:  `更新股市数据`,
	Run: func(cmd *cobra.Command, args []string) {

		if bUpdateAll {

			update.UpdateAllData(&ProgressBarIndex)
		} else if bUpdateF10 {

			update.UpdateF10(&ProgressBarIndex)
		} else if bUpdateXdxr {

			update.StockUpdateXdxr(&ProgressBarIndex)
		} else if bUpdateTick {

			if !tickToday && len(tickStart) == 0 {
				fmt.Println("stock update --tick, 必须携带--today或者--start")
				return
			} else {
				base.UpdateTickStartDate(tickStart)
			}
			update.UpdateHistoryTransaction(tickToday, &ProgressBarIndex)

		} else if bUpdateKLine {
			base.SetKLineOffset(klineOffset)

			if klineRealtime && klineBasic {

				update.StockUpdateRealtimeBasicKLine(&ProgressBarIndex)
			} else if klineRealtime {

				update.StockUpdateRealtimeKLine(&ProgressBarIndex)
			} else if klineBasic {

				update.StockUpdateBasicKLine(&ProgressBarIndex)
			} else if klineQfq {

				update.StockUpdateKLineWithQfq(&ProgressBarIndex)
			} else {

				update.StockUpdateWideKLine(&ProgressBarIndex)
			}
		} else if bUpdateExchange {

			update.UpdateExchange(&ProgressBarIndex)
		} else if bExchangeFundFlow {

			update.UpdateExchangeFundFlow(&ProgressBarIndex)
		} else if bExchangeExtend {

			update.UpdateExchangeKLineExtend(&ProgressBarIndex)
		} else if bExchangeNotice {

			update.UpdateExchangeNotices(&ProgressBarIndex)
		} else if bUpdateReport {

			update.UpdateFinanceReports(&ProgressBarIndex)
		} else if bUpdateSnapshot {

			update.UpdateStockSnapshot(&ProgressBarIndex)

		}
	},
}

CmdUpdate 更新数据

View Source
var CmdVersion = &cobra.Command{
	Use:   "version",
	Short: "显示版本号",
	Run: func(cmd *cobra.Command, args []string) {
		fmt.Println(MinVersion)
	},
}

CmdVersion CommandVersion 版本

Functions

func UpdateApplicationName

func UpdateApplicationName(name string)

UpdateApplicationName 更新应用(Application)名称

func UpdateApplicationVersion

func UpdateApplicationVersion(v string)

UpdateApplicationVersion 更新版本号

Types

type Service

type Service struct {
	daemon.Daemon
}

Service is the daemon service struct

func (*Service) Manage

func (service *Service) Manage() (string, error)

Manage by daemon commands or run the daemon

Jump to

Keyboard shortcuts

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