当前位置: 首页 > 软件库 > Web3 > 开源货币/比特币 >

crypto-rl

授权协议 Readme
开发语言 Python
所属分类 Web3、 开源货币/比特币
软件类型 开源软件
地区 不详
投 递 者 胡浩瀚
操作系统 跨平台
开源组织
适用人群 未知
 软件概览

Deep Reinforcement Learning Toolkit for Cryptocurrencies

Table of contents:

  1. Purpose
  2. Scope
  3. Dependencies
  4. Project structure
  5. Design patterns
  6. Getting started
  7. Citing this project
  8. Appendix

1. Purpose

The purpose of this application is to provide a toolkit to:

  • Record full limit order book and trade tick data from twoexchanges (Coinbase Pro and Bitfinex) into an ArcticTickstore database (i.e., MongoDB),
  • Replay recorded historical data to derive feature sets for training
  • Train an agent to trade cryptocurrencies using the DQN algorithm (note: this agentimplementation is intended to be an example for users to reference)

2. Scope

Research only; there is no capability for live-trading at exchanges.

3. Dependencies

See requirements.txt

Note: to run and train the DQN Agent (./agent/dqn.py) tensorflow and Keras-RLneed to be installed manually and are not listed in the requirements.txtin order to keep this project compatible with other opensourced reinforcement learning platforms(e.g., OpenAI Baselines).

Pip install the following:

git+https://github.com/manahl/arctic.git

Keras==2.2.4
Keras-Applications==1.0.7
Keras-Preprocessing==1.0.9
keras-rl==0.4.2

tensorboard==1.13.1
tensorflow-estimator==1.13.0
tensorflow-gpu==1.13.1

4. Project Structure

The key elements in this project and brief descriptions.

crypto-rl/
	agent/
				...reinforcement learning algorithm implementations
	data_recorder/
				...tools to connect, download, and retrieve limit order book data
	gym_trading/
				...extended openai.gym environment to observe limit order book data
	indicators/
				...technical indicators implemented to be O(1) time complexity
	design-patterns/
				...visual diagrams module architecture
	venv/
				...virtual environment for local deployments
	experiment.py          # Entry point for running reinforcement learning experiments
	recorder.py            # Entry point to start recording limit order book data
	configurations.py      # Constants used throughout this project
	requirements.txt       # List of project dependencies
	setup.py               # Run the command `python3 setup.py install` to 
	                       #    install the extended gym environment i.e., gym_trading.py

5. Design Patterns

Refer to each individual module for design pattern specifications:

Sample snapshot of Limit Order Book levels:

Sample snapshot of Order Arrival flow metrics:

6. Getting Started

Install the project on your machine:

# Clone the project from github
git clone https://github.com/sadighian/crypto-rl.git
cd crypto-rl

# Install a virtual environment for the project's dependencies
python3 -m venv ./venv

# Turn on the virtual environment
source venv/bin/activate

# Install keras-rl dependencies
pip3 install Keras==2.2.4 Keras-Applications==1.0.7 Keras-Preprocessing==1.0.9 keras-rl==0.4.2
 tensorboard==1.13.1 tensorflow-estimator==1.13.0 tensorflow-gpu==1.13.1
 
# Install database
pip3 install git+https://github.com/manahl/arctic.git

# Install the project
pip3 install -e .

6.1 Record limit order book data from exchanges

Step 1:Go to the configurations.py and define the crypto currencies whichyou would like to subscribe and record.

Note: basket list format is as follows [(Coinbase_Instrument_Name, Bitfinex_Instrument_Name), ...]

SNAPSHOT_RATE = 5  # I.e., every 5 seconds
BASKET = [('BTC-USD', 'tBTCUSD'),
         ('ETH-USD', 'tETHUSD'),
         ('LTC-USD', 'tLTCUSD'),
         ('BCH-USD', 'tBCHUSD'),
         ('ETC-USD', 'tETCUSD')]
RECORD_DATA = True

