public abstract void init()
在Algorithm类中是一个抽象方法。 具体实现在Algorithm的子类完成,同时在Algorithm的子类中此方法只调用一次。在方法中可以可以设定策略的开始时间、策略周期、观察周期等。
xxxxxxxxxx
public abstract void onData()
在Algorithm类中是一个抽象方法。 具体实现在Algorithm的子类完成,在Algorithm的子类中此方法在观察周期数据加载时调用,在方法中实现策略的交易思想,进行标的的交易。
xxxxxxxxxx
public abstract void onComplete()
在Algorithm类中是一个抽象方法。 具体实现在Algorithm的子类完成,在策略运行完时调用此方法。
xxxxxxxxxx
public void setDrivingMode( mode)
设置策略运行模式。默认运行模式为DrivingMode. DATADRIVING。
参数
mode DrivingMode 默认运行模式为 DrivingMode. DATADRIVING。
xxxxxxxxxx
protected void setStartDate (int y, int M, int d)
设定策略的开始后验回测时间,这也是加截数据的开始时间,使用这个方法,允许用户自行设定策略的开始年、月、日,设定后,策略运行时依据此方法进行数据加载。
参数
Y : int类型,设定的策略开始为几几年。
M: int类型,设定的策略开始为几月。
d: int类型,设定的策略开始为几日。
xxxxxxxxxx
protected void setStartDate(int y, int M, int d, int H, int m, int s)
设定策略的开始后验回测时间,这也是加截数据的开始时间,使用这个方法,允许用户自行设定策略的开始年、月、日,小时、分钟、秒。设定后,策略运行时依据此方法进行数据加载。
参数
Y : int类型,设定的策略开始为几几年。
M: int类型,设定的策略开始为几月。
d: int类型,设定的策略开始为几日。
H: int类型,设定的策略开始具体到多少小时。
m: int类型,设定的策略开始具体到多少分钟。
s: int类型,设定的策略开始具体到多少秒。
xxxxxxxxxx
protected void setStartDate(LocalDate date)
设定策略的开始后验回测时间,这也是加截数据的开始时间。
参数
date: LocalDate 实例对象。
xxxxxxxxxx
protected void setStartDate(LocalDateTime time)
设定策略的开始后验回测时间,这也是加截数据的开始时间。
参数
time: LocalDateTime 实例对象。
xxxxxxxxxx
protected void setEndDate (int y, int M, int d)
设定策略的结束后验回测时间。使用这个方法,允许用户自行设定策略的开始年、月、日,设定后,策略运行时依据setStartDate()与setEndDate进行数据的下载。
参数
Y : int类型,设定的策略开始为几几年。
M: int类型,设定的策略开始为几月。
d: int类型,设定的策略开始为几日。
xxxxxxxxxx
protected void setEndDate(int y, int M, int d, int H, int m, int s)
设定策略的结束后验回测时间,这也是加截数据的开始时间,使用这个方法,允许用户自行设定策略的开始年、月、日,小时、分钟、秒。设定后,策略运行时依据setStartDate()与setEndDate进行数据的下载。
参数
Y : int类型,设定的策略开始为几几年。
M: int类型,设定的策略开始为几月。
d: int类型,设定的策略开始为几日。
H: int类型,设定的策略开始具体到多少小时。
m: int类型,设定的策略开始具体到多少分钟。
s: int类型,设定的策略开始具体到多少秒。
xxxxxxxxxx
protected void setEndDate(LocalDate date)
设定策略的结束后验回测时间。
参数
date: LocalDate 实例对象。
xxxxxxxxxx
protected void setEndDate(LocalDateTime time)
设定策略的结束后验回测时间。
参数
time: LocalDateTime 实例对象。
xxxxxxxxxx
protected void setBenchmark(String benchmark)
设定基准。默认399300.sz(沪深指数300)。设定时没有限制。使用时可以根据需要自行添加。
参数
benchmark String 。
xxxxxxxxxx
protected void setCash(double cash)
设定策略的初始资金。LazyPeriod模式下必须设置初始资金且不得低于100w(如果setCash设置低于100w,将自行调整为100W),其他模式没有限制,使用时可以自行设定。
参数
cash: double 设定的初始资金。
xxxxxxxxxx
void setSlippage(int slippage)
设定滑点值,默认为0.。
参数
slippage: int 滑点值。
xxxxxxxxxx
protected void increaseFee(String secuCode,double increateRate)
提高合约标的手续费率。
参数
secuCode : String 合约标的。
increateRate: double 提高的手续费率。
xxxxxxxxxx
protected void setFeeRate(String secuCode,double feeRate)
设定合约标的的手续费率。设定后,手续费的计算会按照交易金额计算进行。
参数
secuCode : String 合约标的。
increateRate: double 手续费率。
xxxxxxxxxx
protected void setFeeByVolume(String secuCode,double feeByVolume)
设定合约标的的手续费。设定后,手续费的计算会按照交易手数计算。
参数
secuCode : String 合约标的。
increateRate: double 手续费率。
xxxxxxxxxx
protected void setFee(String secuCode,double openRatio,double openRateByVolume,double closeTodayRate,double closeTodayRatioByVolume,double closeRate,double closeRateByVolume,double minimumCommission)
设定合约标的详细手续费, 在此函数中会指定开仓手续费率、平今手续费率、及平仓手续费率及最低每笔收取的手续费。
参数
secuCode: String 合约标的。
openRatio: double 开仓手续费率。
openRateByVolume: double 表示开仓时按交易量收取的单位固定手续费。
closeTodayRate: double 平今的手续费率。
closeTodayRatioByVolume: double 表示平今仓时按交易量收取的单位固定手续费。
closeRate: double 平仓手续费率。
closeRateByVolume: double 平仓时按手数收取的手续费。
minimumCommission: double 表示每笔交易时收取的最低手续费。
xxxxxxxxxx
public void setStockPoolMode(StockPoolMode mode)
获取股票池股票模式,不可单独使用,须与setDrivingMode(Period)配合使用;不设定时,默认为StockPoolMode.LIVE( 跟随股票池切换)。
参数
mode StockPoolMode 枚举 可以从选取以下几种方式:
xxxxxxxxxx
public void setAdjustMode(AdjustMode mode)
设定股票复权模式 默认为 AdjustMode.MANUAL。
参数
mode AdjustMode 枚举:
xxxxxxxxxx
protected void setRebalancing(TimeFrame resolution)
设定策略的调期周期。使用时须注意调仓周期必须设为观察周期的整数倍。同 onRebalancing 配合。
参数
resolution TimeFrame类型,表示行情(历史或者实盘)数据精度。
股票策略的TimeFrame可以为以下数值:
xxxxxxxxxx
protected void setRebalancing(TimeFrame resolution,int shift,boolean smallPeriodSplit)
设定策略的调期周期。使用时须注意调仓周期必须设为观察周期的整数倍。同 onRebalancing 配合。
参数
resolution TimeFrame类型,表示行情(历史或者实盘)数据精度。
股票策略的TimeFrame可以为以下数值:
shift int 调仓偏移量。
smallPeriodSplit boolean 是否对偏移量进行切割,当shift大于交易周期(5天)时,如果isSplit为true,则对shift取5的模(或者说与相除5,取余数)。如果isSplit为false, shift大于交易周期(5天)时, 跳过。
xxxxxxxxxx
public void setDrive(TimeFrame resolution)
设定策略的驱动周期的。
参数
resolution: TimeFrame类型,表示行情(历史或者实盘)数据精度。可以为以下数值:
xxxxxxxxxx
protected void setShift(int shift)
设定交易日偏移,默认为0即: 周期内第一个交易日,当shift 为1时。则交易日为第二个交易日,当取-1时,最后一个交易日。
参数
shift: int 偏移量。
xxxxxxxxxx
protected void setSmallPeriodSplit(boolean isSplit)
采用交易日偏移时,是否对偏移量进行切割。默认为true。进行切割,当shift大于交易周期(5天)时,如果isSplit为true,则对shift取5的模(或者说与相除5,取余数)。如果isSplit为false, shift大于交易周期(5天)时, 跳过。
参数
isSplit: boolean 默认为true。
xxxxxxxxxx
protected void setPeriodSelectStockMode (boolean select)
默认为false 。 当参数为false,表明当前策略为CTA策略,当参数为true时,策略为换仓策略,另外如果周期大于day,也是换仓策略。
参数
select boolean 值。
xxxxxxxxxx
protected <T extends QuotationSeries> T addQuotation(TimeFrame resolution, String target)
增加行情(历史或者实盘)数据引用监控,通过这个函数添加在策略运行过程中可能会用到的任意标的的任意周期的数据。
参数
resolution: TimeFrame类型,表示行情(历史或者实盘)数据精度。对于TimeFrame的取值应该为setDrive的整倍数,否则策略异常,无法执行。
TimeFrame可以为以下数值:
target: String 表示标的名称。
返回值
<T extends QuotationSeries>T QuotationSeries行情子类, 可以是BarSeries.
xxxxxxxxxx
protected void setPeriodSelectStockMode (boolean select)
默认为false 。 当参数为false,表明当前策略为CTA策略,当参数为true时,策略为换仓策略,另外如果周期大于day,也是换仓策略。
参数
select : boolean 值。
xxxxxxxxxx
protected <T extends QuotationSeries> List<T> addQuotation(TimeFrame resolution, String... targets)
增加行情(历史或者实盘)数据引用监控,通过这个函数添加在策略运行过程中可能会用到的任意标的的任意周期的数据。
参数
resolution : TimeFrame类型,表示行情(历史或者实盘)数据精度。对于TimeFrame的取值应该为setDrive的整倍数,否则策略异常,无法执行。
TimeFrame可以为以下数值:
targets: String 表示不定参数的标的名称。
返回值
xxxxxxxxxx
protected <T extends Fundamental> FundamentalSeries<T> addFundamental(Category type, String security)
添加财务数据引用。
参数
type : Category类型,可以为以下类型:
Security : String类型 股票代码。
返回值
<T extends Fundamental> FundamentalSeries<T> 单个标的的财务引用会返回一个Series类(FundamentalSeries)。
xxxxxxxxxx
protected <T extends Fundamental> List<FundamentalSeries <T> > addFundamental(Category type, String... names)
添加财务数据引用。
参数
type : Category类型,可以为以下类型:
names : String 类型,不定参数的股票代码,使用时,用逗号隔开。
返回值
<T extends Fundamental> FundamentalSeries<T> 单个标的的财务引用会返回一个Series类(FundamentalSeries)。
xxxxxxxxxx
protected BatchQuotationSeries addBatchQuotation(TimeFrame resolution,String pool)
策略运行时,将股票池注册进来,批量获取股票池成分股行情。后验时,如果设定参数股票池为全市场、上证50、沪深300、中证500及中证800,StockPoolMode. LIVE时,后验数据将采取的量邦高速缓冲数据。
参数
resolution TimeFrame类型,表示行情(历史或者实盘)数据精度。
股票策略的TimeFrame可以为以下数值:
Pool 可以取指数名称:
返回值
BatchQuotationSeries 对象。
xxxxxxxxxx
protected BatchQuotationSeries addBatchQuotation(TimeFrame resolution,String... pools)
策略运行时,将股票池注册进来,批量获取股票池成分股行情。后验时,如果设定参数股票池为全市场、上证50、沪深300、中证500及中证800,StockPoolMode. LIVE时,后验数据将采取的量邦高速缓冲数据。
参数
resolution TimeFrame类型,表示行情(历史或者实盘)数据精度。
股票策略的TimeFrame可以为以下数值:
Pool 可以取指数名称:
返回值
BatchQuotationSeries 对象。
xxxxxxxxxx
protected BatchQuotationSeries addBatchQuotation(TimeFrame resolution,List<String> targets)
策略运行时,将股票池注册进来,批量获取股票池成分股行情。后验时,如果设定参数股票池为全市场、上证50、沪深300、中证500及中证800,StockPoolMode. LIVE时,后验数据将采取的量邦高速缓冲数据。
参数
resolution TimeFrame类型,表示行情(历史或者实盘)数据精度。
股票策略的TimeFrame可以为以下数值:
targets: List<String> 由股票代码组成的List。
返回值
BatchQuotationSeries 对象。
xxxxxxxxxx
protected Map<String,Map<Category,FundamentalSeries>> registerBatchFundamental(Category... categories)
依据addBatchQuotation()方法的股票池及TimeFrame设定获取同期的财务数据。
参数
categories: Category 类型 可以以下内容:
返回值
Map<String,Map<Category,FundamentalSeries>> key 股票代码 在value ,Map<Category,FundamentalSeries> 中 key 为 Category 类型 , value为FundamentalSeries。
xxxxxxxxxx
protected Map<String,Map<Category,FundamentalSeries>> registerBatchFundamental(int shiftDays ,Category... categories)
依据addBatchQuotation()方法的股票池及TimeFrame设定获取同期的财务数据。
参数
categories: Category 类型 可以以下内容:
shiftDays: int 财务数据偏移的天数。
返回值
Map<String,Map<Category,FundamentalSeries>> key 股票代码 在value 中Map<Category,FundamentalSeries> 中 key 为 Category 类型 , value为FundamentalSeries。
xxxxxxxxxx
protected List<String> quotationSecurities()
获取该策略所有合约代码。
返回值
List 对象,存储着策略中所有合约代码
xxxxxxxxxx
protected TraderFeedback buy(String security, int volume)
多头开仓,具体价格由当前最新价计算滑点之后得到,大宽网引擎自动计算。
参数
security: String类型,代表标的代码。
volume: int类型,代表标的手数。
返回值
TraderFeedback 类型数据。
xxxxxxxxxx
protected TraderFeedback buy(String security, int volume,double price)
多头开仓。
参数
security: String类型,代表标的代码。
volume: int类型,代表标的手数。
price: double 交易价格。
返回值
TraderFeedback 类型数据。
xxxxxxxxxx
protected TraderFeedback sell(String security,double volume)
空头平仓,具体价格由当前最新价计算滑点之后得到,大宽网引擎自动计算。
参数
security: String类型,代表标的代码。
volume: int类型,代表标的手数。
返回值
TraderFeedback 类型数据。
xxxxxxxxxx
protected TraderFeedback sell(String security, int volume,double price)
空头平仓。
参数
security: String类型,代表标的代码。
volume: int类型,代表标的手数。
price: double 交易价格。
返回值
TraderFeedback 类型数据。
xxxxxxxxxx
protected TraderFeedback sellShort(String security,double volume)
空头开仓。
参数
security: String类型,代表标的代码。
volume: int类型,代表标的手数。
返回值
TraderFeedback 类型数据。
xxxxxxxxxx
protected TraderFeedback sellShort(String security,double volume,double price)
空头开仓。
参数
security: String类型,代表标的代码。
volume: int类型,代表标的手数。
price: double类型, 交易价格。
返回值
TraderFeedback 类型数据。
xxxxxxxxxx
protected TraderFeedback buyToCover(String security,double volume)
多头平仓。
参数
security: String类型,代表标的代码。
volume: int类型,代表标的手数。
返回值
TraderFeedback 类型数据。
xxxxxxxxxx
protected TraderFeedback buyToCover(String security,double volume,double price)
多头平仓。
参数
security: String类型,代表标的代码。
volume: int类型,代表标的手数。
price: double类型, 交易价格。
返回值
TraderFeedback 类型数据。
xxxxxxxxxx
protected void batchBuy(Map<String,Double> targetWeight)
按照股票清单及股票权重,批量买入股票。
参数
targetWeight Map。String, Double>, 股票清单Map对象,其中K 为股票代码, value 为股票权重。
xxxxxxxxxx
protected void batchBuy(List<String> secuCodes,double value)
按照股票清单及固定金额、对股票池进行购买。
参数
secuCodes List<String>股票代码 List 对象。
value double 固定金额。
xxxxxxxxxx
protected void batchSell(List<String> secuCodes)
按照股票清单,卖出股票。
参数
secuCodes List<String> 股票代码 List 对象。
xxxxxxxxxx
protected void lazyBatchBuy(Map<String,Double> buyingWeight, LocalDate date)
在LAZYPERIOD运行模式下,按照既定的日期设定买入股票。使用时将延迟到lazyEvaluate方法中执行。
参数
buyingWeight: Map<String, Double>, 股票清单Map对象,其中K 为股票代码, value 为股票权重。
date: LocalDate 对象,指定的调仓时间。
xxxxxxxxxx
protected void lazyBatchSell(List<String> pool, LocalDate date)
在LAZYPERIOD运行模式下,按照既定的日期设定卖出股票清单,使用时将延迟到lazyEvaluate方法中执行。
参数
pool: List<String> 股票代码 List 对象。
date: LocalDate 对象,指定的调仓时间。
xxxxxxxxxx
protected TraderFeedback buyValue(String security,double value)
对交易标的以固定金额形式买入开仓,以金额确定交易手数。 如对合约标的螺纹钢(rb1710)买入大约200,000.00元做多, 假设当前交易价格为3353.00元,可以卖入59手(200,000.00/3353.00 =59.64 取整 59手)。
参数
security: String标的名称。
value: double 预计买入金额。
返回值 TraderFeedback对象。
xxxxxxxxxx
protected TraderFeedback sellValue(String security,double value)
对交易标的以固定金额形式卖出平仓,以金额确定交易手数。 如对螺纹钢(rb1710)买出大约200,000.00元做空, 假设当前交易价格为3353.00元,可以卖出59手(200,000.00/3353.00 =59.64 取整 59手)。
参数
security: String标的名称。
value: double 预计卖出平仓金额。
返回值
TraderFeedback对象。
xxxxxxxxxx
protected TraderFeedback sellShortValue(String security,double value)
对交易标的以固定金额形式卖出开仓,以金额确定交易手数。 如对螺纹钢(rb1710)卖出大约200,000元做空, 假设当前交易价格为3353.00元,可以卖出59手(200,000.00/3353.00 =59.64 取整 59手)。
参数
security: String标的名称。
value: double 预计卖出金额。
返回值
value: TraderFeedback对象
xxxxxxxxxx
protected TraderFeedback buyToCoverValue(String security,double value)
对交易标的以固定金额形式买入平仓,以金额确定交易手数。 如对螺纹钢(rb1710)买入大约200,000元平仓, 假设当前交易价格为3353.00元,可以买入59手(200,000.00/3353.00 =59.64 取整 59手)。
参数
security: String标的名称。
value: double 预计买入平仓金额。
返回值
TraderFeedback对象。
xxxxxxxxxx
protected double open(int offset)
获取行情序列中的开盘价,适用于单标的CTA策略, 可以不用指定QuotationSeries. 直接在策略中调用如:取最新的开盘价open(0) 。
参数:
offset int类型, 用于指定偏移索引。 当offset 为0时,取当前行情的最新价, 为1时,取上个bar行情值。
返回值
double 请求行情序列的开盘价。
xxxxxxxxxx
protected double high(int offset)
获取行情序列中的最高价,适用于单标的CTA策略, 可以不用指定QuotationSeries. 直接在策略中调用如:取最新的最高价high(0) 。
参数:
offset int类型, 用于指定偏移索引。 当offset 为0时,取当前行情的最新价, 为1时,取上个bar行情值。
返回值
double 请求行情序列的最高价。
xxxxxxxxxx
protected double low(int offset)
获取行情序列中的最低价,适用于单标的CTA策略, 可以不用指定QuotationSeries. 直接在策略中调用如:取最新的最低价low(0) 。
参数:
offset int类型, 用于指定偏移索引。 当offset 为0时,取当前行情的最新价, 为1时,取上个bar行情值。
返回值 double 请求行情序列的最低价。
xxxxxxxxxx
protected double close(int offset)
获取行情序列中的收盘价,适用于单标的CTA策略, 可以不用指定QuotationSeries. 直接在策略中调用如:取最新的收盘价close(0) 。
参数:
offset int类型, 用于指定偏移索引。 当offset 为0时,取当前行情的最新价, 为1时,取上个bar行情值。
返回值
double 请求行情序列的收盘价。
xxxxxxxxxx
protected double volume(int offset)
获取行情中的成交量,适用于单标的CTA策略,策略中已经内置了行情实例 (instance), 可以不用指定QuotationSeries. 直接在策略中调用如:取最新的行情序列中的成交量volume(0)。
参数:
offset int类型, 用于指定偏移索引。 当offset 为0时,取当前行情的最新价, 为1时,取上个bar行情值。
返回值
double 请求行情序列的成交量。
xxxxxxxxxx
protected double value(int offset)
获取行情中的成交额,适用于单标的CTA策略,策略中已经内置了行情实例 (instance), 可以不用指定QuotationSeries. 直接在策略中调用如:取最新的行情序列中的成交额 value(0)。
参数:
offset int类型, 用于指定偏移索引。 当offset 为0时,取当前行情的最新价, 为1时,取上个bar行情值。
返回值
double 请求行情序列的成交额。
xxxxxxxxxx
protected double price(int offset)
获取行情中的成交价,适用于单标的CTA策略,策略中已经内置了行情实例 (instance), 可以不用指定QuotationSeries. 直接在策略中调用如:取最新的行情序列中的成交价 price(0)。
参数:
offset int类型, 用于指定偏移索引。 当offset 为0时,取当前行情的最新价, 为1时,取上个bar行情值。
返回值 double 请求行情序列的成交价。
xxxxxxxxxx
protected int getBarCount()
统计当前Bar的全局索引,从策略开始加截时,第一个策略周期l行情加载开始记录,,第一根Bar的索引值为1,第二根Bar的索引值为2。
返回值
int bar的总个数。
xxxxxxxxxx
protected int getBarCountIntra()
当前Bar在日内的索引,从当前交易日的一个根bar加截开始计算,第一根Bar的getBarCountIntra为1,第n根Bar为N, 次日归零重新计算。
返回值
返回int类型 日内bar的总个数,
xxxxxxxxxx
protected int getLastEntryBar()
记录最近一笔开仓时所在Bar的全局索引。从第一根bar 开始建立索引, 如果在第100根Bar上开仓,那调用getLastEntryBar返回 100。
返回值
int 记录最近一笔开仓时所在Bar的全局索引。
xxxxxxxxxx
protected int getLastExitBar()
记录最近一笔平仓时所在Bar的全局索引。从第一根bar 开始建立索引, 如果在第100根Bar上平仓,那调用intgetLastExitBar返回 100。
返回值
返回int类型 记录最近一笔平仓时所在Bar的全局索引。
xxxxxxxxxx
protected int getLastTradingBar()
记录最近一笔交易(可以是开仓也可以是平仓)所在Bar的全局索引。从第一根bar 开始建立索引, 如果在第100根Bar开仓,在120根Bar平仓,在[100-120) 调用getLastTradingBar返回 100 , 在[120-120+) 调用getLastTradingBar返回 120。
返回值
int 记录最近一笔交易所在Bar的全局索引。
xxxxxxxxxx
protected LocalDateTime getLastOpenTime()
获取最近一笔开仓的开仓时间,如果没有返回LocalDateTime.MIN。
返回值
LocalDateTime 最近一笔开仓的开仓时间。
xxxxxxxxxx
protected LocalDateTime getLastCloseTime()
获取最近一笔平仓交易的平仓时间,如果没有返回LocalDateTime.MIN。
返回值
LocalDateTime 最近一笔平仓的平仓时间。
xxxxxxxxxx
protected LocalDateTime getLastCloseTime()
获取策略最近一笔交易时间(包括开仓时间和平仓时间),如果没有交易返回LocalDateTime.MIN。
返回值
LocalDateTime 最近一笔交易时间时间
xxxxxxxxxx
protected LocalDateTime getLastLongOpenTime()
获取策略最近一笔多头开仓时间,如果没有返回LocalDateTime.MIN。
返回值
LocalDateTime 最近一笔多头开仓时间。
xxxxxxxxxx
protected LocalDateTime getLastShortOpenTime()
获取策略最近一笔空头开仓时间,如果没有返回LocalDateTime.MIN。
返回值
LocalDateTime 最近一笔空头开仓时间。
xxxxxxxxxx
protected LocalDateTime getLastLongCloseTime()
获取策略最近一笔多头平仓时间,如果没有返回LocalDateTime.MIN。
返回值
LocalDateTime 最近多头平仓时间。
xxxxxxxxxx
protected LocalDateTime getLastShortCloseTime()
获取策略最近一笔空头平仓时间,如果没有返回LocalDateTime.MIN。
返回值
LocalDateTime 最近空头平仓时间。
xxxxxxxxxx
protected double getLastLongOpenPrice()
获取策略最近一笔多头开仓成交价。
返回值
double 最近多头开仓成交价。
xxxxxxxxxx
protected double getLastLongClosePrice()
获取策略最近一笔多头平仓成交价。
返回值
double 最近多头平仓成交价。
xxxxxxxxxx
protected double getLastShortOpenPrice()
获取策略最近一笔空头开仓成交价。
返回值
double 最近空头开仓成交价。
xxxxxxxxxx
protected double getLastShortClosePrice()
获取策略最近一笔空头平仓成交价。
返回值
double 最近空头平仓成交价。
xxxxxxxxxx
protected double max(double a, double b)
比较两个double 数的大小,并将最大值返回。
参数:
a: double 类型。
b: double 类型 。
返回值
二数比较的最大值 。
xxxxxxxxxx
protected double max(double a, double b)
比较参数数值大小,将较小值返回。
参数:
a: double 类型。
b: double 类型 。
返回值
double 类型,二数比较的最小值 。
xxxxxxxxxx
protected void info(String format, Object... args)
在策略中设定info级别日志的输出的格式, 并将相关的数据输出。
参数:
format: String 类型。
args: Object 类型 。
xxxxxxxxxx
protected void info(Object... msg)
在策略中设定info级别日志的输出的格式, 并将相关的数据输出。
参数:
msg Object 类型。
xxxxxxxxxx
protected void warn(String format, Object... args)
在策略中设定warn级别日志的输出的格式, 并将相关的数据输出。
参数:
format: String 类型。
args: Object 类型 。
xprotected void warn(Object... msg)
在策略中设定warn级别日志的输出的格式, 并将相关的数据输出。
参数:
msg Object 类型。
xxxxxxxxxx
protected void error(String format, Object... args)
在策略中设定error级别日志的输出的格式, 并将相关的数据输出。
参数:
format: String 类型。
args: Object 类型 。
xxxxxxxxxx
protected void error(Object... msg)
在策略中设定error级别日志的输出的格式, 并将相关的数据输出。
参数:
msg Object 类型。
xxxxxxxxxx
protected LocalTime clock()
获取策略的运行时间(时、分、秒)。
返回值
LocalTime 类型。
xxxxxxxxxx
protected LocalDateTime time()
获取策略的运行时间(包括年-月-日 时:分:秒)。
返回值
LocalDateTime 类型。
xxxxxxxxxx
protected LocalDate date()
获取策略的运行时间(包括年-月-日)。
返回值
LocalDate 类型。
xxxxxxxxxx
protected void plot(String name, double value)
策略运行时,将相关的数据进行画图展示。
参数:
name String 类型 画图指标。
value double 画图的数值。
xxxxxxxxxx
protected <T extends Quotation> QuotationSeries<T> find(String s)
策略运行时,获取指定标的的行情,如果不存在将返回null。
参数:
s String 类型 行情标的。
返回值
<T extends Quotation> QuotationSeries的一个子类 如BarSeries。
xxxxxxxxxx
protected int positionStatus(String secuCode)
获取当前策略的持仓方向, 对于单标的策略而言,当返回为正整数时,表示,当前策略为多头持仓,当返回值为负整数时,表示当前策略为空头持仓。为零表示策略无持仓。
参数:
secuCode: String 表示标的名称。
返回值
当前策略的持仓状态,用于单标的策略的持仓方向判定 对于CTA策略, >0 表示多头持仓 =0 表示无持仓; <0 表示空头持仓。
xxxxxxxxxx
protected List<String> getIndustryStocks(String industry)
获取行业的成分股。
参数:
industry: String 表示行业代码, 行业代业可以是申万一级、二级代码。
返回值
List<String> 指定行业的所有股票代码。
xxxxxxxxxx
protected List<String> getIndustryStocks(String... industries)
获取行业的成分股。
参数:
industries: String 不定参数, 表示行业代码, 行业代业可以是申万一级、二级代码。
返回值
List<String>行业的所有股票代码。
xxxxxxxxxx
protected List<String> getIndustryStocks(LocalDate date, String industry)
获取行业的成分股。
参数:
date: LocalDate 指定日期。
industry: String 表示行业代码, 行业代业可以是申万一级、二级代码。
返回值
List<String>指定行业的所有股票代码。
xxxxxxxxxx
protected List<String> getIndustryStocks(LocalDate date,String... industries)
获取行业的成分股。
参数:
date: LocalDate 指定日期。
industries: String 不定参数, 表示行业代码, 行业代业可以是申万一级、二级代码。
返回值
List<String>指定行业的所有股票代码。
xxxxxxxxxx
protected List<String> getIndexStocks(String index)
获取行业指数成分股。
参数:
index: String 指数代码。
返回值
List<String>指定行业指数的所有成分股票代码。
xxxxxxxxxx
protected List<String> getIndexStocks(String ….indices)
获取行业指数成分股。
参数:
indices: String 不定参数, 使用时可以传入多个指数代码,用逗号隔开。
返回值
List<String>指定行业指数的所有成分股票代码。
xxxxxxxxxx
protected List<String> getIndexStocks(LocalDate date, String index)
获取行业指数成分股。
参数:
date: LocalDate 指定日期。
index: String 指数代码。
返回值
List<String>指定行业指数的所有成分股票代码。
xxxxxxxxxx
protected List<String> getIndexStocks(LocalDate date, String... indices)
获取指数成分股。
参数:
date: LocalDate 指定日期。
indices: String 不定参数, 使用时可以传入多个指数代码,用逗号隔开。
返回值
List<String>指定行业指数的所有成分股票代码。
xxxxxxxxxx
protected List<String> getConceptStocks(String concept)
获取概念、地域,规模及风格相关的成分股。
参数:
concept: String 概念、地域,规模或者风格代码。
返回值
List<String>指定概念、地域,规模或者风格相关的成分股。
xxxxxxxxxx
protected List<String> getConceptStocks(String ...concepts)
获取概念、地域,规模及风格相关的成分股。
参数:
concepts: String 不定参数, 使用时可以传入多个概念、地域,规模或者风格代码,用逗号隔开。
返回值
List<String>指定概念、地域,规模或者风格相关的成分股。
xxxxxxxxxx
protected List<String> getConceptStocks(LocalDate date,String concept)
获取指定时间点的概念、地域,规模及风格相关的成分股。
参数:
date: LocalDate 指定日期。
concept: String 概念、地域,规模或者风格代码。
返回值
List<String>指定概念、地域,规模或者风格相关的成分股。
xxxxxxxxxx
protected List<String> getConceptStocks(LocalDate date,String ….concepts)
获取指定时间点的概念、地域,规模及风格相关的成分股。
参数:
date: LocalDate 指定日期。
concepts: String 不定参数, 使用时可以传入多个概念、地域,规模或者风格代码,用逗号隔开。
返回值
List<String>指定概念、地域,规模或者风格相关的成分股。
xxxxxxxxxx
protected Map<String,Position> getPostions()
获取当前策略的持仓信息。
返回值
Map<String,Position> Key String 标的代码 Position Position类实例 使用此方庋时,需要导入 cn.quanttech.quantera.yotta.core.portfolio.Position
xxxxxxxxxx
protected void lazyRecordWeightBook(Map<String,double> weightList,LocalDate date)
在LAZYPERIOD运行模式下,按照既定的日期设定调仓股票清单。使用时将延迟到lazyEvaluate方法中执行。
参数:
weightList: Map<String,double> Map对手象 Key值为标的代码,Value为传入的该标的权重配置。
date: LocalDate。 指定的换仓日期。
xxxxxxxxxx
protected void lazyEvaluate()
在LAZYPERIOD运行模式下,待所有选股结果执行完毕后,进行选股后验,包括处理停牌股票(开仓时遇到停牌股票将不进行开仓,平仓遇到停牌股票将保留持仓,待恢复交易后平仓)、换仓操作。
xxxxxxxxxx
protected void lazyEvaluate(int logLevel)
在LAZYPERIOD运行模式下,待所有选股结果执行完毕后,进行选股后验,包括处理停牌股票(开仓时遇到停牌股票将不进行开仓,平仓遇到停牌股票将保留持仓,待恢复交易后平仓)、换仓操作。
参数:
logLevel: int 0及以下,不输出日志, 1输出 警告信息,1 以上,输出详细信信息。
xxxxxxxxxx
protected void lazyEvaluate(boolean bAdjust)
在LAZYPERIOD运行模式下,待所有选股结果执行完毕后,进行选股后验,包括处理停牌股票(开仓时遇到停牌股票将不进行开仓,平仓遇到停牌股票将保留持仓,待恢复交易后平仓)、换仓操作。
参数:
bAdjust: boolean 对于股票是否采用复权计算。 为true 将采用复权方式计算股票价格。
xxxxxxxxxx
protected void lazyEvaluate(int lazyLogLevel, boolean bAdjust)
在LAZYPERIOD运行模式下,待所有选股结果执行完毕后,进行选股后验,包括处理停牌股票(开仓时遇到停牌股票将不进行开仓,平仓遇到停牌股票将保留持仓,待恢复交易后平仓)、换仓操作。
参数:
logLevel: int 0及以下,不输出日志, 1输出 警告信息,1 以上,输出详细信信息。
bAdjust: boolean 对于股票是否采用复权计算。 为true 将采用复权方式计算股票价格。
xxxxxxxxxx
protected Quotation pickQuoteData(String target, TimeFrame timeFrame, LocalDate dataDate)
获取指定时间下及行情周期下标的的行情数据。
参数:
target: String 合约代码。
timeFrame: TimeFrame行情周期。
dataDate: LocalDate 指定时间点。
返回值
Quotation 行情数据。
xxxxxxxxxx
protected Map<String,Quotation> pickQuoteData(List<String> target, TimeFrame timeFrame, LocalDate dataDate)
获取一个List序列合约特定时间点采用的行情周期的行情。
参数:
target: List<String> 多合约构建list序列。
timeFrame: TimeFrame行情周期。
dataDate: LocalDate 指定时间点。
返回值
Map<String,Quotation> 多标的行情Map对象。
xxxxxxxxxx
protected List<? extends Quotation> pickQuoteData(String target,TimeFrame timeFrame,LocalDate startDate,LocalDate endDate)
获取合约在一段时间点的行情数据(包含开始时间与结束时间)。
参数:
target: String 合约代码。
timeFrame: TimeFrame行情周期。
startDate: LocalDate 开始时间。
endDate: LocalDate 结束 时间。
返回值
List<? extends Quotation> 可以是Bar数据,也可以是Tick数据。
xxxxxxxxxx
protected Map<String,List<? extends Quotation>> pickQuoteData(List<String> target, TimeFrame timeFrame, LocalDate startDate, LocalDate endDate)
获取合约序列在一段时间点的行情数据(包含开始时间与结束时间)。
参数:
target: List<String> 多合约构建list序列。
timeFrame: TimeFrame行情周期。
startDate: LocalDate 开始时间。
endDate: LocalDate 结束时间。
返回值
Map<String,List<? extends Quotation>> 其中 String(Key值)为合约名称,value 值为行情。 可以是Bar数据,也可以是Tick。
xxxxxxxxxx
protected List<AlphaFactorValue> pickFactorData(String factor, LocalDate dataDate)
获取因子数据。使用时,需要在策略头申明导入类: import cn.quanttech.quantera.common.type.data. AlphaFactorValue
。
参数:
factor: String 因子名称。
dataDate: LocalDate 指定时间。
返回值
List<AlphaFactorValue> list 对象 因子数据。
xxxxxxxxxx
protected List<AlphaFactorValue> pickFactorData(String factor, LocalDateTime dataDate)
获取具体时间点的因子数据。使用时,需要在策略头申明导入类:import cn.quanttech.quantera.common.type.data. AlphaFactorValue
。
参数:
factor: String 因子名称。
dataDate: LocalDateTime 指定时间。
返回值
List<AlphaFactorValue> list 对象 因子数据。
xxxxxxxxxx
protected List<AlphaFactorValue> pickFactorData(String factor,LocalDate start,LocalDate end)
获取因子数据。使用时,需要在策略头申明导入类: import cn.quanttech.quantera.common.type.data. AlphaFactorValue
。
参数:
factor: String 因子名称。
start: LocalDate 指定开始时间日期。
end: LocalDate 指定结束时间日期。
返回值
List<AlphaFactorValue> list 对象 因子数据。
xxxxxxxxxx
protected List<AlphaFactorValue> pickFactorData(String target,String factor,LocalDate start,LocalDate end)
获取标的的定时间段的相关因子数据。使用时,需要在策略头申明导入类: ``import cn.quanttech.quantera.common.type.data. AlphaFactorValue``` 。
参数:
target : String 指定股票代码。
factor: String 因子名称。
start: LocalDate 指定开始时间。
end: LocalDate 指定结束时间。
返回值
List<AlphaFactorValue> list 对象 因子数据。
xxxxxxxxxx
protected List<AlphaFactorValue> pickFactorData(String target,String factor,LocalDateTime start,LocalDateTime end)
获取指定股票的因子数据。使用时,需要在策略头申明导入类: import cn.quanttech.quantera.common.type.data. AlphaFactorValue
。
参数:
target : String 指定股票代码。
factor: String 因子名称。
start: LocalDateTime 指定开始时间。
end: LocalDateTime 指定结束时间。
返回值
List<AlphaFactorValue> list 对象 因子数据。
xxxxxxxxxx
protected List<AlphaFactorValue> pickFactorData(List<String> targetpool, String factor,LocalDate dataDate)
获取指定股票的因子数据。使用时,需要在策略头申明导入类: import cn.quanttech.quantera.common.type.data. AlphaFactorValue
。
参数:
targetpool : List<String> 股票池。
factor: String 因子名称。
dataDate: LocalDate 指定时间。
返回值
List<AlphaFactorValue> list 对象 因子数据。
xxxxxxxxxx
protected List<AlphaFactorValue> pickFactorData(List<String> targetpool, String factor,LocalDateTime dataDate)
获取指定股票的因子数据。使用时,需要在策略头申明导入类: import cn.quanttech.quantera.common.type.data. AlphaFactorValue
。
参数:
targetpool : List<String> 股票池。
factor: String 因子名称。
dataDate: LocalDateTime 指定时间。
返回值
List<AlphaFactorValue> list 对象 因子数据。
xxxxxxxxxx
protected List<AlphaFactorValue> pickFactorData(List<String> targetpool, String factor,LocalDate start,LocalDate end)
获取指定股票的因子数据。使用时,需要在策略头申明导入类: import cn.quanttech.quantera.common.type.data. AlphaFactorValue
。
参数:
targetpool : List<String> 股票池。
factor: String 因子名称。
start: LocalDate 指定开始时间。
endt: LocalDate 指定结束时间。
返回值
List<AlphaFactorValue> list 对象 因子数据。
xxxxxxxxxx
protected List<AlphaFactorValue> pickFactorData(List<String> targetpool, String factor,LocalDateTime start,LocalDateTime end)
获取指定股票的因子数据。使用时,需要在策略头申明导入类: import cn.quanttech.quantera.common.type.data. AlphaFactorValue
。
参数:
targetpool : List<String> 股票池。
factor: String 因子名称。
start: LocalDateTime 指定开始时间。
endt: LocalDateTime 指定结束时间。
返回值
List<AlphaFactorValue> list 对象 因子数据。
xxxxxxxxxx
protected List<AlphaFactorValue> pickRiskFactorData(String riskFactor, LocalDate start, LocalDate end)
获取风险因子数据,使用时,需要导入类:import cn.quanttech.quantera.common.type.data.AlphaFactorValue
。
参数:
fariskFactorctor: String 风险因子名称。
start: LocalDate 指定开始时间。
endt: LocalDate 指定结束时间。
返回值
List<AlphaFactorValue> list 对象 风险因子数据。
xxxxxxxxxx
protected List<AlphaFactorValue> pickFactorData(String target, String factor, LocalDateTime start, LocalDateTime end)
获取风险因子数据,使用时,需要导入类:import cn.quanttech.quantera.common.type.data.AlphaFactorValue
。
参数:
target: String 股票名称。
fariskFactorctor: String 风险因子名称。
start: LocalDate 指定开始时间。
endt: LocalDate 指定结束时间。
返回值
List<AlphaFactorValue> list 对象 风险因子数据。
xxxxxxxxxx
protected CurrentQuotation pickCurrentData(String target)
获取当前时间点(以天为单位)的行情数据。
参数:
target: String 股票或者期货代码。
返回值
CurrentQuotation对象。
xxxxxxxxxx
protected Map<String, CurrentQuotation> pickCurrentData(List<String> target)
获取当前时间点(以天为单位多个标的的行情。
参数:
target: List<String> List对象多个 股票或者期货代码。
返回值
Map<String, CurrentQuotation>Key为标的名,Value为 CurrentQuotation对象。
xxxxxxxxxx
protected List<SecuBaseInfo> getAllStocks()
获取所有股票的信息。调用此函数,需要导入类:import cn.quanttech.quantera.common.contract.SecuBaseInfo
。
返回值
List<SecuBaseInfo>股票的信息类序列。详情请查看SecuBaseInfo类。
xxxxxxxxxx
protected List<IndexInstrument> getAllIndex()
获取所有指数信息 使用时,需要在策略头申明导入类:import cn.quanttech.quantera.common.type.data.IndexInstrument
返回值
List< IndexInstrument>指数类序列,详情请查看IndexInstrument类。
xxxxxxxxxx
protected List<FundInstrument> getAllFund()
获取所有基金信息 使用时,需要在策略头申明导入类:import cn.quanttech.quantera.common.type.data.FundInstrument
。
返回值
List<FundInstrument>基金类序列,详情请查看FundInstrument类。
xxxxxxxxxx
protected List<ContractInfo> getAllFutures()
获取所有合约信息 使用时,需要在策略头申明导入类:import cn.quanttech.quantera.common.type.data.ContractInfo
。
返回值
List< ContractInfo >合约信类序列,详情请查看ContractInfo。
xxxxxxxxxx
protected List<Fundamental> getFundamentals(String code, Category category, LocalDate start, LocalDate end)
获取指定股票的财条信息。使用时,需要在策略头申明导入类:import cn.quanttech.quantera.common.type.fundamental.FundamentalFundamental
。
参数:
code: String 股票代码。
category: Category Enum 财务类型。category 可以取以下数据:
start: LocalDate 开始时间。
end: LocalDate 结束时间。
返回值
List< Fundamental>期货合约信息序列。详情请查看Fundamental类。
xxxxxxxxxx
protected Map<String, List<Fundamental>> getFundamentals(List<String> codes, Category category, LocalDate start, LocalDate end)
获取指定股票的财条信息。使用时,需要在策略头申明导入类:import cn.quanttech.quantera.common.type.fundamental.Fundament
。
参数:
code: String 股票代码
category: Category Enum 财务类型
start: LocalDate 开始时间。
end: LocalDate 结束时间。
返回值
Map<String, List<Fundamental>> 。详情请查看Fundamental类。
xxxxxxxxxx
protected Map<String,Double> createEqualWeight(List<String> secuCodes)
创建一个Map对象的等权重的股票列表。
参数:
secuCodes: List<String> 对象一个股票列表 股票代码为String
返回值
Map<String,Double>. key String 类型,表示股票代码,value double类型, 表示股票的权重。
xxxxxxxxxx
protected List<String> findTopNFactors(List<AlphaFactorValue> values,int n)
比对AlphaFactorValue中的因子值正序排列,查找前n个因子值股票代列表。使用时,需要在策略头申明导入类:import cn.quanttech.quantera.common.type.data.AlphaFactorValue
。
参数:
values: List<AlphaFactorValue> AlphaFactorValue因子List对象。
n: int决定返回因子股票池的大小。
返回值
List<String>因子股票池。
xxxxxxxxxx
protected List<String> findBottomNFactors(List<AlphaFactorValue> values,int n)
比对AlphaFactorValue中的因子值,倒序排列。 查找n个因子值股票代列表。使用时,需要在策略头申明导入类:import cn.quanttech.quantera.common.type.data.AlphaFactorValue
。
参数:
values: List<AlphaFactorValue> AlphaFactorValue因子List对象。
n: int决定返回因子股票池的大小。
返回值
List<String>因子股票池。
xxxxxxxxxx
protected List<String> findRangeFactors(List<AlphaFactorValue> values,int n)
获取 List<AlphaFactorValue> 中因子上限与因子下限分位数范围股票列表,如果因子下限值大于因子上限值,返回空集。使用时,需要在策略头申明导入类:import cn.quanttech.quantera.common.type.data.AlphaFactorValue
。
参数:
values: List<AlphaFactorValue> AlphaFactorValue因子List对象。
n: int决定返回因子股票池的大小。
返回值
List<String>因子股票池。
xxxxxxxxxx
protected List<String> findRangeFactors(List<AlphaFactorValue> values,int n)
获取 List<AlphaFactorValue>中因子取值在指定分位数上下限范围内的股票列表,如果因子下限值大于因子上限值,返回空集。使用时,需要在策略头申明导入类:import cn.quanttech.quantera.common.type.data.AlphaFactorValue
。
参数:
values: List<AlphaFactorValue> AlphaFactorValue因子List对象。
n: int决定返回因子股票池的大小。
返回值
List<String>因子股票池。
xxxxxxxxxx
protected List<String> getCurrentSecuCodes()
在PERIOD模式下,获取当前股票池成份列表 。
返回值
List<String>股票列表。
xxxxxxxxxx
protected List<String> getRemovingSecuCodes()
在PERIOD模式下,获取本期移除股票列表 。
返回值
ist<Pair<String,LocalDate>> 股票列表。
xxxxxxxxxx
protected List<Pair<String,LocalDate>> getRemovedSecuCodes()
在PERIOD模式下, 获取历史所有移除的股票列表。
返回值
List<Pair<String,LocalDate>> 已经移动的股票列表。
xxxxxxxxxx
protected void submitWeightBook(Map<String,Double> weightBook)
按照既定的股票代码与权重,对持仓进行换仓。
参数:
weightBook Map<String,Double> Map对象 key 为String类型的股票代码,value 为double 占的比重(权重)。
xxxxxxxxxx
protected boolean onRebalancing()
同setRebalancing()配对使用,依据setRebalancing()设置,确定当前是否进行调仓。
返回值
boolean 值。
xxxxxxxxxx
protected LocalDate queryBackwardTradingDate (LocalDate date,int count)
查询指定日期n个交易日之前交易日。
参数:
date: LocalDate 指定日期
count: int 偏移天数。
返回值
LocalDate 对象。
xxxxxxxxxx
protected List<LocalDate> getTradingDays(LocalDate start,LocalDate end)
获取两个日期之间的所有交易日,包含头尾(如果是交易日) 。
参数:
start : LocalDate 指定日期。
end : LocalDate 指定日期。
返回值
List<LocalDate> 交易日。
xxxxxxxxxx
protected List<LocalDate> getTradingDays(LocalDate localdate,int dayCount)
获取指定日期前n个交易日,包含endDate(如果其它是交易日) 。
参数:
localdate : LocalDate 指定日期。
dayCount : int 交易日的个数,如果超出当前最大或者最小交易日返回值个数可能比该值。
返回值
List<LocalDate> 交易日。