FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
python-binance/tests/test_futures.py at master · EnjoyAndroid/python-binance · GitHub
EnjoyAndroid
/
python-binance
Public
forked from
sammchardy/python-binance
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Security and quality
Insights
Expand file tree
Breadcrumbs
python-binance
/
tests
/
test_futures.py
Copy path
More file actions
More file actions
Latest commit
History
History
History
94 lines (85 loc) · 3.53 KB
Breadcrumbs
python-binance
/
tests
/
test_futures.py
Copy path
File metadata and controls
94 lines (85 loc) · 3.53 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
import
requests_mock
import
json
from
binance
.
client
import
Client
import
re
client
=
Client
(
api_key
=
"api_key"
,
api_secret
=
"api_secret"
,
ping
=
False
)
def
test_futures_position_information
():
with
requests_mock
.
mock
()
as
m
:
url_matcher
=
re
.
compile
(
r"https:\/\/fapi.binance.com\/fapi\/v3\/positionRisk\?.+"
)
response
=
[
{
"symbol"
:
"LTCUSDT"
,
"positionSide"
:
"LONG"
,
"positionAmt"
:
"0.700"
,
"entryPrice"
:
"75.6"
,
"breakEvenPrice"
:
"75.63024"
,
"markPrice"
:
"73.18000000"
,
"unRealizedProfit"
:
"-1.69400000"
,
"liquidationPrice"
:
"0"
,
"isolatedMargin"
:
"0"
,
"notional"
:
"51.22600000"
,
"marginAsset"
:
"USDT"
,
"isolatedWallet"
:
"0"
,
"initialMargin"
:
"10.24520000"
,
"maintMargin"
:
"0.33296900"
,
"positionInitialMargin"
:
"10.24520000"
,
"openOrderInitialMargin"
:
"0"
,
"adl"
:
0
,
"bidNotional"
:
"0"
,
"askNotional"
:
"0"
,
"updateTime"
:
1729436057076
,
}
]
m
.
register_uri
(
"GET"
,
url_matcher
,
json
=
json
.
dumps
(
response
),
status_code
=
200
)
pos
=
client
.
futures_position_information
(
symbol
=
"LTCUSDT"
)
assert
m
.
last_request
.
qs
[
"symbol"
][
0
]
==
"LTCUSDT"
.
lower
()
assert
m
.
last_request
.
path
==
"/fapi/v3/positionrisk"
def
test_futures_position_information_version_override
():
with
requests_mock
.
mock
()
as
m
:
url_matcher
=
re
.
compile
(
r"https:\/\/fapi.binance.com\/fapi\/v2\/positionRisk\?.+"
)
response
=
[
{
"symbol"
:
"LTCUSDT"
,
"positionSide"
:
"LONG"
,
"positionAmt"
:
"0.700"
,
"entryPrice"
:
"75.6"
,
"breakEvenPrice"
:
"75.63024"
,
"markPrice"
:
"73.18000000"
,
"unRealizedProfit"
:
"-1.69400000"
,
"liquidationPrice"
:
"0"
,
"isolatedMargin"
:
"0"
,
"notional"
:
"51.22600000"
,
"marginAsset"
:
"USDT"
,
"isolatedWallet"
:
"0"
,
"initialMargin"
:
"10.24520000"
,
"maintMargin"
:
"0.33296900"
,
"positionInitialMargin"
:
"10.24520000"
,
"openOrderInitialMargin"
:
"0"
,
"adl"
:
0
,
"bidNotional"
:
"0"
,
"askNotional"
:
"0"
,
"updateTime"
:
1729436057076
,
}
]
m
.
register_uri
(
"GET"
,
url_matcher
,
json
=
json
.
dumps
(
response
),
status_code
=
200
)
pos
=
client
.
futures_position_information
(
symbol
=
"LTCUSDT"
,
version
=
2
)
assert
m
.
last_request
.
qs
[
"symbol"
][
0
]
==
"LTCUSDT"
.
lower
()
assert
m
.
last_request
.
path
==
"/fapi/v2/positionrisk"
def
test_futures_account_balance
():
with
requests_mock
.
mock
()
as
m
:
url_matcher
=
re
.
compile
(
r"https:\/\/fapi.binance.com\/fapi\/v3\/balance\?.+"
)
m
.
register_uri
(
"GET"
,
url_matcher
,
json
=
{},
status_code
=
200
)
client
.
futures_account_balance
()
assert
m
.
last_request
.
path
==
"/fapi/v3/balance"
def
test_futures_account_config
():
with
requests_mock
.
mock
()
as
m
:
url_matcher
=
re
.
compile
(
r"https:\/\/fapi.binance.com\/fapi\/v1\/accountConfig\?.+"
)
m
.
register_uri
(
"GET"
,
url_matcher
,
json
=
{},
status_code
=
200
)
client
.
futures_account_config
()
assert
m
.
last_request
.
path
==
"/fapi/v1/accountconfig"
Back
|
FazBrowse Home
|
New Git URL