Skip to content

Commit

Permalink
Merge pull request #50 from AsyncAlgoTrading/perspective
Browse files Browse the repository at this point in the history
Starting on Perspective integration
  • Loading branch information
timkpaine committed Jun 4, 2020
2 parents 7afe5cf + 390a2d6 commit be32498
Show file tree
Hide file tree
Showing 212 changed files with 6,034 additions and 7,189 deletions.
19 changes: 0 additions & 19 deletions .bettercodehub.yml

This file was deleted.

2 changes: 1 addition & 1 deletion .bumpversion.cfg
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[bumpversion]
current_version = (0, 0, 3, 'final', 0)
current_version = (0, 1, 0, 'final', 0)
commit = False
tag = False
parse = (?P<major>\d+)\,\ (?P<minor>\d+)\,\ (?P<patch>\d+)\,\ \'(?P<release>\S+)\'\,\ (?P<build>\d+)
Expand Down
67 changes: 67 additions & 0 deletions .clang-format
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
Language: Cpp
# BasedOnStyle: WebKit
AccessModifierOffset: -1
AlignAfterOpenBracket: false
AlignConsecutiveAssignments: false
# AlignConsecutiveMacros: true
AlignEscapedNewlinesLeft: false
AlignOperands: false
AlignTrailingComments: true
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AllowShortFunctionsOnASingleLine: All
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AlwaysBreakAfterDefinitionReturnType: true
AlwaysBreakBeforeMultilineStrings: false
AlwaysBreakTemplateDeclarations: true
BinPackArguments: true
BinPackParameters: true
BreakBeforeBinaryOperators: All
BreakBeforeBraces: Attach
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: true
ColumnLimit: 120
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 2
ContinuationIndentWidth: 2
Cpp11BracedListStyle: true
DerivePointerAlignment: false
DisableFormat: false
ExperimentalAutoDetectBinPacking: false
ForEachMacros: [ foreach, Q_FOREACH, BOOST_FOREACH ]
IndentCaseLabels: true
IndentWidth: 2
IndentWrappedFunctionNames: false
KeepEmptyLinesAtTheStartOfBlocks: true
MacroBlockBegin: ''
MacroBlockEnd: ''
MaxEmptyLinesToKeep: 1
NamespaceIndentation: Inner
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: true
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakFirstLessLess: 120
PenaltyBreakString: 1000
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
SpaceAfterCStyleCast: false
SpaceBeforeAssignmentOperators: true
SpaceBeforeParens: ControlStatements
SpaceInEmptyParentheses: false
SpacesBeforeTrailingComments: 2
SpacesInAngles: false
SpacesInContainerLiterals: true
SpacesInCStyleCastParentheses: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
Standard: Cpp11
TabWidth: 2
UseTab: Never
SortIncludes: false
...
1 change: 1 addition & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
docs/img/orderbook2.gif filter=lfs diff=lfs merge=lfs -text
12 changes: 10 additions & 2 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,9 @@ target/
horizon

*.DS_Store
dashboard_server/node_modules/
js/node_modules/
js/build/
aat/ui/assets/static/
notes.txt
ref
coinbase.sh
Expand All @@ -82,4 +84,10 @@ logo.png
coverage
experiments
aat_test
docs/api
docs/api
docs/index.md
tornado_sqlalchemy_login
aat.db
python_junit.xml
.mypy_cache
.vscode
45 changes: 33 additions & 12 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,11 @@ function (build_dep name cmake_file)

include_directories(${CMAKE_BINARY_DIR}/${name}-src/extras/${name}/include)
include_directories(${CMAKE_BINARY_DIR}/${name}-src/include)

if(${name} STREQUAL "date")
include_directories(${CMAKE_BINARY_DIR}/${name}-src/include/date)
endif()

include_directories(${CMAKE_BINARY_DIR}/${name}-src)
endfunction()
##############################
Expand Down Expand Up @@ -167,7 +172,6 @@ endif()
#########################
# PYTHON BINDINGS BUILD #
#########################
include_directories("${AAT_PYTHON_SRC}/perspective/include")
if(MANYLINUX)
# Manylinux docker images have no shared libraries
# The instead use a statically built python.
Expand All @@ -188,6 +192,10 @@ include_directories( ${Python_INCLUDE_DIRS} )
# already found from before
find_package(Boost)

