Open pedro-vicente opened 4 years ago
Hey there. You might not be linking with libcurl? -lcurl
If you're using cmake it should link if it finds it on your machine. Alternatively, you might need the curl development library, which is distinct from the end-user library on Ubuntu. apt-get install libcurl-dev
.
If neither of those work can you copy the output of the initial cmake command and the following make command? (As outlined in the readme?)
Thanks, and good luck.
I used
apt-get install libcurl4-openssl-dev
from
https://askubuntu.com/questions/78183/installing-curl-h-library
doing make VERBOSE=1
/usr/bin/c++ -rdynamic CMakeFiles/optional_app.dir/src/app/display.cpp.o CMakeFiles/optional_app.dir/src/app/main.cpp.o -o optional_app -lcurl -lcurses -lform liboptional.a
locate libcurl.a /usr/lib/x86_64-linux-gnu/libcurl.a
here's the complete cmake
-- The C compiler identification is GNU 7.5.0
-- The CXX compiler identification is GNU 7.5.0
-- Check for working C compiler: /usr/bin/cc
-- Check for working C compiler: /usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /usr/bin/c++
-- Check for working CXX compiler: /usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Curses: /usr/lib/x86_64-linux-gnu/libcurses.so
-- Found CURL: /usr/lib/x86_64-linux-gnu/libcurl.so (found version "7.58.0")
/usr/include/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libcurl.so
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pvn/git/trade/optional/bld/googletest-download
Scanning dependencies of target googletest
[ 11%] Creating directories for 'googletest'
[ 22%] Performing download step (git clone) for 'googletest'
Cloning into 'googletest-src'...
Already on 'master'
Your branch is up to date with 'origin/master'.
[ 33%] No patch step for 'googletest'
[ 44%] Performing update step for 'googletest'
Current branch master is up to date.
[ 55%] No configure step for 'googletest'
[ 66%] No build step for 'googletest'
[ 77%] No install step for 'googletest'
[ 88%] No test step for 'googletest'
[100%] Completed 'googletest'
[100%] Built target googletest
-- Found PythonInterp: /usr/bin/python (found version "2.7.17")
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Looking for pthread_create
-- Looking for pthread_create - not found
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
/usr/lib/x86_64-linux-gnu/libcurl.so/usr/lib/x86_64-linux-gnu/libcurses.so/usr/lib/x86_64-linux-gnu/libform.so
-- Configuring done
-- Generating done
-- Build files have been written to: /home/pvn/git/trade/optional/bld
the extra output was because I changed the Cmake script thanks
set(lib_dep ${lib_dep})
if(UNIX)
set(lib_dep ${lib_dep} ${CMAKE_THREAD_LIBS_INIT} ${CURL_LIBRARIES} ${CURSES_LIBRARIES})
endif()
message( ${lib_dep} )
target_link_libraries(
${app}
${lib_dep}
${backend}
${ui}
)
I had better luck doing a Windows port
and a fork at
https://github.com/pedro-vicente/optional
to build
cmake . ^
-DCURL_INCLUDE:PATH=K:\wx\curl-7.61.0\builds\libcurl-vc14-x64-debug-static-ipv6-sspi-winssl\include ^
-DCURL_LIBRARY:FILE=K:\wx\curl-7.61.0\builds\libcurl-vc14-x64-debug-static-ipv6-sspi-winssl\lib\libcurl_a_debug.lib ^
-DCURSES_INCLUDE:PATH=N:\PDCurses ^
-DCURSES_LIBRARY:FILE=N:\PDCurses\wincon\pdcurses.lib
Hmm yeah. I just did a clean build from a fresh clone and it generates the build files and makes the executable just fine. I'm not on Ubuntu though, I'm using Void.
If you're still wanting the linux version to run, what about your make command output? (With VERBOSE=1) I'm really surprised it's failing to link, since your cmake output says it found the lib.
projects/optional/build2 master ✔ 402d
▶ cmake ../
-- The C compiler identification is GNU 9.2.0
-- The CXX compiler identification is GNU 9.2.0
-- Check for working C compiler: /bin/cc
-- Check for working C compiler: /bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /bin/c++
-- Check for working CXX compiler: /bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
-- Found Curses: /usr/lib/libcurses.so
-- Found CURL: /usr/lib/libcurl.so (found version "7.68.0")
-- Configuring done
-- Generating done
-- Build files have been written to: /home/tegan/projects/optional/build2/googletest-download
make[1]: Entering directory '/home/tegan/projects/optional/build2/googletest-download'
make[2]: Entering directory '/home/tegan/projects/optional/build2/googletest-download'
Scanning dependencies of target googletest
make[2]: Leaving directory '/home/tegan/projects/optional/build2/googletest-download'
make[2]: Entering directory '/home/tegan/projects/optional/build2/googletest-download'
[ 11%] Creating directories for 'googletest'
[ 22%] Performing download step (git clone) for 'googletest'
Cloning into 'googletest-src'...
Already on 'master'
Your branch is up to date with 'origin/master'.
[ 33%] No patch step for 'googletest'
[ 44%] Performing update step for 'googletest'
Current branch master is up to date.
[ 55%] No configure step for 'googletest'
[ 66%] No build step for 'googletest'
[ 77%] No install step for 'googletest'
[ 88%] No test step for 'googletest'
[100%] Completed 'googletest'
make[2]: Leaving directory '/home/tegan/projects/optional/build2/googletest-download'
[100%] Built target googletest
make[1]: Leaving directory '/home/tegan/projects/optional/build2/googletest-download'
-- Found PythonInterp: /bin/python3.8 (found version "3.8.1")
-- Looking for pthread.h
-- Looking for pthread.h - found
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Failed
-- Looking for pthread_create in pthreads
-- Looking for pthread_create in pthreads - not found
-- Looking for pthread_create in pthread
-- Looking for pthread_create in pthread - found
-- Found Threads: TRUE
-- Configuring done
-- Generating done
-- Build files have been written to: /home/tegan/projects/optional/build2
and builds:
projects/optional/build2 master ✗ 402d ◒
▶ make
make[1]: Entering directory '/home/tegan/projects/optional/build2'
make[2]: Entering directory '/home/tegan/projects/optional/build2'
Scanning dependencies of target optional
make[2]: Leaving directory '/home/tegan/projects/optional/build2'
make[2]: Entering directory '/home/tegan/projects/optional/build2'
[ 6%] Building CXX object CMakeFiles/optional.dir/src/backend/account.cpp.o
[ 12%] Building CXX object CMakeFiles/optional.dir/src/backend/oauth.cpp.o
[ 18%] Building CXX object CMakeFiles/optional.dir/src/backend/rest.cpp.o
[ 25%] Building CXX object CMakeFiles/optional.dir/src/backend/option_chain.cpp.o
/home/tegan/projects/optional/src/backend/option_chain.cpp: In member function 'std::vector<std::__cxx11::basic_string<char> > Optional::OptionChain::puts()':
/home/tegan/projects/optional/src/backend/option_chain.cpp:122:1: warning: no return statement in function returning non-void [-Wreturn-type]
122 | }
| ^
[ 31%] Linking CXX static library liboptional.a
make[2]: Leaving directory '/home/tegan/projects/optional/build2'
[ 31%] Built target optional
make[2]: Entering directory '/home/tegan/projects/optional/build2'
Scanning dependencies of target optional_app
make[2]: Leaving directory '/home/tegan/projects/optional/build2'
make[2]: Entering directory '/home/tegan/projects/optional/build2'
[ 37%] Building CXX object CMakeFiles/optional_app.dir/src/app/display.cpp.o
/home/tegan/projects/optional/src/app/display.cpp: In member function 'std::string Optional::Display::popup_get_symbol_name()':
/home/tegan/projects/optional/src/app/display.cpp:342:1: warning: no return statement in function returning non-void [-Wreturn-type]
342 | }
| ^
[ 43%] Building CXX object CMakeFiles/optional_app.dir/src/app/main.cpp.o
[ 50%] Linking CXX executable optional_app
make[2]: Leaving directory '/home/tegan/projects/optional/build2'
[ 50%] Built target optional_app
make[2]: Entering directory '/home/tegan/projects/optional/build2'
Scanning dependencies of target gtest
make[2]: Leaving directory '/home/tegan/projects/optional/build2'
make[2]: Entering directory '/home/tegan/projects/optional/build2'
[ 56%] Building CXX object googletest-build/googletest/CMakeFiles/gtest.dir/src/gtest-all.cc.o
[ 62%] Linking CXX static library ../../lib/libgtest.a
make[2]: Leaving directory '/home/tegan/projects/optional/build2'
[ 62%] Built target gtest
make[2]: Entering directory '/home/tegan/projects/optional/build2'
Scanning dependencies of target gtest_main
make[2]: Leaving directory '/home/tegan/projects/optional/build2'
make[2]: Entering directory '/home/tegan/projects/optional/build2'
[ 68%] Building CXX object googletest-build/googletest/CMakeFiles/gtest_main.dir/src/gtest_main.cc.o
[ 75%] Linking CXX static library ../../lib/libgtest_main.a
make[2]: Leaving directory '/home/tegan/projects/optional/build2'
[ 75%] Built target gtest_main
make[2]: Entering directory '/home/tegan/projects/optional/build2'
Scanning dependencies of target optional_unit_tests
make[2]: Leaving directory '/home/tegan/projects/optional/build2'
make[2]: Entering directory '/home/tegan/projects/optional/build2'
[ 81%] Building CXX object CMakeFiles/optional_unit_tests.dir/tests/account_tests.cpp.o
[ 87%] Building CXX object CMakeFiles/optional_unit_tests.dir/tests/oauth_tests.cpp.o
[ 93%] Building CXX object CMakeFiles/optional_unit_tests.dir/tests/rest_tests.cpp.o
[100%] Linking CXX executable optional_unit_tests
make[2]: Leaving directory '/home/tegan/projects/optional/build2'
[100%] Built target optional_unit_tests
make[1]: Leaving directory '/home/tegan/projects/optional/build2'
projects/optional/build2 master ✗ 402d ◒
▶ ls -lah
total 3.2M
drwxr-xr-x 8 tegan tegan 4.0K Jun 23 23:06 .
drwxr-xr-x 9 tegan tegan 4.0K Jun 23 23:05 ..
-rw-r--r-- 1 tegan tegan 24K Jun 23 23:05 CMakeCache.txt
drwxr-xr-x 7 tegan tegan 4.0K Jun 23 23:06 CMakeFiles
-rw-r--r-- 1 tegan tegan 17K Jun 23 23:05 Makefile
drwxr-xr-x 2 tegan tegan 4.0K Jun 23 23:05 bin
-rw-r--r-- 1 tegan tegan 1.6K Jun 23 23:05 cmake_install.cmake
drwxr-xr-x 5 tegan tegan 4.0K Jun 23 23:05 googletest-build
drwxr-xr-x 4 tegan tegan 4.0K Jun 23 23:05 googletest-download
drwxr-xr-x 6 tegan tegan 4.0K Jun 23 23:05 googletest-src
drwxr-xr-x 2 tegan tegan 4.0K Jun 23 23:06 lib
-rw-r--r-- 1 tegan tegan 1008K Jun 23 23:05 liboptional.a
-rwxr-xr-x 1 tegan tegan 460K Jun 23 23:05 optional_app
-rwxr-xr-x 1 tegan tegan 1.7M Jun 23 23:06 optional_unit_tests
yes, the cmake output says it found the lib
here's make VERBOSE=1
/usr/bin/cmake -H/home/pvn/git/trade/optional -B/home/pvn/git/trade/optional/bld --check-build-system CMakeFiles/Makefile.cmake 0
/usr/bin/cmake -E cmake_progress_start /home/pvn/git/trade/optional/bld/CMakeFiles /home/pvn/git/trade/optional/bld/CMakeFiles/progress.marks
make -f CMakeFiles/Makefile2 all
make[1]: Entering directory '/home/pvn/git/trade/optional/bld'
make -f CMakeFiles/optional.dir/build.make CMakeFiles/optional.dir/depend
make[2]: Entering directory '/home/pvn/git/trade/optional/bld'
cd /home/pvn/git/trade/optional/bld && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pvn/git/trade/optional /home/pvn/git/trade/optional /home/pvn/git/trade/optional/bld /home/pvn/git/trade/optional/bld /home/pvn/git/trade/optional/bld/CMakeFiles/optional.dir/DependInfo.cmake --color=
Dependee "/home/pvn/git/trade/optional/bld/CMakeFiles/optional.dir/DependInfo.cmake" is newer than depender "/home/pvn/git/trade/optional/bld/CMakeFiles/optional.dir/depend.internal".
Dependee "/home/pvn/git/trade/optional/bld/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/home/pvn/git/trade/optional/bld/CMakeFiles/optional.dir/depend.internal".
Scanning dependencies of target optional
make[2]: Leaving directory '/home/pvn/git/trade/optional/bld'
make -f CMakeFiles/optional.dir/build.make CMakeFiles/optional.dir/build
make[2]: Entering directory '/home/pvn/git/trade/optional/bld'
[ 6%] Building CXX object CMakeFiles/optional.dir/src/backend/account.cpp.o
/usr/bin/c++ -I/home/pvn/git/trade/optional/external_libraries -I/usr/include/x86_64-linux-gnu -std=gnu++1z -o CMakeFiles/optional.dir/src/backend/account.cpp.o -c /home/pvn/git/trade/optional/src/backend/account.cpp
[ 12%] Building CXX object CMakeFiles/optional.dir/src/backend/oauth.cpp.o
/usr/bin/c++ -I/home/pvn/git/trade/optional/external_libraries -I/usr/include/x86_64-linux-gnu -std=gnu++1z -o CMakeFiles/optional.dir/src/backend/oauth.cpp.o -c /home/pvn/git/trade/optional/src/backend/oauth.cpp
[ 18%] Building CXX object CMakeFiles/optional.dir/src/backend/rest.cpp.o
/usr/bin/c++ -I/home/pvn/git/trade/optional/external_libraries -I/usr/include/x86_64-linux-gnu -std=gnu++1z -o CMakeFiles/optional.dir/src/backend/rest.cpp.o -c /home/pvn/git/trade/optional/src/backend/rest.cpp
[ 25%] Building CXX object CMakeFiles/optional.dir/src/backend/option_chain.cpp.o
/usr/bin/c++ -I/home/pvn/git/trade/optional/external_libraries -I/usr/include/x86_64-linux-gnu -std=gnu++1z -o CMakeFiles/optional.dir/src/backend/option_chain.cpp.o -c /home/pvn/git/trade/optional/src/backend/option_chain.cpp
[ 31%] Linking CXX static library liboptional.a
/usr/bin/cmake -P CMakeFiles/optional.dir/cmake_clean_target.cmake
/usr/bin/cmake -E cmake_link_script CMakeFiles/optional.dir/link.txt --verbose=1
/usr/bin/ar qc liboptional.a CMakeFiles/optional.dir/src/backend/account.cpp.o CMakeFiles/optional.dir/src/backend/oauth.cpp.o CMakeFiles/optional.dir/src/backend/rest.cpp.o CMakeFiles/optional.dir/src/backend/option_chain.cpp.o
/usr/bin/ranlib liboptional.a
make[2]: Leaving directory '/home/pvn/git/trade/optional/bld'
[ 31%] Built target optional
make -f CMakeFiles/optional_app.dir/build.make CMakeFiles/optional_app.dir/depend
make[2]: Entering directory '/home/pvn/git/trade/optional/bld'
cd /home/pvn/git/trade/optional/bld && /usr/bin/cmake -E cmake_depends "Unix Makefiles" /home/pvn/git/trade/optional /home/pvn/git/trade/optional /home/pvn/git/trade/optional/bld /home/pvn/git/trade/optional/bld /home/pvn/git/trade/optional/bld/CMakeFiles/optional_app.dir/DependInfo.cmake --color=
Dependee "/home/pvn/git/trade/optional/bld/CMakeFiles/optional_app.dir/DependInfo.cmake" is newer than depender "/home/pvn/git/trade/optional/bld/CMakeFiles/optional_app.dir/depend.internal".
Dependee "/home/pvn/git/trade/optional/bld/CMakeFiles/CMakeDirectoryInformation.cmake" is newer than depender "/home/pvn/git/trade/optional/bld/CMakeFiles/optional_app.dir/depend.internal".
Scanning dependencies of target optional_app
make[2]: Leaving directory '/home/pvn/git/trade/optional/bld'
make -f CMakeFiles/optional_app.dir/build.make CMakeFiles/optional_app.dir/build
make[2]: Entering directory '/home/pvn/git/trade/optional/bld'
[ 37%] Building CXX object CMakeFiles/optional_app.dir/src/app/display.cpp.o
/usr/bin/c++ -I/home/pvn/git/trade/optional/external_libraries -I/usr/include/x86_64-linux-gnu -I/home/pvn/git/trade/optional/src/backend -std=gnu++1z -o CMakeFiles/optional_app.dir/src/app/display.cpp.o -c /home/pvn/git/trade/optional/src/app/display.cpp
[ 43%] Building CXX object CMakeFiles/optional_app.dir/src/app/main.cpp.o
/usr/bin/c++ -I/home/pvn/git/trade/optional/external_libraries -I/usr/include/x86_64-linux-gnu -I/home/pvn/git/trade/optional/src/backend -std=gnu++1z -o CMakeFiles/optional_app.dir/src/app/main.cpp.o -c /home/pvn/git/trade/optional/src/app/main.cpp
[ 50%] Linking CXX executable optional_app
/usr/bin/cmake -E cmake_link_script CMakeFiles/optional_app.dir/link.txt --verbose=1
/usr/bin/c++ -rdynamic CMakeFiles/optional_app.dir/src/app/display.cpp.o CMakeFiles/optional_app.dir/src/app/main.cpp.o -o optional_app -lcurl -lcurses -lform liboptional.a
liboptional.a(rest.cpp.o): In function `Optional::Rest::Rest()':
rest.cpp:(.text+0x9c): undefined reference to `curl_global_init'
liboptional.a(rest.cpp.o): In function `Optional::Rest::~Rest()':
rest.cpp:(.text+0xb1): undefined reference to `curl_global_cleanup'
liboptional.a(rest.cpp.o): In function `Optional::Rest::post(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool&, bool)':
rest.cpp:(.text+0x121): undefined reference to `curl_easy_init'
rest.cpp:(.text+0x156): undefined reference to `curl_slist_append'
rest.cpp:(.text+0x174): undefined reference to `curl_easy_setopt'
rest.cpp:(.text+0x199): undefined reference to `curl_easy_setopt'
rest.cpp:(.text+0x1b4): undefined reference to `curl_easy_setopt'
rest.cpp:(.text+0x1d1): undefined reference to `curl_easy_setopt'
rest.cpp:(.text+0x1eb): undefined reference to `curl_easy_setopt'
liboptional.a(rest.cpp.o):rest.cpp:(.text+0x210): more undefined references to `curl_easy_setopt' follow
liboptional.a(rest.cpp.o): In function `Optional::Rest::post(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool&, bool)':
rest.cpp:(.text+0x25a): undefined reference to `curl_easy_perform'
rest.cpp:(.text+0x276): undefined reference to `curl_easy_cleanup'
liboptional.a(rest.cpp.o): In function `Optional::Rest::get(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool&, bool)':
rest.cpp:(.text+0x31b): undefined reference to `curl_easy_init'
rest.cpp:(.text+0x350): undefined reference to `curl_slist_append'
rest.cpp:(.text+0x36e): undefined reference to `curl_easy_setopt'
rest.cpp:(.text+0x393): undefined reference to `curl_easy_setopt'
rest.cpp:(.text+0x3b0): undefined reference to `curl_easy_setopt'
rest.cpp:(.text+0x3ca): undefined reference to `curl_easy_setopt'
rest.cpp:(.text+0x3eb): undefined reference to `curl_easy_setopt'
liboptional.a(rest.cpp.o):rest.cpp:(.text+0x408): more undefined references to `curl_easy_setopt' follow
liboptional.a(rest.cpp.o): In function `Optional::Rest::get(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >, bool&, bool)':
rest.cpp:(.text+0x414): undefined reference to `curl_easy_perform'
rest.cpp:(.text+0x430): undefined reference to `curl_easy_cleanup'
liboptional.a(rest.cpp.o): In function `Optional::Rest::url_encoding(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> >)':
rest.cpp:(.text+0x495): undefined reference to `curl_easy_init'
rest.cpp:(.text+0x501): undefined reference to `curl_easy_escape'
rest.cpp:(.text+0x566): undefined reference to `curl_free'
rest.cpp:(.text+0x572): undefined reference to `curl_easy_cleanup'
collect2: error: ld returned 1 exit status
CMakeFiles/optional_app.dir/build.make:124: recipe for target 'optional_app' failed
make[2]: *** [optional_app] Error 1
make[2]: Leaving directory '/home/pvn/git/trade/optional/bld'
CMakeFiles/Makefile2:67: recipe for target 'CMakeFiles/optional_app.dir/all' failed
make[1]: *** [CMakeFiles/optional_app.dir/all] Error 2
make[1]: Leaving directory '/home/pvn/git/trade/optional/bld'
Makefile:129: recipe for target 'all' failed
make: *** [all] Error 2
but the linux build is not important, just wanted a build to see the API working the goal is to use ASIO to make REST requests, not curl thanks
running the app on Windows with
./optional_app
where
Failed to load valid refresh token from disk. Please manually reauthenticate.
Steps:
1. Go to this url: https://auth.tdameritrade.com/auth?response_type=code&redirect_uri=https://localhost&client_id=<CLIENT_ID>@AMER.OAUTHAP
2. Authenticate with your TD Ameritrade account to approve the app.
3. The result will be a code in your address bar and a failed page load @ https://localhost. Paste entire address bar contents below:
:
but when I set that URL in a browser, I get a response from the TD website
A third-party application may be attempting to make unauthorized access to your account.
following
https://www.reddit.com/r/algotrading/comments/c81vzq/td_ameritrade_api_access_2019_guide/
I was able to get the access tokens
Yes, as per the readme oauth is broken since they changed the system after the schwab merge. This repo is out of date re: that.
Glad you got it working though! Yes it was very much experimental, and I've actually moved away from TD over to IBKR for algo stuff.
Best of luck.
TD is actually very good (not so about IBKR); but I am only using the REST interface
https://developer.tdameritrade.com/price-history/apis/get/marketdata/%7Bsymbol%7D/pricehistory
where the OAuth User ID is hardcoded , but generated by the method above
so, I just do this with asio
/////////////////////////////////////////////////////////////////////////////////////////////////////
//td_query
//https://developer.tdameritrade.com/price-history/apis/get/marketdata/%7Bsymbol%7D/pricehistory
//v1/marketdata/HD/pricehistory?apikey=KEY&periodType=day&period=2&frequencyType=minute&frequency=30
//v1/marketdata/XYZ/pricehistory?periodType=month&frequencyType=daily&startDate=1464148800000&endDate=1464825600000
/////////////////////////////////////////////////////////////////////////////////////////////////////
std::string td_query(const std::string& ticker,
const std::string& periodType,
int period,
const std::string& frequencyType,
int frequency,
const std::string& startDate,
const std::string& endDate)
{
std::stringstream ss;
ss << "/v1/marketdata/" << ticker << "/pricehistory?apikey=KEY"
<< "&periodType=" << periodType
<< "&frequencyType=" << frequencyType
<< "&frequency=" << frequency
<< "&startDate=" << startDate
<< "&endDate=" << endDate
;
then construct a HTTP GET with the above string as path
std::string http;
http += "GET ";
http += path;
http += " HTTP/1.0\r\n";
http += "Host: " + host;
http += "\r\n";
http += "Accept: */*\r\n";
http += "Connection: close\r\n\r\n";
asio::write(socket, asio::buffer(http, http.size()));
I'll be happy to share the code , if interested
Yeah I left TD before they dropped commissions since I got a better rate at IBKR, and now that I've moved over it's too much technical debt on my end to switch back, I think. :smile: The API at IBKR is more complicated, but also more powerful in ways. TD was quite nice though, and the JSON was easy to parse.
And yes, that looks very clean. This project actually started out as a school project for my undergrad, and grew into a trading side hobby. I went with curl because it was all I knew but AISO looks quite nice, and more in line with modern C++. I'll definitely give it a look, thanks.
curl is awful from a programmer's point of view
I recommend the ASIO standalone (header only) outside of boost very socket level orientated, but that is good i.m.o
for JSON we use the excellent
https://github.com/nlohmann/json
with asio, and JSON for modern C++ I can parse the TD JSON with few lines of code
TD has a good app for iOS , ThinkOrSwim
I sent you email
I get on linux ubuntu
rest.cpp:(.text+0x495): undefined reference to `curl_easy_init'
curl packages were installed