分类
外汇短线交易是什么

FinRL 入门指南

    Load the Graph API Explorer and from the Facebook App dropdown menu, select your app.

Get Started

This tutorial shows you how to use the Video API to create a Video on a Page. It assumes you know how to perform basic cURL requests with a command-line tool like Terminal, or an app such as Postman, and have basic familiarity with the Graph API Explorer.

Before You Start

  • An existing Facebook app. If you don’t have one, go to Facebook for Developers, click My Apps, and create one.
  • A 10–20 MB video that you have split into 5 MB chunks, with all of the chunks in a single directory.
  • A Page that you are able to perform CREATE_CONTENT Tasks on.
  • Access to a command-line tool (such as Terminal) or an app (such as Postman) that can perform cURL requests.

Step 1: Get a User Access Token

As a general practice, you have to implement Facebook Login into your app and use it to get Access Tokens from your app users. However, for this tutorial, you can use the Graph API Explorer because it has already implemented Facebook Login and makes it easy for you to generate tokens for any of your apps.

    Load the Graph API Explorer and from the Facebook App dropdown menu, select your app.

Step 2: Get Your Page ID and Its Token

  1. Using the Graph API Explorer, send a request to the GET /me/accounts edge. This queries your user and returns any Pages that you authorized your app to access in the last step.
  2. Identify your Page in the response and copy its ID ( id ) and Page access token ( access_token ).

Step 3: Create a Video Session

  1. In your command-line tool, navigate to the folder containing your video’s chunks, then send a cURL request to the POST /page-id/videos edge on the graph-video.facebook.com host. If you are using Postman, include the query parameter keys and values in FinRL 入门指南 the request Body as form-data.
    Sample Request
  2. Replace the Page ID ( 1755847768034402 ) in the request path with your Page's ID, FinRL 入门指南 set access_token to the Page access token you just copied, and file_size to the video file’s total size, in bytes.
    The API returns a video session:
  3. Copy all returned values, except for end_offset .

Step 4: Upload First Video Chunk

Send another request to the POST /{page-id}/videos edge and include your upload_session_id and the name of your first video chunk.

Sample Request

If you are using cURL, include the @ symbol FinRL 入门指南 before your file name.

If you are FinRL 入门指南 using Postman, omit the @ symbol, set video_file_chunk to File (hover over the row to trigger the drop-down menu) and manually select the first chunk file.

The API will respond with a new start_offset . Capture the new value.

Step 5: Upload Remaining Video Chunks

  1. Perform the same request, but set start_offset to the new start_offset value returned in the previous response, and set video_file_chunk to the name of the next video chunk in sequence. The API will once again respond with a new start_offset value, which you can use to upload the next chunk in sequence.
  2. Continue repeating this step until you have uploaded all remaining video chunks in the correct order. The program you used to split your video file into chunks should take care of naming your chunks in sequential order.

Step 6: End Upload Session

Once you have uploaded your final chunk, end the upload session by sending one final request to the same endpoint and set upload_phase to finish.

Sample Request

Upon success, the API will end the upload session and respond with true .

We will assemble your video and encode it. The encoding FinRL 入门指南 process may take up to several minutes to fully encode, depending on the total size of your video file.

FinRL 入门指南

ElegantRL

近年来,不少研究者和机构都在研究使用深度强化学习技术解决量化交易问题,其中FinRL 是在这一领域中展示了巨大的潜力的 Python 开源项目。FinRL最初由哥伦比亚大学的一个研究团队提出,是适用于量化交易的深度强化学习项目,为从业人员提供用于流程化策略开发的统一项目模板。FinRL目前由开源社区 AI4Finance 进行维护,他们提供了量化金融中深度强化学习(DRL)的教育资源,对学习者非常友好。

1.项目概述

  • FinRL:流程化生成和管理交易策略
  • ElegantRL(小雅):开发和优化深度强化学习算法,提供了轻量级的DRL算法库,其中包含DDPG,TD3, SAC, PPO(GAE),DQN,DoubleDQN, DuelingDQN, D3QN,并支持用户自定义算法
  • FinRL-Meta:通过FinRL-Meta对接不同交易市场

AI4Finance 团队认为评价DRL库的指标应当包括ReplayBuffer、RL训练数据的吞吐、算法依赖关系、是否区分on-policy和off-policy、多进程的控制中心等。此前在强化学习社区中流行的DRL开源库包括伯克利的RLlib ray,OpenAI的baselines,hill的stable baselines,stable baselines FinRL 入门指南 3,莫烦的教学代码,来自清华大学团队的“天授”等。FinRL作为新晋的DRL项目,吸取社区中的项目的优势,也进化出更多的新特性。

“小”:只需安装 PyTorch 和 Matplotlib 用于网络训练以及画图协助调参,整个库只有4个 py 文件,并且tutorial版将一直维持在1000行代码以内,保持与最新版使用相同的变算法库量名与代码结构,把学习成本降到最低。

“雅”:代码优雅,可读性高,耦合度低,可移植性高。ElegantRL具备DRL算法的基本模板,都继承自一个基类。只要照着模板编写新算法,就能自动支持多进程训练。

高性能:ElegantRL在支持多进程训练后,最新版最要支持多GPU训练了。RL与DL的不同导致它的分布式不能照搬DL的多GPU训练模式,所以无法直接使用PyTorch 或TensorFlow 这些深度学习框架自带的多GPU训练模块。

以下内容由Luke翻译自 ElegantRL: a lightweight and stable deep reinforcement learning library 内容有部分改动

2.ElegantRL的特点

ElegantRL能够帮助研究人员和从业者更便捷地“设计、开发和部署”深度强化学习技术。ElegantRL的 elegant 体现在以下几个方面:

轻量:代码量低于1000行

高效:性能向Ray RLlib靠拢

稳定:ElegantRL支持离散动作空间以及连续动作空间下的常用DRL算法,并且提供了十分友好的教程

3.总述:文件结构和函数

ElegantRL的“小”最直观的体现就是:整个库只有3个文件,net.py, agent.py, run.py。 再加上env.py 用于存放与训练环境有关的代码。在Tutorial版用小于1000行的代码对一个完整的DRL库进行实现,这对想要入门深度强化学习的研究者有莫大的帮助。