okex 0.3.3 → 0.3.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/okex/api_v5.rb +13 -0
- data/lib/okex/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 463b9adff7eb98e1fa712f06153edbc29b80870aede2cd2913681da84f0e5b66
|
4
|
+
data.tar.gz: 428d38ce826c5e3e01ddcd43c3a9e8e4e5b2de1d4f41139497ad5beee818b452
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 615e679ffb2f370020af864cdc753bcf7cb836a83e73a127046f09712b1a81a4d20dcbe94643e19177f1c61578fb8e3bfd44f752673fed56ab4208d4eeda7ee0
|
7
|
+
data.tar.gz: dc96eacc3985d1889eac587fee049b2c174eca9e245d03e66a4bfb3f1cb8c1871c99cb73ef70f5b418703883f4e6927888c7806492841fb76a71f9b4b43a332a
|
data/Gemfile.lock
CHANGED
data/lib/okex/api_v5.rb
CHANGED
@@ -87,6 +87,10 @@ class OKEX::ApiV5
|
|
87
87
|
end
|
88
88
|
|
89
89
|
# 设置止损价格
|
90
|
+
# @param inst_id [String] 合约名称
|
91
|
+
# @param posSide [String] 持仓方向
|
92
|
+
# @param sz [Integer] 持仓数量(张)
|
93
|
+
# @param price [Float] 止损价格
|
90
94
|
def set_stop_loss(inst_id, posSide, sz, price)
|
91
95
|
side = (posSide == OKEX::Order::POS_LONG) ? "sell" : "buy"
|
92
96
|
|
@@ -104,6 +108,15 @@ class OKEX::ApiV5
|
|
104
108
|
client.post(host, "/api/v5/trade/order-algo", params)
|
105
109
|
end
|
106
110
|
|
111
|
+
# 查询当前设置的止损价格
|
112
|
+
# @param inst_id [String] 合约名称
|
113
|
+
def stop_loss_price(inst_id)
|
114
|
+
result = client.get(host, "/api/v5/trade/orders-algo-pending?instId=#{inst_id}&instType=SWAP&ordType=conditional")
|
115
|
+
return result[0]["slTriggerPx"].to_i if result.size == 1
|
116
|
+
|
117
|
+
raise "invalid result: #{result.inspect}"
|
118
|
+
end
|
119
|
+
|
107
120
|
private
|
108
121
|
|
109
122
|
attr_reader :client, :host
|
data/lib/okex/version.rb
CHANGED