build_dep("json" "${AAT_CMAKE_MODULE_PATH}/Json.txt.in")
build_dep("json-pybind" "${AAT_CMAKE_MODULE_PATH}/Json_pybind.txt.in")
build_dep("date" "${AAT_CMAKE_MODULE_PATH}/date.txt.in")

if(MACOS)
# on mac, use the vanilla pybind11 finder
find_package(pybind11)
Expand Down Expand Up @@ -258,33 +266,46 @@ set(CMAKE_SHARED_LIBRARY_PREFIX "")

include_directories("${CMAKE_SOURCE_DIR}/cpp/include")

set(SOURCE_FILES
${CMAKE_SOURCE_DIR}/cpp/src/config/enums.cpp
${CMAKE_SOURCE_DIR}/cpp/src/config/parser.cpp
${CMAKE_SOURCE_DIR}/cpp/src/core/instrument/instrument.cpp
${CMAKE_SOURCE_DIR}/cpp/src/core/exchange/exchange.cpp
${CMAKE_SOURCE_DIR}/cpp/src/core/models/data.cpp
${CMAKE_SOURCE_DIR}/cpp/src/core/models/event.cpp
${CMAKE_SOURCE_DIR}/cpp/src/core/models/order.cpp
${CMAKE_SOURCE_DIR}/cpp/src/core/models/trade.cpp
${CMAKE_SOURCE_DIR}/cpp/src/core/order_book/price_level.cpp
${CMAKE_SOURCE_DIR}/cpp/src/core/order_book/collector.cpp
${CMAKE_SOURCE_DIR}/cpp/src/core/order_book/order_book.cpp
${CMAKE_SOURCE_DIR}/cpp/src/python/binding.cpp
)

########################
# Python extra targets #
########################
add_library(binding SHARED
${CMAKE_SOURCE_DIR}/cpp/src/binding.cpp
${HEADER_FILES})
add_library(binding SHARED ${SOURCE_FILES})
set_target_properties(binding PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/aat)
target_link_libraries(binding ${PYTHON_LIBRARIES})

add_library(_enums SHARED
${CMAKE_SOURCE_DIR}/cpp/src/enums.cpp)
set_target_properties(_enums PROPERTIES
LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/aat)
# add_library(_enums SHARED
# ${CMAKE_SOURCE_DIR}/cpp/src/enums.cpp)
# set_target_properties(_enums PROPERTIES
# LIBRARY_OUTPUT_DIRECTORY ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/aat)
# target_link_libraries(_enums binding)
target_link_libraries(_enums ${PYTHON_LIBRARIES})
# target_link_libraries(_enums ${PYTHON_LIBRARIES})

## Copy in place for testing
add_custom_command(TARGET binding POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:binding> ${CMAKE_SOURCE_DIR}/aat/)
add_custom_command(TARGET _enums POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:_enums> ${CMAKE_SOURCE_DIR}/aat/)
# add_custom_command(TARGET _enums POST_BUILD COMMAND ${CMAKE_COMMAND} -E copy $<TARGET_FILE:_enums> ${CMAKE_SOURCE_DIR}/aat/)
########################

if(CPP_BUILD_STRICT AND NOT WIN32)
target_compile_options(binding PRIVATE -Wall -Werror)
target_compile_options(binding PRIVATE $<$<CONFIG:DEBUG>:-fPIC -O0>)
target_compile_options(_enums PRIVATE -Wall -Werror)
target_compile_options(_enums PRIVATE $<$<CONFIG:DEBUG>:-fPIC -O0>)
# target_compile_options(_enums PRIVATE -Wall -Werror)
# target_compile_options(_enums PRIVATE $<$<CONFIG:DEBUG>:-fPIC -O0>)
endif()


Expand Down
1 change: 0 additions & 1 deletion CONTRIBUTING.md

This file was deleted.

81 changes: 50 additions & 31 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,59 +1,77 @@
CONFIG=./config/backtest_multi.cfg
EXCHANGE=gdax
CONFIG=./config/synthetic.cfg


