-
Notifications
You must be signed in to change notification settings - Fork 105
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of github.com:blockplusim/crypto_trading_service_…
…for_tradingview
- Loading branch information
Showing
4 changed files
with
114 additions
and
41 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
**常用代码模板** | ||
|
||
开多代码信号模板 | ||
``` | ||
plotshape(condition1, text='▲', style=shape.labeldown, textcolor=color.white, color = color.green, location = location.abovebar, title = "开多") | ||
alertcondition(condition1 , title="CrossOver Double EMA Buy", message="CrossOver Double EMA Buy") | ||
``` | ||
|
||
开空代码信号模板 | ||
``` | ||
plotshape(condition2, text='▼', style=shape.labeldown, textcolor=color.white, color = color.red, location = location.abovebar, title = "开空") | ||
alertcondition(condition2 , title="CrossUnder Double EMA Sell", message="CrossUnder Double EMA Sell") | ||
``` | ||
|
||
平仓代码模板 | ||
``` | ||
plotshape(condition2, text='Cancel', style=shape.labeldown, textcolor=color.white, color = color.red, location = location.abovebar, title = "开空") | ||
alertcondition(condition2 , title="CrossUnder Double EMA Sell", message="CrossUnder Double EMA Sell") | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
## okex_trading.py 使用指南 | ||
适用于有python使用经验的朋友,因为只是一个python脚本 | ||
|
||
**使用流程** | ||
1.购买海外服务器,注意必须是中国大陆以外的,因为许多交易所目前大陆IP无法连接和交易 | ||
2.安装 Python3.6 环境,安装必备的包:ccxt flask 等 | ||
3.我们需要修改 ***config.ini*** 文件。该文件包含以下内容 | ||
|
||
```ini | ||
[account] | ||
apiKey = | ||
secret = | ||
password = | ||
enable_proxies = False | ||
proxies = | ||
|
||
[trading] | ||
symbol = TRX-USDT-SWAP | ||
amount = 1 | ||
tdMode = isolated | ||
lever = 5 | ||
|
||
[service] | ||
apiSec = 5BFJYtNg7hwkgCzYQMwwQNctqan9CmqOzmtldJc | ||
listenHost = 0.0.0.0 | ||
listenPort = 80 | ||
debugMode = True | ||
ipWhiteList = 52.89.214.238,34.212.75.30,54.218.53.128,52.32.178.7,127.0.0.1 | ||
``` | ||
|
||
**[account]** 节点主要配置欧易交易所的API信息 | ||
apiKey、secret和password可以在欧易个人中心的API中创建(创建API记得给予交易和读取权限,不要给提现的权限),enable_proxies是是否启用代理的意思,如果你的服务器是国内服务器,一般需要启用,启用填写True,proxies填写具体的代理地址,如:http://127.0.0.1:1080 所以建议使用海外服务器来运行这个程序 | ||
|
||
**[trading]** 交易API的默认配置 | ||
**symbol**:交易对,比特币BTC/USDT永续合约就是 BTC-USDT-SWAP 其他币也类似,不知道这个怎么设置的话,可以打开电脑版欧易,打开 交易 -> 基础交易 -> 切换你要交易的币对 -> 浏览器地址栏最后面就有交易对信息 | ||
**amount**:交易的数量,币的个数。注意这里统一使用币来计价,比如你开BTC,那么这里就是开BTC的数量 | ||
**lever**:默认杠杆倍数,如果 /order 请求中带有这个参数,系统会根据lever重新修改杠杆倍数 | ||
**tdMode**:保证金模式,isolated:逐仓 ;cross:全仓 | ||
|
||
**[service]** 服务配置 | ||
**apiSec**:通信密钥,这个一定要修改,随便改长一点复杂一点就行了 | ||
**listenHost**: 服务监听地址,一般默认即可 | ||
**listenPort**:服务监听端口,一般80即可,注意 TradingView 只支持80和443 | ||
**debugMode**:True或者False,开启debug模式的话日志输出会更详细 | ||
**ipWhiteList**:授权使用本服务接口的IP地址集合,每个IP地址用英文逗号 **,** 隔开,这里默认前面四个地址是 TradingView 的官方地址 | ||
|
||
**运行环境** | ||
Python 3.6.10 | ||
ccxt 1.56.41 | ||
flask 1.1.2 | ||
|
||
**如何运行** | ||
修改玩config.ini中的配置后,直接使用 `python okex_trading.py` 启动即可 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
## okex_trading_ui 使用说明 | ||
预编译好且带有操作界面的程序,操作比较简单,适合新手小白 | ||
|
||
**使用前准备** | ||
1.需要准备一个欧易OKEX交易所账号,如果你还没有注册,请先[注册一个账号](http://okex.pw/tvbot),然后到账号API申请V5API,备注名称随意,权限需要选择只读和交易,不要勾选提现!然后确认添加即可 | ||
2.你需要购买一台海外的服务器用于24小时自动运行这个自动交易程序,可以选择腾讯云轻量应用服务器香港等东亚地区的服务器(注意必须买海外的,推荐香港),可查看[腾讯轻量服务器教程](https://cloud.tencent.com/document/product/1207/44549) | ||
|
||
**使用步骤** | ||
1.在服务器上下载程序,从 `release` 中下载 `okex_trading_ui` 程序并解压到服务器上。[服务器上打开这个链接下载](https://github.com/blockplusim/crypto_trading_service_for_tradingview/releases) | ||
2.下载完成以后解压,直接双击打开 `okex_trading_ui.exe` 界面如下: | ||
|
||
<img src="https://user-images.githubusercontent.com/94948670/146109501-70f09b0d-59c2-4690-8993-64c33d823d0f.png" alt="" width="40%" height="40%" /> | ||
|
||
在上面的界面中,我们看到需要用到三个参数 apiKey / secret / password 。这三个参数我们可以在欧易OKEX个人中心中API中申请V5API中获取,然后把三个参数复制过来 | ||
|
||
<img src="https://user-images.githubusercontent.com/94948670/146110819-1b3a1ea5-39df-4fd7-8a98-35d7ca0763a0.png" alt="" width="70%" height="70%" /> | ||
|
||
下一步我们配置交易相关信息 | ||
|
||
<img src="https://user-images.githubusercontent.com/94948670/146111099-c4fc3341-038d-48c3-a80b-55a95647d638.png" alt="" width="40%" height="40%" /> | ||
|
||
下一步在服务配置这边,一般需要修改 `通信密钥`, 这里就是一个简单的密码,用于验证身份。我们在TradingView调用的时候需要用到 | ||
|
||
<img src="https://user-images.githubusercontent.com/94948670/146111335-9842154a-3f0b-48d2-8cf1-a8d9ba5d6a02.png" alt="" width="40%" height="40%" /> | ||
|
||
配置完成后,点击 `保存配置`,然后再点击 `启动服务` 即可 | ||
|
||
<img src="https://user-images.githubusercontent.com/94948670/146112100-2be19db2-2dc6-4328-a997-0d68ba335bea.png" alt="" width="40%" height="40%" /> | ||
|
||
这个启动完成后,我们就可以对接 `TradingView` 来实现自动交易了 | ||
|
||
<img src="https://user-images.githubusercontent.com/94948670/146113041-85c79ee7-4917-4953-9f07-17a86e023ee9.png" alt="" width="100%" height="100%" /> | ||
|
||
在香港服务器上运行成功界面如上图所示 | ||
|
||
|