Skip to content

Commit

Permalink
update release script for public PyPi package, refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
maartenscholl committed Sep 29, 2021
1 parent 0f282be commit 4a4c4c7
Show file tree
Hide file tree
Showing 11 changed files with 111 additions and 103 deletions.
11 changes: 7 additions & 4 deletions .github/workflows/python-publish-pypi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ jobs:
# overwrite the config file that wrongly captures the Python installation directory
- name: "[MacOS] Install boost"
run: |
wget https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.gz > /dev/null 2>&1
wget https://jztkft.dl.sourceforge.net/project/boost/boost/1.76.0/boost_1_76_0.tar.gz > /dev/null 2>&1
tar -xzf boost_1_*
cd boost_1_*
./bootstrap.sh > /dev/null 2>&1
Expand Down Expand Up @@ -165,7 +165,7 @@ jobs:
CIBW_BUILD: 'cp3${{matrix.python_minor_version}}-manylinux*'
CIBW_SKIP: '*i686'
CIBW_BUILD_VERBOSITY: 3
CIBW_BEFORE_ALL_LINUX: 'yum install -y wget epel-release gsl gsl-devel && wget https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.gz > /dev/null 2>&1 && tar -xzf boost_1_* && cd boost_1_* && ./bootstrap.sh && echo "using gcc ;" > project-config.jam && echo "project : default-build <toolset>gcc ;" >> project-config.jam && echo "import python ;" >> project-config.jam && echo "using python : 3.${{matrix.python_minor_version}} : /opt/python/cp3${{matrix.python_minor_version}}-cp3${{matrix.python_minor_version}}m/bin/python : /opt/python/cp3${{matrix.python_minor_version}}-cp3${{matrix.python_minor_version}}m/include/python3.${{matrix.python_minor_version}}m/ : /opt/python/cp3${{matrix.python_minor_version}}-cp3${{matrix.python_minor_version}}m/lib/python3.${{matrix.python_minor_version}}/ ;" >> project-config.jam && cat project-config.jam && ./b2 install -j 8 --with=all > /dev/null 2>&1 && cd ~ && wget http://www.met.reading.ac.uk/clouds/adept/adept-2.0.5.tar.gz && tar -xf adept-2.0.5.tar.gz && cd adept-2.0.5/ && ./configure && make -j2 && make install && cd include && ./create_adept_source_header && cp adept_source.h /usr/local/include/'
CIBW_BEFORE_ALL_LINUX: 'yum install -y wget epel-release gsl gsl-devel && wget https://jztkft.dl.sourceforge.net/project/boost/boost/1.76.0/boost_1_76_0.tar.gz > /dev/null 2>&1 && tar -xzf boost_1_* && cd boost_1_* && ./bootstrap.sh && echo "using gcc ;" > project-config.jam && echo "project : default-build <toolset>gcc ;" >> project-config.jam && echo "import python ;" >> project-config.jam && echo "using python : 3.${{matrix.python_minor_version}} : /opt/python/cp3${{matrix.python_minor_version}}-cp3${{matrix.python_minor_version}}m/bin/python : /opt/python/cp3${{matrix.python_minor_version}}-cp3${{matrix.python_minor_version}}m/include/python3.${{matrix.python_minor_version}}m/ : /opt/python/cp3${{matrix.python_minor_version}}-cp3${{matrix.python_minor_version}}m/lib/python3.${{matrix.python_minor_version}}/ ;" >> project-config.jam && cat project-config.jam && ./b2 install -j 8 --with=all > /dev/null 2>&1 && cd ~ && wget http://www.met.reading.ac.uk/clouds/adept/adept-2.0.5.tar.gz && tar -xf adept-2.0.5.tar.gz && cd adept-2.0.5/ && ./configure && make -j2 && make install && cd include && ./create_adept_source_header && cp adept_source.h /usr/local/include/'
run: |
python -m cibuildwheel --output-dir distribution --platform linux
python -m twine upload distribution/*
Expand All @@ -181,7 +181,7 @@ jobs:
CIBW_BUILD: 'cp3${{matrix.python_minor_version}}-manylinux*'
CIBW_SKIP: '*i686'
CIBW_BUILD_VERBOSITY: 3
CIBW_BEFORE_ALL_LINUX: 'yum install -y wget epel-release gsl gsl-devel && wget https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.gz > /dev/null 2>&1 && tar -xzf boost_1_* && cd boost_1_* && ./bootstrap.sh && echo "using gcc ;" > project-config.jam && echo "project : default-build <toolset>gcc ;" >> project-config.jam && echo "import python ;" >> project-config.jam && echo "using python : 3.${{matrix.python_minor_version}} : /opt/python/cp3${{matrix.python_minor_version}}-cp3${{matrix.python_minor_version}}/bin/python : /opt/python/cp3${{matrix.python_minor_version}}-cp3${{matrix.python_minor_version}}/include/python3.${{matrix.python_minor_version}}/ : /opt/python/cp3${{matrix.python_minor_version}}-cp3${{matrix.python_minor_version}}/lib/python3.${{matrix.python_minor_version}}/ ;" >> project-config.jam && cat project-config.jam && ./b2 install -j 8 --with=all > /dev/null 2>&1 && cd ~ && wget http://www.met.reading.ac.uk/clouds/adept/adept-2.0.5.tar.gz && tar -xf adept-2.0.5.tar.gz && cd adept-2.0.5/ && ./configure && make -j2 && make install && cd include && ./create_adept_source_header && cp adept_source.h /usr/local/include/'
CIBW_BEFORE_ALL_LINUX: 'yum install -y wget epel-release gsl gsl-devel && wget https://jztkft.dl.sourceforge.net/project/boost/boost/1.76.0/boost_1_76_0.tar.gz > /dev/null 2>&1 && tar -xzf boost_1_* && cd boost_1_* && ./bootstrap.sh && echo "using gcc ;" > project-config.jam && echo "project : default-build <toolset>gcc ;" >> project-config.jam && echo "import python ;" >> project-config.jam && echo "using python : 3.${{matrix.python_minor_version}} : /opt/python/cp3${{matrix.python_minor_version}}-cp3${{matrix.python_minor_version}}/bin/python : /opt/python/cp3${{matrix.python_minor_version}}-cp3${{matrix.python_minor_version}}/include/python3.${{matrix.python_minor_version}}/ : /opt/python/cp3${{matrix.python_minor_version}}-cp3${{matrix.python_minor_version}}/lib/python3.${{matrix.python_minor_version}}/ ;" >> project-config.jam && cat project-config.jam && ./b2 install -j 8 --with=all > /dev/null 2>&1 && cd ~ && wget http://www.met.reading.ac.uk/clouds/adept/adept-2.0.5.tar.gz && tar -xf adept-2.0.5.tar.gz && cd adept-2.0.5/ && ./configure && make -j2 && make install && cd include && ./create_adept_source_header && cp adept_source.h /usr/local/include/'
run: |
python -m cibuildwheel --output-dir distribution --platform linux
python -m twine upload distribution/*
Expand All @@ -203,7 +203,10 @@ jobs:

- name: "[Windows] Install boost"
run: |
wget https://boostorg.jfrog.io/artifactory/main/release/1.76.0/source/boost_1_76_0.tar.gz -UseBasicParsing -OutFile boost_1_76_0.tar.gz
remove-item alias:\wget
choco install wget --no-progress
dir
wget -N https://jztkft.dl.sourceforge.net/project/boost/boost/1.76.0/boost_1_76_0.tar.gz
tar -xzf boost_1_76_0.tar.gz
cd boost_1_76_0
./bootstrap.bat --prefix=C:/Boost
Expand Down
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ Example taken from: https://github.com/INET-Complexity/ESL/blob/master/example/o
using namespace esl;
using namespace esl::economics;
using namespace esl::economics::markets::order_book;
using esl::economics::markets::order_book::limit_order_message;
using esl::economics::markets::order_book::limit_order;
using namespace esl::economics::markets::order_book::statically_allocated;

// trades in this market are in multiples of the lot size
Expand All @@ -124,23 +124,23 @@ constexpr size_t lot_size = 100;
// note that ESL uses fixed-precision for prices internally, and that the use of
// a floating point type here relies on the developer understanding the
// conversion.
limit_order_message create( double p
limit_order create( double p
, size_t q = 1000
, limit_order_message::side_t side = limit_order_message::side_t::sell)
, limit_order::side_t side = limit_order::side_t::sell)
{
// substitute your own stock ticker type here
esl::economics::markets::ticker ticker_dummy_;

// substitute your agent id
identity<agent> owner_dummy_;

return limit_order_message
return limit_order
( ticker_dummy_
, owner_dummy_
, side
, markets::quote(price(p, currencies::USD), lot_size * currencies::USD.denominator)
, q
,limit_order_message::lifetime_t::good_until_cancelled
,limit_order::lifetime_t::good_until_cancelled
);
}

Expand All @@ -158,8 +158,8 @@ int main(int argc, char** argv) {
// creates the order book
auto book_ = std::make_unique<book<max_orders_>>(min_, max_);

book_->insert(create(4.75, 500, limit_order_message::side_t::buy));
book_->insert(create(4.75, 750, limit_order_message::side_t::sell));
book_->insert(create(4.75, 500, limit_order::side_t::buy));
book_->insert(create(4.75, 750, limit_order::side_t::sell));

// use book_.reports to view the output generated by the order book, which contains
// 1. the placement of the buy order
Expand Down
4 changes: 2 additions & 2 deletions esl/economics/markets/order_book/basic_book.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ namespace esl::economics::markets::order_book {
///
/// \brief Extracts the order and places it in the book.
///
/// \param order limit_order_message sent by the market participant
virtual void insert(const limit_order_message &order) = 0;
/// \param order limit_order sent by the market participant
virtual void insert(const limit_order &order) = 0;

///
/// \brief Cancels a placed order by its order_identifier
Expand Down
20 changes: 10 additions & 10 deletions esl/economics/markets/order_book/binary_tree_order_book.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@ namespace esl::economics::markets::order_book {
namespace dynamically_allocated {

/*
bool book::insert(const limit_order_message &order)
bool book::insert(const limit_order &order)
{
if(order.side == limit_order_message::buy) {
if(order.side == limit_order::buy) {
index assigned_ = next_++;
orders_bid.insert(bid_t::value_type( order.limit
, std::make_pair(assigned_, order) ));
} else if(order.side == limit_order_message::sell) {
} else if(order.side == limit_order::sell) {
index assigned_ = next_++;
orders_ask.insert(ask_t::value_type( order.limit
, std::make_pair(assigned_, order)));
Expand All @@ -65,7 +65,7 @@ namespace esl::economics::markets::order_book {
}
}
bool book::match(std::queue<limit_order_message> &orders)
bool book::match(std::queue<limit_order> &orders)
{
while(true) {
if(orders_bid.empty() || orders_ask.empty()) {
Expand All @@ -76,8 +76,8 @@ namespace esl::economics::markets::order_book {
auto i_ask_ = orders_ask.begin_();
if(i_bid_->second.second.limit >= i_ask_->second.second.limit) {
limit_order_message &bid = i_bid_->second.second;
limit_order_message &ask = i_ask_->second.second;
limit_order &bid = i_bid_->second.second;
limit_order &ask = i_ask_->second.second;
match(bid, ask);
orders.push(bid);
Expand All @@ -96,17 +96,17 @@ namespace esl::economics::markets::order_book {
}
}
limit_order_message &book::find(limit_order_message::side_t side,
limit_order &book::find(limit_order::side_t side,
//const esl::identity<esl::law::property> &
index identifier)
{
if(side == limit_order_message::buy) {
if(side == limit_order::buy) {
for(auto &i : orders_bid) {
if(i.second.first == identifier) {
return i.second.second;
}
}
} else if(side == limit_order_message::sell) {
} else if(side == limit_order::sell) {
for(auto &i : orders_ask) {
if(i.second.first == identifier) {
return i.second.second;
Expand All @@ -117,7 +117,7 @@ namespace esl::economics::markets::order_book {
throw std::exception();
}
void book::match(limit_order_message &bid, limit_order_message &ask)
void book::match(limit_order &bid, limit_order &ask)
{
auto price = ask.limit;
auto quantity_ = std::min(bid.quantity, ask.quantity);
Expand Down
8 changes: 4 additions & 4 deletions esl/economics/markets/order_book/binary_tree_order_book.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,12 +64,12 @@ namespace esl::economics::markets::order_book {
}

typedef std::multimap< quote
, std::pair<basic_book::order_identifier , limit_order_message>
, std::pair<basic_book::order_identifier , limit_order>
, std::greater<>
> bid_t;

typedef std::multimap< quote
, std::pair<basic_book::order_identifier , limit_order_message>
, std::pair<basic_book::order_identifier , limit_order>
, std::less<>
> ask_t;

Expand Down Expand Up @@ -97,9 +97,9 @@ namespace esl::economics::markets::order_book {
/// \brief
///
/// \param order
void insert(const limit_order_message &order) override
void insert(const limit_order &order) override
{
if(limit_order_message::side_t::buy == order.side){
if(limit_order::side_t::buy == order.side){
auto remainder_ = order.quantity;
for( auto i = orders_ask.begin()
; i != orders_ask.end() && order.limit >= i->first
Expand Down
6 changes: 3 additions & 3 deletions esl/economics/markets/order_book/execution_report.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ namespace esl::economics::markets::order_book {
///
/// \brief Buy or sell
///
limit_order_message::side_t side;
limit_order::side_t side;

///
/// \brief Because a report can apply to only a part of the order,
Expand All @@ -70,8 +70,8 @@ namespace esl::economics::markets::order_book {
identity<agent> owner;


execution_report( state_t state
, limit_order_message::side_t side
execution_report(state_t state
, limit_order::side_t side
, std::uint32_t quantity
, std::uint64_t identifier
, const quote& limit
Expand Down
10 changes: 5 additions & 5 deletions esl/economics/markets/order_book/matching_engine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ namespace esl::economics::markets::order_book {
///
/// \param order
/// \return
void insert(const limit_order_message &order)
void insert(const limit_order &order)
{
auto i = books.find(order.symbol);

Expand All @@ -85,8 +85,8 @@ namespace esl::economics::markets::order_book {
/// \param side
/// \param id
/// \return
limit_order_message &find( const ticker& symbol
, limit_order_message::side_t side
limit_order &find( const ticker& symbol
, limit_order::side_t side
, const esl::identity<esl::law::property>& identifier)
{
auto i = books.find(symbol);
Expand All @@ -97,7 +97,7 @@ namespace esl::economics::markets::order_book {
}
bool match(const ticker &symbol, std::queue<limit_order_message> &orders)
bool match(const ticker &symbol, std::queue<limit_order> &orders)
{
auto i = books.find(symbol);
if(i == books.end()) {
Expand All @@ -108,7 +108,7 @@ namespace esl::economics::markets::order_book {
return i->second->insert(orders);
}
bool match(std::queue<limit_order_message> &orders)
bool match(std::queue<limit_order> &orders)
{
for(auto & book : books) {
book.second->insert(orders);
Expand Down
17 changes: 11 additions & 6 deletions esl/economics/markets/order_book/order.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@

namespace esl::economics::markets::order_book {

class limit_order_message
class limit_order
{
private:
public:
Expand All @@ -62,7 +62,7 @@ namespace esl::economics::markets::order_book {

std::uint32_t quantity;

limit_order_message ( ticker symbol
limit_order (ticker symbol
, const identity<agent> &owner
, side_t side
, const quote& limit
Expand All @@ -80,9 +80,14 @@ namespace esl::economics::markets::order_book {
}


[[nodiscard]] constexpr bool operator == (const limit_order_message &o) const
[[nodiscard]] constexpr bool operator == (const limit_order &o) const
{
return lifetime == o.lifetime && side == o.side && symbol == o.symbol && owner == o.owner & limit == o.limit && quantity == o.quantity;
return lifetime == o.lifetime
&& side == o.side
&& symbol == o.symbol
&& owner == o.owner
&& limit == o.limit
&& quantity == o.quantity;
}

[[nodiscard]] constexpr bool closed() const
Expand All @@ -96,10 +101,10 @@ namespace esl::economics::markets::order_book {
}

protected:
friend std::ostream &operator << (std::ostream &, const limit_order_message &);
friend std::ostream &operator << (std::ostream &, const limit_order &);
};

inline std::ostream &operator << (std::ostream &ostream, const limit_order_message &order)
inline std::ostream &operator << (std::ostream &ostream, const limit_order &order)
{
(void)ostream;
(void)order;
Expand Down
Loading

0 comments on commit 4a4c4c7

Please sign in to comment.