command

package
v0.2.1 Latest Latest
Warning

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

Go to latest
Published: Oct 11, 2023 License: Apache-2.0 Imports: 19 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Application = "stock"
	MinVersion  = "0.0.1" // 版本号

)
View Source
var CmdPrint = &cmder.Command{
	Use:     "print",
	Example: Application + " print sh000001",
	Short:   "打印K线概要",

	Run: func(cmd *cmder.Command, args []string) {
		tradeDate := cache.DefaultCanReadDate()
		if len(flagDate.Value) > 0 {
			tradeDate = trading.FixTradeDate(flagDate.Value)
		}
		keywords := ""
		code := ""
		for _, m := range subModules {
			if len(m.Value) > 0 {
				keywords = m.Name
				code = m.Value
				break
			}
		}
		if len(keywords) > 0 {
			plugins := cache.PluginsWithName(cache.PluginMaskFeature, keywords)
			if len(plugins) == 0 {
				fmt.Printf("没有找到名字是[%s]的数据插件\n", keywords)
			} else {
				handlePrintData(code, tradeDate, plugins[0])
			}
		} else if len(maCode) > 0 {

		} else if len(boxCode) > 0 {

		} else {
			if len(args) != 1 {
				fmt.Println(cmd.Help())
				return
			}

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

CmdPrint 打印命令

View Source
var CmdRepair = &cmder.Command{
	Use:     "repair",
	Example: Application + " repair --all",

	Args: func(cmd *cmder.Command, args []string) error {
		return nil
	},
	Short: "修复股市数据",
	Long:  `修复股市数据`,
	Run: func(cmd *cmder.Command, args []string) {
		beginDate := trading.FixTradeDate(flagStartDate.Value)
		endDate := cache.DefaultCanReadDate()
		if len(flagEndDate.Value) > 0 {
			endDate = trading.FixTradeDate(flagEndDate.Value)
		}
		dates := trading.TradeRange(beginDate, endDate)
		count := len(dates)
		fmt.Printf("修复数据: %s => %s"+strings.Repeat("\r\n", 2), dates[0], dates[count-1])
		base.UpdateTickStartDate(dates[0])
		if flagAll.Value {
			handleRepairAll(dates)
		} else if flagBaseData.Value {
			keywords := []string{}
			if flagTrans.Value {
				keywords = append(keywords, flagTrans.Name)
			}
			if len(keywords) == 0 {
				handleRepairDataSet(dates)
			} else {
				plugins := cache.PluginsWithName(cache.PluginMaskBaseData, keywords...)
				if len(plugins) == 0 {
					fmt.Printf("没有找到名字是[%s]的数据插件\n", strings.Join(keywords, ","))
				} else {
					handleRepairData(dates, plugins)
				}
			}
		} else if flagFeatures.Value {
			handleRepairFeatures(dates)
		}
	},
}

CmdRepair 补登历史数据

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

	Args: func(cmd *cmder.Command, args []string) error {
		return nil
	},
	Short: "更新股市数据",
	Long:  `更新股市数据`,
	Run: func(cmd *cmder.Command, args []string) {
		fmt.Println()
		currentDate := cache.DefaultCanUpdateDate()
		cacheDate, featureDate := cache.CorrectDate(currentDate)
		if flagAll.Value {

			handleUpdateAll(cacheDate, featureDate)
		} else if flagBaseData.Value {
			handleUpdateBaseData(cacheDate, featureDate)
		} else if flagFeatures.Value {
			handleUpdateFeatures(cacheDate, featureDate)
		}
	},
}

CmdUpdate 更新数据

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

CmdVersion CommandVersion 版本

Functions

func UpdateApplicationVersion added in v0.1.5

func UpdateApplicationVersion(v string)

UpdateApplicationVersion 更新版本号

Types

type Command added in v0.1.3

type Command = cmder.Command

Jump to

Keyboard shortcuts

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