Step 2:Open a CLI/terminal and execute the command to start recordingfull limit order book and trade data.

python3 recorder.py

6.2 Replay recorded data to export stationary feature set

Step 1:Ensure that you have data in your database.

Check with MongoDB shell or Compass.If you do not have data, see refer to the section above6.1 Record limit order book data from exchanges.

Step 2:Run a historial data simulation to take snapshots of thelimit order book(s) and export their stationary featuresto a compressed csv.

To do this, you can leverage the test cases in data_recorder/tests/or write your own logic. When using the test case methods, make sureto change the query parameters to match what you've actually recorded andis in your database.

Example to export features to a compressed csv:

python3 data_recorder/tests/test_extract_features.py

6.3 Train an agent

Step 1:Ensure you have data in the data_recorder/database/data_exports/ folder.This is where the agent loads data from. If you do not have data exportedinto that folder, see refer to the section above6.2 Replay recorded data to export stationary feature set.

Step 2:Open a CLI/terminal and start learning/training the agent.

python3 experiment.py --window_size=50 --weights=False --fitting_file=...

Refer to experiment.py to see all the keyword arguments.

7. Citing this project

Please remember to cite this repository if used in your research:

    @misc{Crypto-RL,
        author = {Jonathan Sadighian},
        title = {Deep Reinforcement Learning Toolkit for Cryptocurrencies},
        year = {2019},
        publisher = {GitHub},
        journal = {GitHub repository},
        howpublished = {\url{https://github.com/sadighian/crypto-rl}},
    }

8. Appendix

8.1 Branches

There are multiple branches of this project, each with a different implementation patternfor persisting data:

  • FULL branch is intended to be the foundation for a fully automated trading system(i.e., implementation of design patterns that are ideal for a trading system that requiresparallel processing) and persists streaming tick data into an Arctic Tick Store

Note: the branches below (i.e., lightweight, order book snapshot, mongo integration)are no longer actively maintained as of October 2018, and are here for reference.

  • LIGHT WEIGHT branch is intended to record streaming data more efficiently thanthe full branch (i.e., all websocket connections are made from a single processand the limit order book is not maintained) and persists streaming tick data intoan Arctic tick store
  • ORDER BOOK SNAPSHOT branch has the same design pattern as the full branch,but instead of recording streaming ticks, snapshots of the limit order book are takenevery N seconds and persisted into an Arctic tick store
  • MONGO INTEGRATION branch is the same implementation as ORDER BOOK SNAPSHOT,with the difference being a standard MongoDB is used, rather than Arctic.This branch was originally used to benchmark Arctic's performance and is not up todate with the FULL branch.

8.2 Assumptions

  • You have installed a virtual environment and installed the project to that venv(e.g., pip3 install -e .)
  • You have mongoDB already installed
  • You know how to use a cli to start python scripts
  • You are running an ubuntu 18+ os

8.3 Change Log

  • 2021-09-25: Updated requirements.txt: going forward the database requires a manualinstallation via pip install git+https://github.com/manahl/arctic.git
  • 2019-12-12: Added docstrings and refactored many classes to improve code readability
  • 2019-09-18: Refactored envs and brokers for simplification andadded different reward approaches.
  • 2019-09-13: Created and implemented 'order arrival' flow metrics,inspired byMulti-Level Order-Flow Imbalance in a Limit Order Bookby Xu, Ke; Gould, Martin D.; Howison, Sam D.
  • 2019-09-06: Created and implemented Indicator.py base class
  • 2019-04-28: Reorganized project structure for simplicity
  • RSA新套路,记录一下。 题目源码: from secret import flag, x, y from Crypto.Util.number import * D = 0x1337 assert x**2 - D*y**2 == 1 p, q = [getPrime(1024) for _ in range(2)] n = p * q e = 0x10001 m = bytes_to_lo

  • 接上次的RSA,我们来接着学习RSA在CTF的常见类型题目。新涉及了python中的sympy库,利用里面的中国剩余定理函数。 低加密指数广播攻击 在RSA中e也称为加密指数。由于e是可以随意选取的,选取小一点的e可以缩短加密时间(比如3),但是选取不当的话,就会造成安全问题 如果选取的加密指数较低,并且使用了相同的加密指数将一个信息多次加密(广播),那么可以进行广播攻击得到明文。选取了相同的加密

  • package crypto import "crypto" crypto包搜集了常用的密码(算法)常量。 Index 返回首页 type PublicKey type PrivateKey type Hash func (h Hash) Available() bool func (h Hash) Size() int func (h Hash) New() hash.Hash func Re

  • 一道有趣的题,知识点:因数分解(费马的方法): (1)待分解的数n=10379。计算√n(指n的开平方,下同)。它不是整数,否则10379就是一个平方数了,而平方数已完成了至少一步因数分解。 (2)取大于等于√n的正整数N。可写成N=[√n]+1,其中[  ]是取整函数。显然,N^2>n。 (3)求N^2-n。然后考察它是不是平方数。注意,N^2-n应该不是很大,所以,比较容易判断它是不是平方数。

  • 1.crypto  (node.js) 1.1 加密 var key = '2cef781a9c0411eb' var str = JSON.stringify({ "ip": "192.168.12.1", "mac": "80:3F:5D:0E:04:2B", "wan_ip": "0.0.0.0", "internet": "1", "5g_ssid": "531A6-yang_test_2

  • 2.创建工具函数encryptPassword.ts实现加密 encryptPassword 这个文件实现的是传入一个字符串 然后给你加密 这里是用于密码的。 密码不要明文存储 根据用户的输入的密码,在加密一次存储到数据库,登录时,在把输入的加密一次,和数据库的比对,一样就登陆成功了 import * as crypto from 'crypto'; import config from '.

  • I am using a SAML authentication mechanism to authenticate my application. I am using IDP server as ADFS and SP as JBoss EAP 7.1.4. I have added all the configurations related to the IDP and sp server

  • 这回基本没有crypto,pwn题后几个有难度,一直整不出来,等WP pwn Sanity drink 只要求输入与密码相同,输入可以覆盖到密码 int __cdecl main(int argc, const char **argv, const char **envp) { char user_password[32]; // [rsp+0h] [rbp-50h] BYREF char

 相关资料
  • Overview 因为Java的Crypto API始终有点难用,SpringSide在core module中的org.springside.modules.security.utils中提供了封装。 API的出入参数都是byte[]数组,需要配合Encodes来转换成Hex或Base64存储。 Digests消息摘要 去年一轮的密码被盗风波后,使用salt并迭代N次的sha-1式密码存储已经是

  • The crypto component hosts all the implementations of cryptographic primitives we use in Libra: hashing, signing, and key derivation/generation. The NextGen directory contains implementations of crypt

  • crypto 跟加密相关的一些功能,包括安全验证等。

  • crypto 包括 attr、ecdsa、utils 子包。 attr:chaincode 属性检查校验; ecdsa:ecdsa 加密算法接口,一些 hash 和签名校验方法。 utils:提供 aes、ecdsa、x509 等方法。

  • crypto模块的目的是为了提供通用的加密和哈希算法。用纯JavaScript代码实现这些功能不是不可能,但速度会非常慢。Nodejs用C/C++实现这些算法后,通过cypto这个模块暴露为JavaScript接口,这样用起来方便,运行速度也快。 MD5和SHA1 MD5是一种常用的哈希算法,用于给任意数据一个“签名”。这个签名通常用一个十六进制的字符串表示: const crypto = req

  • import "crypto" crypto包搜集了常用的密码(算法)常量。 type PublicKey type PublicKey interface{} 代表一个使用未指定算法的公钥。 type PrivateKey type PrivateKey interface{} 代表一个使用未指定算法的私钥。 type Hash type Hash uint Hash用来识别/标识另一个包里实现