okex 0.2.1 → 0.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/okex.rb +1 -0
- data/lib/okex/api_v5.rb +7 -1
- data/lib/okex/client.rb +2 -0
- data/lib/okex/order.rb +52 -0
- data/lib/okex/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 119599f81a10e3904790ddb620ce5e73c5f8f880c542d0b1cc34e56463cc88d4
|
4
|
+
data.tar.gz: a0b3c1f7f95ddfbacb37703461ffb92f3df372fa6e6f64e91c6027127d513a9a
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e40edaca89bbfad96f815190516ba4ac2a47244a442189d54aca236c0a908b03141f4878a00c8153e2496c63a1aef9d25b747419c624bc3eea82caf89ec72efe
|
7
|
+
data.tar.gz: 17d81b29e609e2a11614b214ca77c3143391654a1276eefe4d702b63fc81e415ff92cf6a554d28c9f55d2c41c0734c9409f5d3617ad46cdd5a9d167660847403
|
data/Gemfile.lock
CHANGED
data/lib/okex.rb
CHANGED
data/lib/okex/api_v5.rb
CHANGED
@@ -8,7 +8,13 @@ class OKEX::ApiV5
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def orders
|
11
|
-
client.get("/api/v5/account/positions")
|
11
|
+
resp = client.get("/api/v5/account/positions")
|
12
|
+
|
13
|
+
if resp['code'].to_i == 0 && resp['data'].size > 0
|
14
|
+
return resp['data'].map {|params| OKEX::Order.new(params)}
|
15
|
+
end
|
16
|
+
|
17
|
+
[]
|
12
18
|
end
|
13
19
|
|
14
20
|
def short_swap(instid, amount)
|
data/lib/okex/client.rb
CHANGED
data/lib/okex/order.rb
ADDED
@@ -0,0 +1,52 @@
|
|
1
|
+
module OKEX
|
2
|
+
class Order
|
3
|
+
POS_LONG = 'long'.freeze
|
4
|
+
POS_SHORT = 'short'.freeze
|
5
|
+
|
6
|
+
def initialize(params)
|
7
|
+
@params = params
|
8
|
+
end
|
9
|
+
|
10
|
+
def instrument_id
|
11
|
+
dig("instId")
|
12
|
+
end
|
13
|
+
|
14
|
+
# 杠杆倍数
|
15
|
+
def leverage
|
16
|
+
dig("lever")
|
17
|
+
end
|
18
|
+
|
19
|
+
def created_at
|
20
|
+
Time.at(dig("cTime").to_i / 1000)
|
21
|
+
end
|
22
|
+
|
23
|
+
# 平均开仓价
|
24
|
+
def avg_open_price
|
25
|
+
dig("avgPx").to_f
|
26
|
+
end
|
27
|
+
|
28
|
+
# 预估强平价
|
29
|
+
def est_liq_price
|
30
|
+
dig("liqPx").to_f
|
31
|
+
end
|
32
|
+
|
33
|
+
# 持仓方向
|
34
|
+
def position_side
|
35
|
+
side = dig("posSide")
|
36
|
+
if [POS_SHORT, POS_LONG].include?(side)
|
37
|
+
return side
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
# 未实现收益
|
42
|
+
def upl
|
43
|
+
dig("upl").to_f
|
44
|
+
end
|
45
|
+
|
46
|
+
private
|
47
|
+
|
48
|
+
def dig(key)
|
49
|
+
@params[key]
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
data/lib/okex/version.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: okex
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- David Zhang
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-07-
|
11
|
+
date: 2021-07-23 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -90,6 +90,7 @@ files:
|
|
90
90
|
- lib/okex/client.rb
|
91
91
|
- lib/okex/coin.rb
|
92
92
|
- lib/okex/coin/bitcoin.rb
|
93
|
+
- lib/okex/order.rb
|
93
94
|
- lib/okex/version.rb
|
94
95
|
- okex.gemspec
|
95
96
|
homepage: https://github.com/daqing/okex
|