E2L 使用 C++ 开发的一种策略性语言,它基于 LLVM IR 基本架构, FLEX 词汇分析器生成器 及 GNU BISON (YACC) 通用的解析器生成器 作为语法分析. 主要功能是价格的计算, 即数学的运算为主的一种简单性的编程语言
请参考 安装
E2L 在 E2Q (交易系统) 运行过程
E2L Script 运行思维图:
E2L::INIT系统初始化E2L::EAEA 运行交易策略模型.E2L::OMSOMS 系统撮合处理 (Order Limit Book).E2L::BrokerBroker 经纪商(私募)关于风险控制 .
E2L 详细底层系统 API 请参考 e2l_api.
E2L IR 状态
LLVM 的设计核心是与语言无关的中间表示 (IR),它是一种可移植的高级汇编语言 ,可以通过多次迭代进行各种转换优化 。
Frontend (Language Specific) → LLVM IR → Backend (Target Specific)
↓ ↓ ↓
Your Custom Language Optimization x86/ARM/RISC-V
Parser & AST Passes Machine Code
#--------
# Name:function
# Parameters:
# - arg1: xxx
# - arg2: xxx
# -> return
# Description:
#
#--------
func main() {
hello = 1;
return hello;
}
#----- func end
ret = main();Function return type does not match operand type of return inst!
ret void
i64Call parameter type does not match function signature!
i64* getelementptr inbounds ([43 x i64], [43 x i64]* @.str, i64 0, i64 0)
i64 %0 = call i64 (i64, ...) @printf(i64* getelementptr inbounds ([43 x i64], [43 x i64]* @.str, i64 0, i64 0), i64 %codeLine, i64 %varname, i64 %toPrint, i64 %varpath)
Function arguments must have first-class types!
void %val17008502563505747485
Function return type does not match operand type of return inst!
ret void
i64Global variable initializer type does not match global variable type!
[43 x i64]* @.str
; ModuleID = 'e2l.1804289383'
source_filename = "e2l.1804289383"
@.str = private constant [43 x i64] c"%ld [echo varname: %s line:%ld, file:%s]\0A\00"
@sfd.ssfd.sfd = internal global i64 11980000
declare i64 @printf(i64, ...)
define internal void @echo(i64 %codeLine, i64 %varname, i64 %toPrint, i64 %varpath) {
entry:
%0 = call i64 (i64, ...) @printf(i64* getelementptr inbounds ([43 x i64], [43 x i64]* @.str, i64 0, i64 0), i64 %codeLine, i64 %varname, i64 %toPrint, i64 %varpath)
ret void
}
declare i64 @last(i64)
declare void @call(i8)
declare i8 @tochar(...)
declare void @FPrintCurrentPath(void)
declare void @FVersion(...)
declare void @FGlobalUnion(...)
define internal i64 @main846930886(i64 %argc, i64 %argv) {
entry.846930886:
%ret = alloca i64, align 8
%0 = call i64 @main()
store i64 %0, i64* %ret, align 8
ret void
}
define internal i64 @main() {
main:
%hello = alloca i64, align 8
store i64 10000, i64* %hello, align 8
%hello1 = load i64, i64* %hello, align 8
ret i64 %hello1
}
初始化函数 FIsInit(); 通过返回 UInitOk 结构标识当前运行的状态.
UInitOk 两种不同的状态:
I_OK策略可以进入分析I_Proc策略初始化中
以 Uxxx 开头的结构均是系统定义的结构
union UInitOk {
I_OK = 1;
I_Proc = 0;
}e2q进程.
-p指定数据库配置文件-r当前运行的次数,可作为策略的版本参数-a在 ea 端代表当前的 EA 是第几个策略进程,默认:0-eEA 的交易策略代码
Shell 命令
user@e2q/build# ./e2q -p ../cfg/db.properties -r 0 -a 0 -e /opt/invest/ea_market.e2
- 撮合进程.
-p指定数据库配置文件-r当前运行的次数,可作为策略的版本参数-a在 撮合 端代表将会有多少个 EA 进程进入,默认:1-s撮合端代码
Shell 命令
user@e2q/build# ./e2q -p ../cfg/db.properties -r 1 -a 3 -s /opt/oms/oms_market.e2
当前的代码会在 oms_market.e2 中通过 函数 FWhois(); 返回 UOMSRisk 结构体以区分
union UOMSRisk{
# OMS 是柜台撮合中心
I_OMS = 0;
# 代理商
I_BROKER = 1;
# 策略者
I_EA = 2;
} 展示基本的案例
import <luquant/ModeMagic.e2>
#--------
# Name:functMainEvention
# Parameters:
# - arg1: tick_size
# - arg2: thread_id
# -> return
# Description:
# 测试
#--------
func MainEvent(tick_size, thread_id) {
code = EmCfiCode() ;
timeframe = EmCurrentTFrame() ;
if (tick_size > 0) {
now_time = FTime(code, timeframe, 0);
now_close = FClose(code ,timeframe , 0);
adj_close = FAdjClose(code ,timeframe , 0);
}
}- 解释 LaTeX Math
- 完善数组指令
- 类(Class Object)功能
- 接入 GUP 运算
本项目采用 BSD-3-Clause 许可证。
- 有问题或建议?请通过以下方式联系我们:
- 📧 Email: vyouzhi@gmail.com
- Telegram: @E2Quant
