Request Python API single order submit for gateio-perpetual-futures
tensorboy opened this issue · 0 comments
tensorboy commented
Is your feature request related to a problem? Please describe.
I'm trying to create orders with the python bindings of gateio-perpetual-futures, however, I cannot do it because I'm not quite familiar with C++.
OS: ubuntu 20.04
My cmake:
include_guard(DIRECTORY)
# If you encountered segmentation fault at run-time, comment out the following line.
if (CMAKE_BUILD_TYPE STREQUAL "Release")
set(CMAKE_INTERPROCEDURAL_OPTIMIZATION TRUE)
endif()
add_compile_definitions(CCAPI_ENABLE_SERVICE_EXECUTION_MANAGEMENT)
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_GATEIO)
add_compile_definitions(CCAPI_ENABLE_EXCHANGE_GATEIO_PERPETUAL_FUTURES)
My python script:
import os
import sys
import time
from ccapi import Event, SessionOptions, SessionConfigs, Session, EventHandler, Request
class MyEventHandler(EventHandler):
def __init__(self):
super().__init__()
def processEvent(self, event: Event, session: Session) -> bool:
print(f'Received an event:\n{event.toStringPretty(2, 2)}')
return True # This line is needed.
if __name__ == '__main__':
eventHandler = MyEventHandler()
option = SessionOptions()
config = SessionConfigs()
config.setCredential({"CCAPI_GATEIO_PERPETUAL_FUTURES_API_KEY":"xxx", \
"CCAPI_GATEIO_PERPETUAL_FUTURES_API_SECRET":"xxx"})
session = Session(option, config, eventHandler)
request = Request(Request.Operation_CREATE_ORDER, "gateio-perpetual-futures", "ETH_USDT")
request.appendParam({
"size": "0.01",
"price":"2500",
"tif": "gtc"
})
session.sendRequest(request)
time.sleep(10)
session.stop()
print('Bye')
The error message:
Event [
type = RESPONSE,
messageList = [
Message [
type = RESPONSE_ERROR,
recapType = UNKNOWN,
time = 1970-01-01T00:00:00.000000000Z,
timeReceived = 2022-03-15T21:42:18.578651194Z,
elementList = [
Element [
nameValueMap = {
ERROR_MESSAGE = {"label":"INVALID_KEY","message":"Invalid key provided"},
HTTP_STATUS_CODE = 401
}
]
],
correlationIdList = [ dsnhvXZo ]
]
]
]
Bye
(worldbreak) nana@nana:~/cppapi/binding/python/example/src/gateio_create_order$ python main.py
Received an event:
Event [
type = RESPONSE,
messageList = [
Message [
type = RESPONSE_ERROR,
recapType = UNKNOWN,
time = 1970-01-01T00:00:00.000000000Z,
timeReceived = 2022-03-15T21:44:25.059816210Z,
elementList = [
Element [
nameValueMap = {
ERROR_MESSAGE = {"label":"INVALID_KEY","message":"Invalid key provided"},
HTTP_STATUS_CODE = 401
}
]
],
correlationIdList = [ T6NOe8yS ]
]
]
]
Bye
It looks my API Key and Secret are not right, however, I confirm it is right, I also changed my API key and secret to other invalid numbers, which show the same error.
Describe the solution you'd like
A bunch of examples to submit orders for each exchange.
Describe alternatives you've considered
A script to submit an order for gateio-perpetual-futures