🔥码云GVP开源项目 12k star Uniapp+ElementUI 功能强大 支持多语言、二开方便! 广告
[原文网址](https://connect.spotware.com/docs/available-resources/playground) ### Getting access to the Trading API 使用以下方式建立SSL连接**host:port** Trading API入口点列表(该列表将使用辅助入口点进行更新,这些入口点将在主要点出现故障时使用): * Primary:[sandbox-tradeapi.spotware.com:5032](ssl://sandbox-tradeapi.spotware.com:5032) * Secondary1: coming soon * Secondary2: coming soon * Secondary3: coming soon See[trading API protocol description](https://connect.spotware.com/docs/api-reference/trading-api)to learn more about how it works. Or read[Getting Started Guide](https://connect.spotware.com/docs/api-reference/getting-started)to start your own app quickly. ### OAuth usage examples **Note 1:**如果您不知道cTrader ID是什么,为什么需要它以及它如何工作,请参阅[the corresponding section](https://connect.spotware.com/docs/available-resources/playground#ctraderID)below. 因为您必须使用OAuth服务。 **Note 2:**如果您不了解OAuth技术,请查看OAuth标准参考[RFC6749: The OAuth 2.0 Authorization Framework](http://tools.ietf.org/html/rfc6749). #### Getting access token flow * **Step 1**使用以下链接向我们的OAuth授权服务器发起请求。 您将被要求使用您的cTrader ID登录,请在开始之前创建它,如果您还没有。 如果您尝试访问帐户贸易信息,请使用此链接: ~~~ https://sandbox-connect.spotware.com/apps/auth? client_id={your Partner's Public Client ID}& redirect_uri={your Redirection URI}& scope=accounts ~~~ [Send Accounts API OAuth Request >>>](https://sandbox-connect.spotware.com/apps/auth?&client_id=139_a8QoCbMhGpWyWxpGKhkWeNdrADKzsFV6Ex7FDiDCTEeO5kiqqZ&redirect_uri=https%3A%2F%2Fconnect.spotware.com%2Fdocs%2Favailable-resources%2Fplayground&scope=accounts) 如果您尝试访问交易API,请使用以下链接: ~~~ https://sandbox-connect.spotware.com/apps/auth? client_id={your Partner's Public Client ID}& redirect_uri={your Redirection URI}& scope=trading ~~~ [Send Trading API OAuth Request >>>](https://sandbox-connect.spotware.com/apps/auth?&client_id=139_a8QoCbMhGpWyWxpGKhkWeNdrADKzsFV6Ex7FDiDCTEeO5kiqqZ&redirect_uri=https%3A%2F%2Fconnect.spotware.com%2Fdocs%2Favailable-resources%2Fplayground&scope=trading) * **Step 2**您的请求将使用授权码进行响应,授权码应由您的服务器与访问令牌交换 **Note:**请记住**授权码在10秒内到期**,所以你应该在收到后立即交换。 如果代码已过期,那么您可以再次发送初始请求(步骤1)。 使用以下请求交换代码: ~~~ https://sandbox-connect.spotware.com/apps/token? grant_type=authorization_code& code={the authorization code from the response on the previous request}& redirect_uri={your Redirection URI}& client_id={your Partner's Public Client ID}& client_secret={your Partner's Client Secret} ~~~ [Exchange the Code with Access Token](https://sandbox-connect.spotware.com/apps/token?grant_type=authorization_code&code=&redirect_uri=https%3A%2F%2Fconnect.spotware.com%2Fdocs%2Favailable-resources%2Fplayground&client_id=7_5az7pj935owsss8kgokcco84wc8osk0g0gksow0ow4s4ocwwgc&client_secret=49p1ynqfy7c4sw84gwoogwwsk8cocg8ow8gc8o80c0ws448cs4) 您将使用JSON文本文件进行响应。 使用记事本打开它以查看访问令牌和刷新令牌。 要刷新访问令牌,只需发送以下请求,用正确的数据替换占位符。 ~~~ https://sandbox-connect.spotware.com/apps/token? grant_type=refresh_token& refresh_token={your Refresh Token previously received with Access Token}& redirect_uri={your Redirection URI}& client_id={your Partner's Public Client ID}& client_secret={your Partner's Client Secret} ~~~ #### 可用的工具 * cTrader Web:[sandbox-ctweb.spotware.com](https://sandbox-ctweb.spotware.com/) 请参阅下文,了解如何创建cTrader ID,它是什么以及如何将帐户链接到它。 ### cTrader ID 了解cTrader ID(cTID)是什么 cTrader ID是个人交易者的个人资料,其中包含交易者的昵称,电子邮件,头像等信息.cTID在所有cTrader产品中很常见,可用于在一个地方管理所有交易账户(即使他们是用不同的经纪人开设的) )以及访问cTrader的云功能,如云收藏夹,警报等。此外,使用cTrader ID交易者可以授予他的交易账户访问第三方在线应用程序,解决方案和产品,如交易性能发布者,信号复制器等。 如何创建cTrader ID并将帐户链接到它 1.打开cTrader Web sandbox2-ct.spotware.com 2.使用“Open DEMO accout”,您可以创建自己的模拟账户。密码将在创建帐户时发送到您指定的电子邮件。     * **注意:**通过重复此操作,您可以根据需要为调查和测试创建尽可能多的帐户 3.使用您的DEMO帐户登录。 4.使用cTrader终端窗口右上角的“注册”菜单,您可以创建自己的cTrader ID。只需填写3个字段: * nickname (your personal profile nickname) * email (please specify correct email, the confirmation code will be sent to you) * password 5.转到为cTID指定的电子邮件,然后单击此处的确认链接以符合您的cTID创建。 6.如果您使用相同的浏览器处理电子邮件和cTWeb - 将打开cTWeb,您将自动使用新的cTID登录。 7.所有可用帐户将自动链接到您的cTID。 之后,您可以使用您的cTID将您的交易账户访问权限授予与cTrader平台集成的第三方应用程序。