text stringlengths 24 1.04M | metadata stringlengths 233 497 |
|---|---|
### File: server/pkg/config/jwt.go
package config
import "mayfly-go/pkg/utils/assert"
type Jwt struct {
Key string `yaml:"key"`
ExpireTime uint64 `yaml:"expire-time"` // 过期时间,单位分钟
}
func (j *Jwt) Valid() {
assert.IsTrue(j.ExpireTime != 0, "config.yml之 [jwt.expire-time] 不能为空")
}
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/config/jwt.go", "license": "apache-2.0", "size": 285} |
### File: server/pkg/config/log.go
package config
import "path"
type Log struct {
Level string `yaml:"level"`
File *LogFile `yaml:"file"`
}
type LogFile struct {
Name string `yaml:"name"`
Path string `yaml:"path"`
}
// 获取完整路径文件名
func (l *LogFile) GetFilename() string {
var filepath, filename string
if fp :... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/config/log.go", "license": "apache-2.0", "size": 497} |
### File: server/pkg/config/mysql.go
package config
type Mysql struct {
Host string `mapstructure:"path" json:"host" yaml:"host"`
Config string `mapstructure:"config" json:"config" yaml:"config"`
Dbname string `mapstructure:"db-name" json:"dbname" yaml:"db-name"`
Username string `mapstructu... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/config/mysql.go", "license": "apache-2.0", "size": 880} |
### File: server/pkg/config/redis.go
package config
type Redis struct {
Host string `yaml:"host"`
Port int `yaml:"port"`
Password string `yaml:"password"`
Db int `yaml:"db"`
}
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/config/redis.go", "license": "apache-2.0", "size": 164} |
### File: server/pkg/config/server.go
package config
import "fmt"
type Server struct {
Port int `yaml:"port"`
Model string `yaml:"model"`
Cors bool `yaml:"cors"`
Tls *Tls `yaml:"tls"`
Static *[]*Static `yaml:"static"`
StaticFile *[]*StaticFi... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/config/server.go", "license": "apache-2.0", "size": 788} |
### File: server/pkg/ctx/log_handler.go
package ctx
import (
"encoding/json"
"fmt"
"mayfly-go/pkg/biz"
"mayfly-go/pkg/logger"
"mayfly-go/pkg/utils"
"reflect"
"runtime/debug"
"github.com/sirupsen/logrus"
)
type SaveLogFunc func(*ReqCtx)
var saveLog SaveLogFunc
// 设置保存日志处理函数
func SetSaveLogFunc(sl SaveLogFun... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/ctx/log_handler.go", "license": "apache-2.0", "size": 2455} |
### File: server/pkg/ctx/permission_handler.go
package ctx
import (
"fmt"
"mayfly-go/pkg/biz"
"mayfly-go/pkg/cache"
"mayfly-go/pkg/config"
"time"
)
type Permission struct {
NeedToken bool // 是否需要token
Code string // 权限code
}
func NewPermission(code string) *Permission {
return &Permission{NeedToken: t... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/ctx/permission_handler.go", "license": "apache-2.0", "size": 2824} |
### File: server/pkg/ctx/req_ctx.go
package ctx
import (
"io"
"mayfly-go/pkg/ginx"
"mayfly-go/pkg/model"
"mayfly-go/pkg/utils/assert"
"time"
"github.com/gin-gonic/gin"
)
// 处理函数
type HandlerFunc func(*ReqCtx)
type ReqCtx struct {
GinCtx *gin.Context // gin context
RequiredPermission *Permission // ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/ctx/req_ctx.go", "license": "apache-2.0", "size": 2990} |
### File: server/pkg/ctx/token.go
package ctx
import (
"errors"
"mayfly-go/pkg/biz"
"mayfly-go/pkg/config"
"mayfly-go/pkg/global"
"mayfly-go/pkg/model"
"mayfly-go/pkg/utils"
"time"
"github.com/golang-jwt/jwt/v4"
)
var (
JwtKey = config.Conf.Jwt.Key
ExpTime = config.Conf.Jwt.ExpireTime
)
// 创建用户token
fun... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/ctx/token.go", "license": "apache-2.0", "size": 1507} |
### File: server/pkg/ginx/ginx.go
package ginx
import (
"io"
"mayfly-go/pkg/biz"
"mayfly-go/pkg/global"
"mayfly-go/pkg/model"
"net/http"
"strconv"
"github.com/gin-gonic/gin"
)
// 绑定并校验请求结构体参数
func BindJsonAndValid(g *gin.Context, data interface{}) {
if err := g.ShouldBindJSON(data); err != nil {
panic(biz.... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/ginx/ginx.go", "license": "apache-2.0", "size": 1830} |
### File: server/pkg/global/global.go
package global
import (
"github.com/go-redis/redis/v8"
"github.com/sirupsen/logrus"
"gorm.io/gorm"
)
var (
Log *logrus.Logger // 日志
Db *gorm.DB // gorm
RedisCli *redis.Client // redis
)
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/global/global.go", "license": "apache-2.0", "size": 216} |
### File: server/pkg/httpclient/httpclient.go
package httpclient
import (
"bytes"
"encoding/json"
"errors"
"fmt"
"io"
"io/ioutil"
"mime/multipart"
"net/http"
"os"
"time"
)
var client = &http.Client{}
// 默认超时
const DefTimeout = 60
type RequestWrapper struct {
url string
method string
timeout int
b... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/httpclient/httpclient.go", "license": "apache-2.0", "size": 5226} |
### File: server/pkg/logger/logger.go
package logger
import (
"fmt"
"mayfly-go/pkg/config"
"mayfly-go/pkg/global"
"os"
"strings"
"time"
"github.com/sirupsen/logrus"
)
var Log = logrus.New()
func init() {
Log.SetFormatter(new(LogFormatter))
Log.SetReportCaller(true)
logConf := config.Conf.Log
// 如果不存在日志配... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/logger/logger.go", "license": "apache-2.0", "size": 1583} |
### File: server/pkg/middleware/cors.go
package middleware
import (
"net/http"
"github.com/gin-gonic/gin"
)
// 处理跨域请求,支持options访问
func Cors() gin.HandlerFunc {
return func(c *gin.Context) {
method := c.Request.Method
c.Header("Access-Control-Allow-Origin", "*")
c.Header("Access-Control-Allow-Methods", "POS... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/middleware/cors.go", "license": "apache-2.0", "size": 749} |
### File: server/pkg/model/login_account.go
package model
type AppContext struct {
}
type LoginAccount struct {
Id uint64
Username string
}
type Permission struct {
CheckToken bool // 是否检查token
Code string // 权限码
Name string // 描述
}
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/model/login_account.go", "license": "apache-2.0", "size": 235} |
### File: server/pkg/model/model.go
package model
import (
"fmt"
"mayfly-go/pkg/biz"
"mayfly-go/pkg/global"
"strconv"
"strings"
"time"
"gorm.io/gorm"
)
type Model struct {
Id uint64 `json:"id"`
CreateTime *time.Time `json:"createTime"`
CreatorId uint64 `json:"creatorId"`
Creator strin... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/model/model.go", "license": "apache-2.0", "size": 5898} |
### File: server/pkg/model/page.go
package model
// 分页参数
type PageParam struct {
PageNum int `json:"pageNum"`
PageSize int `json:"pageSize"`
}
// 分页结果
type PageResult struct {
Total int64 `json:"total"`
List interface{} `json:"list"`
}
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/model/page.go", "license": "apache-2.0", "size": 231} |
### File: server/pkg/model/result.go
package model
import (
"encoding/json"
"fmt"
"mayfly-go/pkg/biz"
)
const (
SuccessCode = 200
SuccessMsg = "success"
)
// 统一返回结果结构体
type Result struct {
Code int16 `json:"code"`
Msg string `json:"msg"`
Data interface{} `json:"data"`
}
// 将Result转为json字符串
func... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/model/result.go", "license": "apache-2.0", "size": 1254} |
### File: server/pkg/rediscli/rediscli.go
package rediscli
import (
"context"
"fmt"
"time"
"github.com/go-redis/redis/v8"
)
var cli *redis.Client
func SetCli(client *redis.Client) {
cli = client
}
func GetCli() *redis.Client {
return cli
}
// get key value
func Get(key string) string {
val, err := cli.Get(... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/rediscli/rediscli.go", "license": "apache-2.0", "size": 1220} |
### File: server/pkg/scheduler/scheduler.go
package scheduler
import (
"mayfly-go/pkg/biz"
"github.com/robfig/cron/v3"
)
func init() {
Start()
}
var cronService = cron.New()
func Start() {
cronService.Start()
}
func Stop() {
cronService.Stop()
}
func Remove(id cron.EntryID) {
cronService.Remove(id)
}
func... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/scheduler/scheduler.go", "license": "apache-2.0", "size": 513} |
### File: server/pkg/starter/banner.go
package starter
import (
"mayfly-go/pkg/global"
)
func PrintBanner() {
global.Log.Print(`
__ _
_ __ ___ __ _ _ _ / _| |_ _ __ _ ___
| '_ ' _ \ / _' | | | | |_| | | | |_____ / _' |/ _ \
| | | | | | (_| | |_|... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/starter/banner.go", "license": "apache-2.0", "size": 429} |
### File: server/pkg/starter/gorm.go
package starter
import (
"mayfly-go/pkg/config"
"mayfly-go/pkg/global"
"gorm.io/driver/mysql"
"gorm.io/gorm"
"gorm.io/gorm/logger"
"gorm.io/gorm/schema"
)
func InitDb() {
global.Db = GormMysql()
}
func GormMysql() *gorm.DB {
m := config.Conf.Mysql
if m == nil || m.Dbnam... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/starter/gorm.go", "license": "apache-2.0", "size": 1474} |
### File: server/pkg/starter/redis.go
package starter
import (
"context"
"fmt"
"mayfly-go/pkg/config"
"mayfly-go/pkg/global"
"github.com/go-redis/redis/v8"
)
func InitRedis() {
global.RedisCli = ConnRedis()
}
func ConnRedis() *redis.Client {
// 设置redis客户端
redisConf := config.Conf.Redis
if redisConf == nil ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/starter/redis.go", "license": "apache-2.0", "size": 829} |
### File: server/pkg/starter/web-server.go
package starter
import (
"mayfly-go/initialize"
"mayfly-go/pkg/biz"
"mayfly-go/pkg/config"
"mayfly-go/pkg/ctx"
"mayfly-go/pkg/global"
)
func RunWebServer() {
// 权限处理器
ctx.UseBeforeHandlerInterceptor(ctx.PermissionHandler)
// 日志处理器
ctx.UseAfterHandlerInterceptor(ctx.... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/starter/web-server.go", "license": "apache-2.0", "size": 911} |
### File: server/pkg/utils/array_utils.go
package utils
// 数组比较
// 依次返回,新增值,删除值,以及不变值
func ArrayCompare(newArr []interface{}, oldArr []interface{}, compareFun func(interface{}, interface{}) bool) ([]interface{}, []interface{}, []interface{}) {
var unmodifierValue []interface{}
ni, oi := 0, 0
for {
if ni >= len(ne... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/utils/array_utils.go", "license": "apache-2.0", "size": 772} |
### File: server/pkg/utils/assert/assert.go
package assert
import "fmt"
// 断言条件为真,不满足的panic
func IsTrue(condition bool, panicMsg string, params ...interface{}) {
if !condition {
if len(params) != 0 {
panic(fmt.Sprintf(panicMsg, params...))
}
panic(panicMsg)
}
}
func State(condition bool, panicMsg string, ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/utils/assert/assert.go", "license": "apache-2.0", "size": 476} |
### File: server/pkg/utils/crypto_utils.go
package utils
import (
"bytes"
"crypto/aes"
"crypto/cipher"
"crypto/md5"
"crypto/rand"
"crypto/rsa"
"crypto/x509"
"encoding/base64"
"encoding/hex"
"encoding/pem"
"errors"
"golang.org/x/crypto/bcrypt"
)
// md5
func Md5(str string) string {
h := md5.New()
h.Writ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/utils/crypto_utils.go", "license": "apache-2.0", "size": 5740} |
### File: server/pkg/utils/json_utils.go
package utils
import (
"encoding/json"
)
func Json2Map(jsonStr string) map[string]interface{} {
var res map[string]interface{}
if jsonStr == "" {
return res
}
_ = json.Unmarshal([]byte(jsonStr), &res)
return res
}
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/utils/json_utils.go", "license": "apache-2.0", "size": 224} |
### File: server/pkg/utils/map_utils.go
package utils
import (
"reflect"
"strconv"
)
func GetString4Map(m map[string]interface{}, key string) string {
return m[key].(string)
}
func GetInt4Map(m map[string]interface{}, key string) int {
i := m[key]
iKind := reflect.TypeOf(i).Kind()
if iKind == reflect.Int {
r... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/utils/map_utils.go", "license": "apache-2.0", "size": 790} |
### File: server/pkg/utils/net.go
package utils
import "net"
// GetAvailablePort 获取可用端口
func GetAvailablePort() (int, error) {
addr, err := net.ResolveTCPAddr("tcp", "localhost:0")
if err != nil {
return 0, err
}
l, err := net.ListenTCP("tcp", addr)
if err != nil {
return 0, err
}
defer func(l *net.TCPLi... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/utils/net.go", "license": "apache-2.0", "size": 374} |
### File: server/pkg/utils/rand.go
package utils
import (
"math/rand"
"time"
)
const randChar = "0123456789abcdefghigklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ"
// 生成随机字符串
func RandString(l int) string {
strList := []byte(randChar)
result := []byte{}
i := 0
r := rand.New(rand.NewSource(time.Now().UnixNano())... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/utils/rand.go", "license": "apache-2.0", "size": 444} |
### File: server/pkg/utils/ssh_conn_wrap.go
package utils
import (
"net"
"time"
)
type WrapSshConn struct {
Conn net.Conn
}
func (c *WrapSshConn) Read(b []byte) (n int, err error) {
return c.Conn.Read(b)
}
func (c *WrapSshConn) Write(b []byte) (n int, err error) {
return c.Conn.Write(b)
}
func (c *WrapSshConn)... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/utils/ssh_conn_wrap.go", "license": "apache-2.0", "size": 702} |
### File: server/pkg/utils/stack_trace_utils.go
package utils
import "runtime"
// 获取调用堆栈信息
func GetStackTrace() string {
var buf [2 << 10]byte
return string(buf[:runtime.Stack(buf[:], false)])
}
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/utils/stack_trace_utils.go", "license": "apache-2.0", "size": 167} |
### File: server/pkg/utils/str_utils.go
package utils
import (
"bytes"
"encoding/json"
"strconv"
"strings"
"text/template"
)
// 可判断中文
func StrLen(str string) int {
return len([]rune(str))
}
// 去除字符串左右空字符
func StrTrim(str string) string {
return strings.Trim(str, " ")
}
func SubString(str string, begin, end i... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/utils/str_utils.go", "license": "apache-2.0", "size": 3284} |
### File: server/pkg/utils/struct_utils.go
package utils
import (
"database/sql"
"encoding/json"
"errors"
"fmt"
"reflect"
"strconv"
"strings"
)
// Copy copy things,引用至copier
func Copy(toValue interface{}, fromValue interface{}) (err error) {
var (
isSlice bool
amount = 1
from = Indirect(reflect.Valu... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/utils/struct_utils.go", "license": "apache-2.0", "size": 16255} |
### File: server/pkg/utils/template.go
package utils
import (
"bytes"
"text/template"
)
func parse(t *template.Template, vars interface{}) string {
var tmplBytes bytes.Buffer
err := t.Execute(&tmplBytes, vars)
if err != nil {
panic(err)
}
return tmplBytes.String()
}
// 模板字符串解析
// @param str 模板字符串
// @param... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/utils/template.go", "license": "apache-2.0", "size": 490} |
### File: server/pkg/utils/tree_utils.go
package utils
// ConvertToINodeArray 其他的结构体想要生成菜单树,直接实现这个接口
type INode interface {
// GetId获取id
GetId() int
// GetPid 获取父id
GetPid() int
// IsRoot 判断当前节点是否是顶层根节点
IsRoot() bool
SetChildren(childern interface{})
}
type INodes []INode
func (nodes INodes) Len() int {
ret... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/utils/tree_utils.go", "license": "apache-2.0", "size": 1646} |
### File: server/pkg/utils/yml.go
package utils
import (
"errors"
"io/ioutil"
"gopkg.in/yaml.v3"
)
// 从指定路径加载yaml文件
func LoadYml(path string, out interface{}) error {
yamlFileBytes, readErr := ioutil.ReadFile(path)
if readErr != nil {
return readErr
}
// yaml解析
err := yaml.Unmarshal(yamlFileBytes, out)
if... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/utils/yml.go", "license": "apache-2.0", "size": 533} |
### File: server/pkg/ws/msg.go
package ws
const SuccessMsgType = 1
const ErrorMsgType = 0
const InfoMsgType = 2
// websocket消息
type Msg struct {
Type int `json:"type"` // 消息类型
Title string `json:"title"` // 消息标题
Msg string `json:"msg"` // 消息内容
}
// 普通消息
func NewMsg(title, msg string) *Msg {
return &Msg{... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/ws/msg.go", "license": "apache-2.0", "size": 604} |
### File: server/pkg/ws/ws.go
package ws
import (
"encoding/json"
"mayfly-go/pkg/global"
"net/http"
"time"
"github.com/gorilla/websocket"
)
var Upgrader = websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024 * 1024 * 10,
CheckOrigin: func(r *http.Request) bool {
return true
},
}
var conns = m... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Go", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/pkg/ws/ws.go", "license": "apache-2.0", "size": 1394} |
### File: server/shutdown.sh
#bin/bash
pid=`ps ax | grep -i 'mayfly-go' | grep -v grep | awk '{print $1}'`
if [ -z "${pid}" ] ; then
echo "No mayfly-go running."
exit -1;
fi
echo "The mayfly-go(${pid}) is running..."
kill ${pid}
echo "Send shutdown request to mayfly-go(${pid}) OK" | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Shell", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/shutdown.sh", "license": "apache-2.0", "size": 272} |
### File: server/startup.sh
#bin/bash
execfile=./mayfly-go
pid=`ps ax | grep -i 'mayfly-go' | grep -v grep | awk '{print $1}'`
if [ ! -z "${pid}" ] ; then
echo "The mayfly-go already running, shutdown and restart..."
kill ${pid}
fi
if [ ! -x "${execfile}" ]; then
sudo chmod +x "${execfile}"
fi
noh... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Shell", "repo_name": "vincentLiu1992/mayfly-go", "path": "server/startup.sh", "license": "apache-2.0", "size": 343} |
### File: docs/Makefile
# Makefile for Sphinx documentation
#
# You can set these variables from the command line.
PYTHON = python
SPHINXOPTS =
SPHINXBUILD = sphinx-build
PAPER =
BUILDDIR = build
# Internal variables.
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Makefile", "repo_name": "vincentliu168/rqalpha", "path": "docs/Makefile", "license": "apache-2.0", "size": 6880} |
### File: docs/make.bat
@ECHO OFF
REM Command file for Sphinx documentation
if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set BUILDDIR=build
set ALLSPHINXOPTS=-d %BUILDDIR%/doctrees %SPHINXOPTS% source
set I18NSPHINXOPTS=%SPHINXOPTS% source
if NOT "%PAPER%" == "" (
set ALLSPHINXOPTS=-D latex_paper_size=... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Batchfile", "repo_name": "vincentliu168/rqalpha", "path": "docs/make.bat", "license": "apache-2.0", "size": 7462} |
### File: docs/source/_templates/layout.html
{% extends "!layout.html" %}
{% block footer %}
{{ super() }}
<script type="text/javascript">
console.log("RQAlpha Powered By RiceQuant.");
</script>
{% endblock %}
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "HTML", "repo_name": "vincentliu168/rqalpha", "path": "docs/source/_templates/layout.html", "license": "apache-2.0", "size": 170} |
### File: docs/source/notebooks/run-rqalpha-in-ipython.ipynb
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# IPython 与 RQAlpha"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## 加载 RQAlpha magic"
]
},
{
"cell_type": "code",
"execution... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Jupyter Notebook", "repo_name": "vincentliu168/rqalpha", "path": "docs/source/notebooks/run-rqalpha-in-ipython.ipynb", "license": "apache-2.0", "size": 226977} |
### File: rqalpha/__init__.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/__init__.py", "license": "apache-2.0", "size": 4572} |
### File: rqalpha/__main__.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/__main__.py", "license": "apache-2.0", "size": 13786} |
### File: rqalpha/api/__init__.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/api/__init__.py", "license": "apache-2.0", "size": 888} |
### File: rqalpha/api/api_base.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/api/api_base.py", "license": "apache-2.0", "size": 32776} |
### File: rqalpha/api/api_extension.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/api/api_extension.py", "license": "apache-2.0", "size": 4381} |
### File: rqalpha/api/helper.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/api/helper.py", "license": "apache-2.0", "size": 847} |
### File: rqalpha/api/names.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
#... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/api/names.py", "license": "apache-2.0", "size": 2048} |
### File: rqalpha/const.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unl... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/const.py", "license": "apache-2.0", "size": 5135} |
### File: rqalpha/core/__init__.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/core/__init__.py", "license": "apache-2.0", "size": 604} |
### File: rqalpha/core/bar_dict_price_board.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/core/bar_dict_price_board.py", "license": "apache-2.0", "size": 1449} |
### File: rqalpha/core/executor.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/core/executor.py", "license": "apache-2.0", "size": 3089} |
### File: rqalpha/core/global_var.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/core/global_var.py", "license": "apache-2.0", "size": 1573} |
### File: rqalpha/core/strategy.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/core/strategy.py", "license": "apache-2.0", "size": 4185} |
### File: rqalpha/core/strategy_context.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LIC... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/core/strategy_context.py", "license": "apache-2.0", "size": 8939} |
### File: rqalpha/core/strategy_loader.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICE... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/core/strategy_loader.py", "license": "apache-2.0", "size": 1502} |
### File: rqalpha/core/strategy_universe.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LI... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/core/strategy_universe.py", "license": "apache-2.0", "size": 1974} |
### File: rqalpha/data/__init__.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/data/__init__.py", "license": "apache-2.0", "size": 604} |
### File: rqalpha/data/adjust.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/data/adjust.py", "license": "apache-2.0", "size": 2500} |
### File: rqalpha/data/base_data_source.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LIC... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/data/base_data_source.py", "license": "apache-2.0", "size": 8715} |
### File: rqalpha/data/converter.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/data/converter.py", "license": "apache-2.0", "size": 3224} |
### File: rqalpha/data/data_proxy.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/data/data_proxy.py", "license": "apache-2.0", "size": 9403} |
### File: rqalpha/data/date_set.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/data/date_set.py", "license": "apache-2.0", "size": 1626} |
### File: rqalpha/data/daybar_store.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/data/daybar_store.py", "license": "apache-2.0", "size": 2179} |
### File: rqalpha/data/dividend_store.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICEN... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/data/dividend_store.py", "license": "apache-2.0", "size": 1632} |
### File: rqalpha/data/future_info_cn.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICEN... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/data/future_info_cn.py", "license": "apache-2.0", "size": 60316} |
### File: rqalpha/data/instrument_mixin.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LIC... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/data/instrument_mixin.py", "license": "apache-2.0", "size": 2988} |
### File: rqalpha/data/instrument_store.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LIC... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/data/instrument_store.py", "license": "apache-2.0", "size": 924} |
### File: rqalpha/data/public_fund_commission.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licens... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/data/public_fund_commission.py", "license": "apache-2.0", "size": 1155} |
### File: rqalpha/data/risk_free_helper.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LIC... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/data/risk_free_helper.py", "license": "apache-2.0", "size": 1320} |
### File: rqalpha/data/simple_factor_store.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/data/simple_factor_store.py", "license": "apache-2.0", "size": 979} |
### File: rqalpha/data/trading_dates_mixin.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/data/trading_dates_mixin.py", "license": "apache-2.0", "size": 2931} |
### File: rqalpha/data/trading_dates_store.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/data/trading_dates_store.py", "license": "apache-2.0", "size": 846} |
### File: rqalpha/data/yield_curve_store.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LI... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/data/yield_curve_store.py", "license": "apache-2.0", "size": 2185} |
### File: rqalpha/environment.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/environment.py", "license": "apache-2.0", "size": 6113} |
### File: rqalpha/events.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Un... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/events.py", "license": "apache-2.0", "size": 4702} |
### File: rqalpha/examples/IF_macd.py
from rqalpha.api import *
import talib
# 在这个方法中编写任何的初始化逻辑。context对象将会在你的算法策略的任何方法之间做传递
def init(context):
# context内引入全局变量s1,存储目标合约信息
context.s1 = 'IF1606'
# 使用MACD需要设置长短均线和macd平均线的参数
context.SHORTPERIOD = 12
context.LONGPERIOD = 26
context.SMOOTHPERIOD ... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/examples/IF_macd.py", "license": "apache-2.0", "size": 1987} |
### File: rqalpha/examples/__init__.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/examples/__init__.py", "license": "apache-2.0", "size": 604} |
### File: rqalpha/examples/buy_and_hold.py
from rqalpha.api import *
# 在这个方法中编写任何的初始化逻辑。context对象将会在你的算法策略的任何方法之间做传递。
def init(context):
logger.info("init")
context.s1 = "000001.XSHE"
update_universe(context.s1)
# 是否已发送了order
context.fired = False
def before_trading(context):
pass
# 你选择的证券... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/examples/buy_and_hold.py", "license": "apache-2.0", "size": 1004} |
### File: rqalpha/examples/data_source/__init__.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/lice... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/examples/data_source/__init__.py", "license": "apache-2.0", "size": 604} |
### File: rqalpha/examples/data_source/get_csv_module.py
import os
def read_csv_as_df(csv_path):
import pandas as pd
data = pd.read_csv(csv_path)
return data
def get_csv():
csv_path = os.path.join(os.path.dirname(__file__), "../IF1706_20161108.csv")
return read_csv_as_df(csv_path)
| {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/examples/data_source/get_csv_module.py", "license": "apache-2.0", "size": 249} |
### File: rqalpha/examples/data_source/import_get_csv_module.py
from rqalpha.api import *
import os
import sys
def init(context):
strategy_file_path = context.config.base.strategy_file
sys.path.append(os.path.realpath(os.path.dirname(strategy_file_path)))
from get_csv_module import get_csv
IF1706_df... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/examples/data_source/import_get_csv_module.py", "license": "apache-2.0", "size": 688} |
### File: rqalpha/examples/data_source/read_csv_as_df.py
from rqalpha.api import *
def read_csv_as_df(csv_path):
import pandas as pd
data = pd.read_csv(csv_path)
return data
def init(context):
import os
strategy_file_path = context.config.base.strategy_file
csv_path = os.path.join(os.path.di... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/examples/data_source/read_csv_as_df.py", "license": "apache-2.0", "size": 776} |
### File: rqalpha/examples/extend_api/__init__.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licen... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/examples/extend_api/__init__.py", "license": "apache-2.0", "size": 605} |
### File: rqalpha/examples/extend_api/rqalpha_mod_extend_api_demo.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://w... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/examples/extend_api/rqalpha_mod_extend_api_demo.py", "license": "apache-2.0", "size": 1812} |
### File: rqalpha/examples/golden_cross.py
from rqalpha.api import *
import talib
# 在这个方法中编写任何的初始化逻辑。context对象将会在你的算法策略的任何方法之间做传递。
def init(context):
context.s1 = "000001.XSHE"
# 设置这个策略当中会用到的参数,在策略中可以随时调用,这个策略使用长短均线,我们在这里设定长线和短线的区间,在调试寻找最佳区间的时候只需要在这里进行数值改动
context.SHORTPERIOD = 20
context.LONGPERIOD... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/examples/golden_cross.py", "license": "apache-2.0", "size": 2165} |
### File: rqalpha/examples/macd.py
from rqalpha.api import *
import talib
# 在这个方法中编写任何的初始化逻辑。context对象将会在你的算法策略的任何方法之间做传递。
def init(context):
context.s1 = "000001.XSHE"
# 使用MACD需要设置长短均线和macd平均线的参数
context.SHORTPERIOD = 12
context.LONGPERIOD = 26
context.SMOOTHPERIOD = 9
context.OBSERVATION =... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/examples/macd.py", "license": "apache-2.0", "size": 2124} |
### File: rqalpha/examples/pair_trading.py
from rqalpha.api import *
import numpy as np
# 在这个方法中编写任何的初始化逻辑。context对象将会在你的算法策略的任何方法之间做传递。
def init(context):
context.s1 = 'AG1612'
context.s2 = 'AU1612'
# 设置全局计数器
context.counter = 0
# 设置滚动窗口
context.window = 60
# 设置对冲手数,通过研究历史数据进行价格序列回归得到... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/examples/pair_trading.py", "license": "apache-2.0", "size": 5427} |
### File: rqalpha/examples/rsi.py
from rqalpha.api import *
import talib
# 在这个方法中编写任何的初始化逻辑。context对象将会在你的算法策略的任何方法之间做传递。
def init(context):
# 选择我们感兴趣的股票
context.s1 = "000001.XSHE"
context.s2 = "601988.XSHG"
context.s3 = "000068.XSHE"
context.stocks = [context.s1, context.s2, context.s3]
co... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/examples/rsi.py", "license": "apache-2.0", "size": 2028} |
### File: rqalpha/examples/run_code_demo.py
# -*- coding: utf-8 -*-
from rqalpha import run_code
code = """
from rqalpha.api import *
def init(context):
logger.info("init")
context.s1 = "000001.XSHE"
update_universe(context.s1)
context.fired = False
def before_trading(context):
pass
def hand... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/examples/run_code_demo.py", "license": "apache-2.0", "size": 821} |
### File: rqalpha/examples/run_file_demo.py
# -*- coding: utf-8 -*-
from rqalpha import run_file
config = {
"base": {
"start_date": "2016-06-01",
"end_date": "2016-12-01",
"benchmark": "000300.XSHG",
"accounts": {
"stock": 100000
}
},
"extra": {
"log_level": "verbose",
},
"mod"... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/examples/run_file_demo.py", "license": "apache-2.0", "size": 436} |
### File: rqalpha/examples/run_func_demo.py
# -*- coding: utf-8 -*-
from rqalpha.api import *
from rqalpha import run_func
def init(context):
logger.info("init")
context.s1 = "000001.XSHE"
update_universe(context.s1)
context.fired = False
def before_trading(context):
pass
def handle_bar(conte... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/examples/run_func_demo.py", "license": "apache-2.0", "size": 1030} |
### File: rqalpha/examples/subscribe_event.py
from rqalpha.api import *
from rqalpha import subscribe_event
def on_trade_handler(event):
trade = event.trade
order = event.order
account = event.account
logger.info("*" * 10 + "Trade Handler" + "*" * 10)
logger.info(trade)
logger.info(order)
... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/examples/subscribe_event.py", "license": "apache-2.0", "size": 1658} |
### File: rqalpha/examples/technical_analysis/__init__.py
# -*- coding: utf-8 -*-
#
# Copyright 2017 Ricequant, Inc
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.o... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/examples/technical_analysis/__init__.py", "license": "apache-2.0", "size": 604} |
### File: rqalpha/examples/technical_analysis/dma.py
# Run `rqalpha mod enable sys_funcat` first.
from rqalpha.api import *
def init(context):
context.s1 = "600275.XSHG"
def handle_bar(context, bar_dict):
S(context.s1)
# 自己实现 DMA指标(Different of Moving Average)
M1 = 5
M2 = 89
M3 = 36
DDD... | {"idx": "gitee_code", "domain": "code", "domain2": "gitee-permissive", "header_footer": "", "lang": "en", "source": "gitee_code-0.jsonl", "prog_lang": "Python", "repo_name": "vincentliu168/rqalpha", "path": "rqalpha/examples/technical_analysis/dma.py", "license": "apache-2.0", "size": 695} |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.