FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
openapi/examples/cpp/subscribe_candlesticks/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
/
subscribe_candlesticks
/
main.cpp
Copy path
More file actions
More file actions
Latest commit
History
History
History
62 lines (51 loc) · 1.55 KB
Breadcrumbs
openapi
/
examples
/
cpp
/
subscribe_candlesticks
/
main.cpp
Copy path
File metadata and controls
62 lines (51 loc) · 1.55 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
#
include
<
iostream
>
#
include
<
longport.hpp
>
#
ifdef
WIN32
#
include
<
windows.h
>
#
endif
using
namespace
longport
;
using
namespace
longport
::quote
;
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
;
}
QuoteContext ctx;
QuoteContext::create
(config, [&](
auto
res) {
if
(!res) {
std::cout <<
"
failed to create quote context:
"
<< res.
status
().
message
()
<< std::endl;
return
;
}
ctx = res.
context
();
res.
context
().
set_on_candlestick
([](
auto
event) {
std::cout << event->
symbol
<<
"
timestamp=
"
<< event->
candlestick
.
timestamp
<<
"
close=
"
<< (
double
)event->
candlestick
.
close
<<
"
open=
"
<< (
double
)event->
candlestick
.
open
<<
"
high=
"
<< (
double
)event->
candlestick
.
high
<<
"
low=
"
<< (
double
)event->
candlestick
.
low
<<
"
volume=
"
<< event->
candlestick
.
volume
<<
"
turnover=
"
<< (
double
)event->
candlestick
.
turnover
<< std::endl;
});
res.
context
().
subscribe_candlesticks
(
"
AAPL.US
"
, Period::Min1, TradeSessions::All, [](
auto
res) {
if
(!res) {
std::cout <<
"
failed to subscribe quote:
"
<< res.
status
().
message
()
<< std::endl;
return
;
}
});
});
std::cin.
get
();
return
0
;
}
Back
|
FazBrowse Home
|
New Git URL