现货合约/秒合约跟单交易所平台开发源代码详情(案例)

2023-03-03 15:52:16 浏览数 (1)

秒合约交易规则比较简捷,简单来说,首先必须选择要交易的数字货币。交易时间区间短为1min、3min、5min,长为60min;然后风险控制,在我们可以控制的风险范围内设定交易金额,设定盈余止损,最重要的是进行货币方向走势的技术分析。也就是说,在我们设置的交易区间内的涨跌方向,根据分析下单。

当指定了trade_id时, 返回一个成交Trade对象引用,不填trade_id参数调用本函数, 将返回包含用户当前交易日所有成交记录的一个Entity对象引用, 使用方法与dict一致, 其中每个元素的key为成交号, value为Trade,Trade继承于Entity。推荐优先使用 Order对象的属性trade_records获取某个委托单的相应成交记录, 更简单易用,仅当确有需要时才使用本函数。

is_changing(obj: Any, key: Optional[Union[str, List[str]]] = None):判定obj最近是否有更新。当业务数据更新导致 wait_update 返回后可以使用该函数判断本次业务数据更新是否包含特定obj或其中某个字段 。如果本次业务数据更新包含了待判定的数据则返回 True, 否则返回 False。关于判断K线更新的说明: 当生成新K线时,其所有字段都算作有更新,若此时执行 api.is_changing(klines.iloc[-1]) 则一定返回True。

代码语言:javascript复制
 /**
    * @dev Approve the passed address to spend the specified amount of tokens on behalf of msg.sender.
    * @param _spender The address which will spend the funds.
    * @param _value The amount of tokens to be spent.
    */
    function approve(address _spender, uint _value) public onlyPayloadSize(2 * 32) {        // To change the approve amount you first have to reduce the addresses`
        //  allowance to zero by calling `approve(_spender, 0)` if it is not
        //  already 0 to mitigate the race condition described here:
        //  
        require(!((_value != 0) && (allowed[msg.sender][_spender] != 0)));
        allowed[msg.sender][_spender] = _value;
        Approval(msg.sender, _spender, _value);
    }    /**
    * @dev Function to check the amount of tokens than an owner allowed to a spender.
    * @param _owner address The address which owns the funds.
    * @param _spender address The address which will spend the funds.
    * @return A uint specifying the amount of tokens still available for the spender.
    */
    function allowance(address _owner, address _spender) public constant returns (uint remaining) {        return allowed[_owner][_spender];
    }
}/**
 * @title Pausable
 * @dev Base contract which allows children to implement an emergency stop mechanism.
 */contract Pausable is Ownable {
  event Pause();
  event Unpause();  bool public paused = false;  /**
   * @dev Modifier to make a function callable only when the contract is not paused.
   */
  modifier whenNotPaused() {    require(!paused);
    _;
  }  /**
   * @dev Modifier to make a function callable only when the contract is paused.
   */
  modifier whenPaused() {    require(paused);
    _;
  }  /**
   * @dev called by the owner to pause, triggers stopped state
   */
  function pause() onlyOwner whenNotPaused public {
    paused = true;
    Pause();
  }  /**
   * @dev called by the owner to unpause, returns to normal state
   */
  function unpause() onlyOwner whenPaused public {
    paused = false;
    Unpause();
  }

0 人点赞