FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
openapi/examples/cpp/submit_order/main.cpp at main · noneback/openapi · GitHub
noneback
/
openapi
Public
forked from
longbridge/openapi
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
openapi
/
examples
/
cpp
/
submit_order
/
main.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
52 lines (45 loc) · 1.21 KB
Breadcrumbs
openapi
/
examples
/
cpp
/
submit_order
/
main.cpp
Copy path
File metadata and controls
52 lines (45 loc) · 1.21 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
#
include
<
iostream
>
#
include
<
longport.hpp
>
#
ifdef
WIN32
#
include
<
windows.h
>
#
endif
using
namespace
longport
;
using
namespace
longport
::trade
;
int
main
(
int
argc,
char
const
* argv[])
{
#
ifdef
WIN32
SetConsoleOutputCP
(
CP_UTF8
);
#
endif
Config config;
Status status =
Config::from_env
(config);
if
(!status) {
std::cout <<
"
failed to load configuration from environment:
"
<< status.
message
() << std::endl;
return
-
1
;
}
TradeContext::create
(config, [](
auto
res) {
if
(!res) {
std::cout <<
"
failed to create trade context:
"
<< res.
status
().
message
()
<< std::endl;
return
;
}
SubmitOrderOptions opts{
"
700.HK
"
, OrderType::
LO
, OrderSide::Buy,
Decimal
(
200
), TimeInForceType::Day,
Decimal
(
50.0
),
std::
nullopt
, std::
nullopt
, std::
nullopt
,
std::
nullopt
, std::
nullopt
, std::
nullopt
,
std::
nullopt
,
};
res.
context
().
submit_order
(opts, [](
auto
res) {
if
(!res) {
std::cout <<
"
failed to submit order:
"
<< res.
status
().
message
()
<< std::endl;
return
;
}
std::cout <<
"
order id:
"
<< res->
order_id
<< std::endl;
});
});
std::cin.
get
();
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL