标签:量化交易 cointrader assert hibernate
转载需说明出处:http://blog.csdn.net/minimicall, http://cloudtrade.top
任何可交易的都可以称之为Assert,资产。其类代码如下:
package org.cryptocoinpartners.schema; import javax.persistence.Basic; import javax.persistence.Cacheable; import javax.persistence.Entity; import javax.persistence.Transient; import org.slf4j.Logger; import org.slf4j.LoggerFactory; /** * Represents anything valuable and tradable, like currency or stock *任何有价值的并且可交易的物体,比如现金、股票 * @author Tim Olson */ @Entity //实体,说明在数据库中会建立相应的表格。由于没有使用name参数,说明类名就是表明。 @Cacheable //可缓存 public abstract class Asset extends EntityBase { public static Asset forSymbol(String symbol) { // only Currency is supported return Currency.forSymbol(symbol); } @Basic(optional = false) public String getSymbol() { return symbol; } @Basic(optional = false) public double getBasis() { return basis; } @Transient public int getScale() { int length = (int) (Math.log10(Math.round(1 / basis))); return length; } @Override public String toString() { return symbol; } protected Asset(String symbol, double basis) { this.symbol = symbol; this.basis = basis; } // JPA protected Asset() { } protected void setSymbol(String symbol) { this.symbol = symbol; } protected void setBasis(double basis) { this.basis = basis; } private String symbol;//符号 private double basis;//值 private static Logger log = LoggerFactory.getLogger(Asset.class); }
程序员的量化交易之路(20)--Cointrader之Assert实体(8)
标签:量化交易 cointrader assert hibernate
原文地址:http://blog.csdn.net/minimicall/article/details/46354483