• 程序猿的量化交易之路(20)--Cointrader之Assert实体(8)


    转载需说明出处: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); }



  • 相关阅读:
    请求重定向,请求转发
    post、get方法乱码问题
    Servlet
    修改Servlet模板,让Servlet更清新
    Java-Python对垒之质数计算
    使用Packet Tracer对不同网段组网模拟
    哑编码的两种方法
    AdaBoost scikit-learn相关参数
    KNN scikit-learn相关参数
    递归思想的应用-根据二叉树的中序遍历和前序遍历重建二叉树
  • 原文地址:https://www.cnblogs.com/zfyouxi/p/5200201.html
Copyright © 2020-2023  润新知