Uh oh!
There was an error while loading. Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork 236
Expand file tree
/
Copy pathmain.py
More file actions
Latest commit
37 lines (32 loc) · 1.12 KB
/
Copy pathmain.py
File metadata and controls
37 lines (32 loc) · 1.12 KB
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
importos
importsys
importtime
fromccapiimportEvent, SessionOptions, SessionConfigs, Session, EventHandler, Request
classMyEventHandler(EventHandler):
def__init__(self):
super().__init__()
defprocessEvent(self, event: Event, session: Session) ->None:
print(f"Received an event:\n{event.toPrettyString(2, 2)}")
if__name__=="__main__":
ifnotos.environ.get("BINANCE_US_API_KEY"):
print("Please set environment variable BINANCE_US_API_KEY", file=sys.stderr)
sys.exit(1)
ifnotos.environ.get("BINANCE_US_API_SECRET"):
print("Please set environment variable BINANCE_US_API_SECRET", file=sys.stderr)
sys.exit(1)
eventHandler=MyEventHandler()
option=SessionOptions()
config=SessionConfigs()
session=Session(option, config, eventHandler)
request=Request(Request.Operation_CREATE_ORDER, "binance-us", "BTCUSD")
request.appendParam(
{
"SIDE": "BUY",
"QUANTITY": "0.0005",
"LIMIT_PRICE": "20000",
}
)
session.sendRequest(request)
time.sleep(10)
session.stop()
print("Bye")