runconfig: build ## Clean and make target, run target
python3 -m aat --config=$(CONFIG)
run: build ## Clean and make target, run target
python3 -m aat $(CONFIG)

run: clean build ## Clean and make target, run target
python3 -m aat --live --verbose=$(VERBOSE) --exchange=$(EXCHANGE)
runcpp: build ## Clean and make target, run target
AAT_USE_CPP=1 python3 -m aat $(CONFIG)

sandbox: build ## Clean and make target, run target
python3 -m aat --sandbox --verbose=$(VERBOSE) -exchange=$(EXCHANGE)

backtest_config: ## Clean and make target, run backtest
python3 -m aat --config=./config/backtest_gemini.cfg

backtest: ## Clean and make target, run backtest
python3 -m aat --backtest --verbose=$(VERBOSE) --exchange=$(EXCHANGE)

backtest_inline: ## Clean and make target, run backtest, plot in terminal
bash -c "export MPLBACKEND=\"module://itermplot\"; export ITERMPLOT=\"rv\"; python3 -m aat backtest $(VERBOSE) $(EXCHANGE)"
rundebug: debug ## Clean and make debug target, run target
python3 -m aat $(CONFIG)

buildext: ## build the package extensions
python3 setup.py build_ext

build: ## build the package
python3 setup.py build

debug: ## build debug build of the package
DEBUG=1 python3 setup.py build

js: ## build the js assets
cd js; yarn build

install: ## install the package
pip3 install .
python3 -m pip install .

tests: build testpy ## Make unit tests

testpy: ## Make unit tests
python3 -m pytest -vvv ./aat/tests --cov=aat --junitxml=python_junit.xml --cov-report=xml --cov-branch

tests: ## Clean and Make unit tests
python3 -m pytest -v ./aat/tests --cov=aat --junitxml=python_junit.xml --cov-report=xml --cov-branch
testpycpp: ## Make unit tests
# AAT_USE_CPP=1 python3 -m pytest -vvv ./aat/tests --cov=aat --junitxml=python_junit.xml --cov-report=xml --cov-branch --capture=no
AAT_USE_CPP=1 python3 -m pytest -s ./aat/tests

test_verbose: ## run the tests with full output
@ python3 -m pytest -vv ./aat/tests --cov=aat --junitxml=python_junit.xml --cov-report=xml --cov-branch
testjs: ## Make js tests
cd js; yarn test

lint: ## run linter
python3 -m flake8 aat
lint: lintpy lintjs lintcpp ## run all linters

fix: ## run autopep8/tslint fix
python3 -m autopep8 --in-place -r -a -a aat/
lintpy: ## run python linter
python3 -m flake8 aat setup.py

lintjs: ## run js linter
cd js; yarn lint

lintcpp: ## run cpp linter
cpplint --linelength=120 --recursive cpp/

fix: fixpy fixjs fixcpp ## run all fixers

fixpy: ## run autopep8 fix
python3 -m autopep8 --in-place -r -a -a aat/ setup.py

fixcpp: ## run clang-format
clang-format -i -style=file `find ./cpp -name "*.*pp"`

fixjs: ## run clang-format
cd js; yarn fix

annotate: ## MyPy type annotation check
mypy -s aat
python3 -m mypy aat

annotate_l: ## MyPy type annotation check - count only
mypy -s aat | wc -l
python3 -m mypy -s aat | wc -l

docs: ## Build the sphinx docs
make -C docs html
open ./docs/_build/html/index.html

dist: ## dist to pypi
rm -rf dist build
python3 setup.py sdist
python3 setup.py bdist_wheel
python3 setup.py sdist bdist_wheel
twine check dist/* && twine upload dist/*

clean: ## clean the repository
Expand All @@ -71,4 +89,5 @@ help:
print-%:
@echo '$*=$($*)'

.PHONY: clean run runconfig sandbox backtest backtest_config test tests test_verbose help install docs data dist js build buildext boost
.PHONY: run buildext build js install tests lint fix docs dist clean help fixcpp

0 comments on commit be32498

Please sign in to comment.