Compare commits

..
Author SHA1 Message Date
John Colvin cc38cc83c0 fix build: Add a few includes, suppress some werrors
Not sure how this slipped through the cracks, but I'm guessing the build
broke when we upgraded the cpp compilers (to clang 17 and gcc 13).

* Include <cstdint> in a few places
* Suppress -Wstringop-overflow in sparkd-gcc-release build
* Change const char * param to explicit std::string for proper type
  deduction in call to 'std::make_tuple'. For some reason, the gcc build
  was failing with an array-bounds werror (changing the arg fixed it).
2024-05-25 15:09:42 -04:00
John Colvin ed215d644f fix build: Remove version suffix from RuntimeIdentifiers in csprojs
They aren't required (nor supported) in dotnet 8
2024-05-25 15:09:42 -04:00
John Colvin 6182cefa69 cleanup: Remove unnused token in BooleanExpression lex 2024-05-25 15:09:42 -04:00
John Colvin 4edd0eb65d cleanup: Remove 'global.json' file
This config file is an artifact leftover from dotnet 6. I'm pretty sure
it's useless now.
2024-05-25 15:09:42 -04:00
John Colvin 97c82c4869 feat: Add [incremental] MongoCollectionStream 2024-05-25 15:09:42 -04:00
John Colvin 250d9fb7cb refactor: Impl IDictionary<int, IBlueRow> in BlueTable 2024-05-25 14:30:43 -04:00
John Colvin 150075e34a Normalize indentation in MongoDBStream 2024-05-25 14:30:43 -04:00
John Colvin 6771fcd219 Add echoDelay param to SimpleTCPServer 2024-05-25 14:30:43 -04:00
John Colvin e721a94d72 Add IObservable ViewStream wrapper 2024-05-25 14:30:42 -04:00
362 changed files with 955 additions and 1062 deletions

No files matched your search

-1
View File
@@ -57,4 +57,3 @@ trace_data/
**/.devcontainer
*.Generated.cs
*.lst
.mono/
-6
View File
@@ -39,8 +39,6 @@ if(WIN32)
add_compile_definitions(SHARED_MEMORY_PREFIX="spark")
add_compile_definitions(APP_DATA_DIR="\$\{APPDATA\}/bts/")
# subdirs
add_subdirectory(src/lib_system)
add_subdirectory(src/lib_domain)
add_subdirectory(src/lib)
else()
# make sparkd look for libspark.so in its directory
@@ -110,10 +108,6 @@ else()
# ** Okx **
add_compile_definitions(OKX_INSTRUMENTS_PATH="/api/v5/public/instruments")
add_compile_definitions(OKX_UNDERLYING_PATH="/api/v5/public/underlying")
# Always add lib_system (all builds depends on it)
add_subdirectory(src/lib_system)
add_subdirectory(src/lib_domain)
endif()
# subdirs
-29
View File
@@ -1,29 +0,0 @@
function(init_library source_dir)
file(
GLOB_RECURSE ${PROJECT_NAME}_Sources
RELATIVE ${CMAKE_CURRENT_SOURCE_DIR}
${source_dir}/*.cpp)
# Note: cpp files inside 'tests' dir(s) are considered tests.
# Remove tests from main sources, and add them to test sources
set(${PROJECT_NAME}_Test_Sources)
foreach(item ${${PROJECT_NAME}_Sources})
if(${item} MATCHES "tests/*.cpp")
list(REMOVE_ITEM ${PROJECT_NAME}_Sources ${item})
list(APPEND ${PROJECT_NAME}_Test_Sources ${item})
endif()
endforeach()
# Add main library
add_library(${PROJECT_NAME} ${${PROJECT_NAME}_Sources})
target_include_directories(${PROJECT_NAME} PUBLIC ${CMAKE_CURRENT_SOURCE_DIR})
# Add tests executable (if there are any)
if (${PROJECT_NAME}_Test_Sources)
add_executable(${PROJECT_NAME}-tests ${${PROJECT_NAME}_Test_Sources})
target_link_libraries(${PROJECT_NAME}-tests PRIVATE ${PROJECT_NAME})
# Catch2
find_package(Catch2 CONFIG REQUIRED COMPONENTS Catch2WithMain)
target_link_libraries(${PROJECT_NAME}-tests PRIVATE Catch2::Catch2WithMain)
endif()
endfunction(init_library)
@@ -14,8 +14,11 @@ public class ObservableViewStream : ViewStream, IObservable<DataPacket>, IDispos
this.source = source;
public void Dispose() {
subscription?.Dispose();
subscription = null;
GC.SuppressFinalize(this);
if (subscription is not null) {
subscription.Dispose();
subscription = null;
}
}
protected override void myOnFirstSubscriber() {
@@ -188,7 +188,7 @@ public class MongoCollectionStream : ViewStream, IObservable<DataPacket> {
collection = database.GetCollection<BsonDocument>(collectionName);
var cursor = collection.Find(Builders<BsonDocument>.Filter.Empty).ToCursor();
var docList = await cursor.ToListAsync();
rowFactory ??= MongoSchemaAdaptor.InferSchema(docList);
rowFactory ??= getRowFactory(docList);
var firstTable = new BlueTableImmutable(rowFactory.Schema).ToDataPacketBuilder();
foreach (var doc in docList) {
var row = rowFactory.GetBlueRow(doc);
@@ -1,7 +1,5 @@
namespace Bts.DataStream;
using BCG;
using bts;
using MongoDB.Bson;
@@ -9,16 +9,16 @@ using System;
using System.Collections.Generic;
using System.Linq;
public class BlueTableSchemaAdaptor<T> {
public class BlueTableSchemaAdaptor<T> : IMutableBlueRowFactory<T> {
readonly string name;
readonly List<ColumnAdaptor> columns = [];
readonly List<ColumnAdaptor> columns = new();
BlueTableSchema? schema;
public BlueTableSchemaAdaptor(string name) =>
this.name = name;
public IBlueTableSchema Schema =>
schema ??= new BlueTableSchema([.. columns.WrapSelectorRO(c => c.Info)], name);
schema ??= new BlueTableSchema(columns.WrapSelectorRO(c => c.Info).ToArray(), name);
public bool Contains(string name) =>
columns.Any(c => c.Info.colName == name);
@@ -60,7 +60,10 @@ public class BlueTableSchemaAdaptor<T> {
columns.Add(new ColumnAdaptor(new(name, columns.Count, dataType), r => getValue(r)));
}
public IBlueRow GetBlueRow(T item) {
public IBlueRow GetBlueRow(T item) =>
GetMutableBlueRow(item);
public MutableBlueRow GetMutableBlueRow(T item) {
var mbr = new MutableBlueRow(Schema);
foreach (var col in columns) {
mbr.setValue(col.Info.colNo, col.GetValue(item));
@@ -0,0 +1,9 @@
#nullable enable
namespace Bts.DataStream;
using BCG;
public interface IBlueRowFactory<T> {
IBlueTableSchema Schema { get; }
IBlueRow GetBlueRow(T item);
}
@@ -0,0 +1,11 @@
#nullable enable
namespace Bts.DataStream;
using BCG;
public interface IMutableBlueRowFactory<T> : IBlueRowFactory<T> {
MutableBlueRow GetMutableBlueRow(T item);
IBlueRow IBlueRowFactory<T>.GetBlueRow(T item) =>
GetMutableBlueRow(item);
}
@@ -313,4 +313,9 @@ namespace BCG
return String.Format("DataPacket, schema {0} n {1} d {2} a {3}", schema.tableName, newRows.Count, deletedRows.Count, addedRows.Count);
}
}
public static class DataPacketExtensions {
public static bool HasChanges(this DataPacket dataPacket) =>
dataPacket.addedRows.Count > 0 || dataPacket.deletedRows.Count > 0;
}
}
+1 -1
View File
@@ -1,7 +1,7 @@
#pragma once
#include "lib/api/apicore.pb.h"
#include "system/export.h"
#include "lib/utils/bts_export.h"
#include <string>
#include <vector>
+1 -2
View File
@@ -1,9 +1,8 @@
#pragma once
#include "lib/api/domain/CallPut.pb.h"
#include "lib/core/EnumMacros.h"
#include "lib/io/JsonReader.h"
#include "lib/logging/logging.h"
#include "system/enum_macros.h"
#include <nlohmann/json.hpp>
namespace bts::api::domain {
+1 -2
View File
@@ -1,9 +1,8 @@
#pragma once
#include "lib/api/domain/Currency.pb.h"
#include "lib/core/EnumMacros.h"
#include "lib/io/JsonReader.h"
#include "lib/logging/logging.h"
#include "system/enum_macros.h"
#include <nlohmann/json.hpp>
namespace bts::api::domain {
+2 -2
View File
@@ -1,10 +1,10 @@
#pragma once
#include "lib/api/domain/SecurityType.pb.h"
#include "lib/core/EnumMacros.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/io/JsonReader.h"
#include "lib/logging/logging.h"
#include "system/enum_macros.h"
#include "system/FMT_IMPL.h"
#include <nlohmann/json.hpp>
+2 -2
View File
@@ -1,10 +1,10 @@
#pragma once
#include "lib/api/domain/Venue.pb.h"
#include "lib/core/EnumMacros.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/io/JsonReader.h"
#include "lib/logging/logging.h"
#include "system/enum_macros.h"
#include "system/FMT_IMPL.h"
#include <nlohmann/json.hpp>
+1 -2
View File
@@ -1,7 +1,6 @@
#pragma once
#include "system/export.h"
#include "lib/utils/bts_export.h"
#include <exception>
#include <string>
+1 -1
View File
@@ -5,7 +5,7 @@
#include "ServerChannel.h"
#include "StatefulPublisher.h"
#include "lib/api/apicore.pb.h"
#include "system/export.h"
#include "lib/utils/bts_export.h"
#include <cstdint>
#include <functional>
+5 -4
View File
@@ -1,6 +1,7 @@
#pragma once
#include "ClientChannel.h"
#include "lib/utils/bts_no_copy.h"
namespace bts {
namespace api {
@@ -15,13 +16,13 @@ class QuickbusClientChannel : public ClientChannel {
const ServiceContext &,
const char *type_name,
const char *service_qualifier);
QuickbusClientChannel(const QuickbusClientChannel &) = delete;
QuickbusClientChannel &operator=(const QuickbusClientChannel &) = delete;
~QuickbusClientChannel();
private:
virtual void send_core(
const std::string &request_envalope, OnReply on_response) override;
BTS_NO_COPY(QuickbusClientChannel);
virtual void
send_core(const std::string &request_envalope, OnReply on_response) override;
virtual Unsubscribe subscribe_core(
const char *method, const char *qualifier, OnSubscriptionCB cb) override;
virtual bool is_sync_call_ok() override;
+1 -1
View File
@@ -1,6 +1,6 @@
#pragma once
#include "system/export.h"
#include "lib/utils/bts_export.h"
// client
#include "../core/ApiClientInterop.h"
+2
View File
@@ -0,0 +1,2 @@
#pragma once
#include "public/ServiceContext.h"
@@ -4,7 +4,7 @@
#include "lib/api/public/ClientChannel.h"
#include "lib/api/public/Result.h"
#include "lib/api/public/Update.h"
#include "system/export.h"
#include "lib/utils/bts_export.h"
#include <google/protobuf/arena.h>
#include <functional>
@@ -1,8 +1,7 @@
#pragma once
#include "{{filename name}}.pb.h"
#include "lib/api/public/ApiServer.h"
#include "system/export.h"
#include "lib/utils/bts_export.h"
#include <string>
#include <functional>
#include <vector>
+2 -2
View File
@@ -1,10 +1,10 @@
#pragma once
#include "lib/api/services/OrderService.pb.h"
#include "lib/core/EnumMacros.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/io/JsonReader.h"
#include "lib/logging/logging.h"
#include "system/enum_macros.h"
#include "system/FMT_IMPL.h"
#include <nlohmann/json.hpp>
+1 -1
View File
@@ -1,7 +1,7 @@
#include "../public/ApiUtils.h"
#include "../public/ServiceContext.h"
#include "HelloServiceServer.h"
#include "system/export.h"
#include "lib/utils/bts_export.h"
#include "lib/api/services/ApiUnitTestService.server.pb.h"
+4 -3
View File
@@ -1,8 +1,10 @@
#pragma once
#include "lib/utils/bts_export.h"
#include "lib/utils/bts_no_copy.h"
#include "lib/api/services/HelloService.client.pb.h"
#include "lib/api/services/HelloService.server.pb.h"
#include "system/export.h"
namespace bts {
namespace api {
@@ -11,10 +13,9 @@ namespace test {
struct BTS_EXPORT HelloServiceServer : public HelloServiceBase {
public:
HelloServiceServer(bts::api::ServiceContext &context);
HelloServiceServer(const HelloServiceServer &) = delete;
HelloServiceServer &operator=(const HelloServiceServer &) = delete;
private:
BTS_NO_COPY(HelloServiceServer);
int _id;
ShoutService _shouter;
GreetingsPublisher _gpub;
@@ -1,6 +1,5 @@
function(get_link_libraries dest)
set(${dest}
bts-system
curl
tbb
boost_system
@@ -1,7 +1,5 @@
function(get_link_libraries dest)
set(${dest}
bts-system
bts-domain
protobuf
double-conversion
boost_system
@@ -1,7 +1,6 @@
function(get_link_libraries dest)
find_package(fmt CONFIG REQUIRED)
set(${dest}
bts-system
crypt32
fmt::fmt-header-only
libcrypto
+1 -3
View File
@@ -1,7 +1,5 @@
#pragma once
#include "system/all_same_type.h"
#include "lib/core/AllSameType.h"
#include <unordered_map>
#include <unordered_set>
+4 -2
View File
@@ -1,11 +1,13 @@
#include "lib/utils/windows_wrapper.h"
#include "ConfigDownloader.h"
#include "lib/utils/bts_assert.h"
#include "system/windows_wrapper.h"
#include <boost/algorithm/string.hpp>
#include <sstream>
#include <stdio.h>
#include "lib/utils/bts_assert.h"
using namespace std;
namespace bts {
+2 -2
View File
@@ -1,5 +1,6 @@
#pragma once
#include "lib/utils/bts_no_copy.h"
#include <curl/curl.h>
#include <string>
@@ -10,8 +11,6 @@ namespace internal {
class ConfigDownloader {
public:
ConfigDownloader();
ConfigDownloader(const ConfigDownloader &) = delete;
ConfigDownloader &operator=(const ConfigDownloader &) = delete;
~ConfigDownloader();
enum Result { FAILURE, SUCCESS, PERMANENT_FAILURE };
@@ -19,6 +18,7 @@ class ConfigDownloader {
Result get(const std::string &url, std::stringstream &out_stream);
private:
BTS_NO_COPY(ConfigDownloader);
CURL *_curl;
};
+2 -2
View File
@@ -17,8 +17,6 @@ class ConfigErrorCollector : public proto::io::ErrorCollector,
public proto::DescriptorPool::ErrorCollector {
public:
ConfigErrorCollector(ConfigLog &log, const char *file);
ConfigErrorCollector(const ConfigErrorCollector &) = delete;
ConfigErrorCollector &operator=(const ConfigErrorCollector &) = delete;
void AddError(int line, int column, const std::string &message) override;
void AddWarning(int line, int column, const std::string &message) override;
@@ -42,6 +40,8 @@ class ConfigErrorCollector : public proto::io::ErrorCollector,
std::string ToString();
private:
BTS_NO_COPY(ConfigErrorCollector);
ConfigLog &_log;
std::string _file;
std::vector<std::string> _errors;
+1
View File
@@ -1,6 +1,7 @@
#pragma once
#include "lib/logging/logging.h"
#include "lib/utils/bts_no_copy.h"
#include <memory>
#include <sstream>
+2 -1
View File
@@ -1,8 +1,9 @@
#include "ConfigPropertyEvaluator.h"
#include "ConfigurationState.h"
#include "lib/expression/ExpressionEvaluator.h"
#include "lib/utils/bts_assert.h"
#include "system/windows_wrapper.h"
#include "lib/utils/windows_wrapper.h"
#include <boost/tokenizer.hpp>
#include <google/protobuf/descriptor.h>
+3 -2
View File
@@ -3,6 +3,7 @@
#include "lib/expression/IPropertyEvaluator.h"
#include "lib/expression/Value.h"
#include "lib/utils/bts_no_copy.h"
namespace bts {
namespace expression {
@@ -16,14 +17,14 @@ class ConfigurationState;
class ConfigPropertyEvaluator : public expression::IPropertyEvaluator {
public:
ConfigPropertyEvaluator(ConfigurationState &config);
ConfigPropertyEvaluator(const ConfigPropertyEvaluator &) = delete;
ConfigPropertyEvaluator &operator=(const ConfigPropertyEvaluator &) = delete;
~ConfigPropertyEvaluator();
bool get_value(
const std::string &property, expression::Value *out_value) override;
private:
BTS_NO_COPY(ConfigPropertyEvaluator);
ConfigurationState &_config;
std::shared_ptr<expression::ExpressionEvaluator> _rule_engine;
};
+2 -2
View File
@@ -3,9 +3,9 @@
#include "lib/collections/Contains.h"
#include "lib/config/ConfigQueryErrors.h"
#include "lib/config/text_format/text_format.h"
#include "lib/core/EnumMacros.h"
#include "lib/utils/TimeStamp.h"
#include "system/enum_macros.h"
#include "system/export.h"
#include "lib/utils/bts_export.h"
#include <cmath>
#include <google/protobuf/descriptor.h>
+1 -2
View File
@@ -1,6 +1,5 @@
#pragma once
#include "system/export.h"
#include "lib/utils/bts_export.h"
#include <string>
#include <vector>
+1 -2
View File
@@ -1,6 +1,5 @@
#pragma once
#include "system/enum_macros.h"
#include "lib/core/EnumMacros.h"
namespace bts::config {
+2 -2
View File
@@ -2,6 +2,7 @@
#include "lib/expression/IPropertyEvaluator.h"
#include "lib/expression/Value.h"
#include "lib/utils/bts_no_copy.h"
#include "text_format/text_format.h"
#include <string>
@@ -35,8 +36,6 @@ struct DeferredValue {
class ConfigValueQueue : public google::protobuf::IDeferValueLookup {
public:
ConfigValueQueue(expression::IPropertyEvaluator &evaluator);
ConfigValueQueue(const ConfigValueQueue &) = delete;
ConfigValueQueue &operator=(const ConfigValueQueue &) = delete;
~ConfigValueQueue();
// Process the queue of deferred values
@@ -61,6 +60,7 @@ class ConfigValueQueue : public google::protobuf::IDeferValueLookup {
expression::IPropertyEvaluator &_eval;
std::vector<DeferredValue> _vals;
std::string _current_file;
BTS_NO_COPY(ConfigValueQueue);
private: // methods
void process_fields();
+1 -2
View File
@@ -1,8 +1,7 @@
#ifndef BADCONFIGURATIONEXCEPTION_H_
#define BADCONFIGURATIONEXCEPTION_H_
#include "system/export.h"
#include "lib/utils/bts_export.h"
#include <sstream>
#include <stdexcept>
#include <string>
+12 -7
View File
@@ -1,21 +1,21 @@
#include "ConfigurationState.h"
#include "ConfigErrorCollector.h"
#include "ConfigPropertyEvaluator.h"
#include "ConfigValueQueue.h"
#include "ConfigurationException.h"
#include "PreprocessInputStream.h"
#include "config.h"
#include "lib/collections/Contains.h"
#include "lib/config/PreprocessInputStream.h"
#include "lib/config/config.h"
#include "lib/config/protos/system_config.pb.h"
#include "lib/config_defaults.h"
#include "lib/config_proto_files.h"
#include "lib/core/FMT.h"
#include "lib/io/ProtoPrinter.h"
#include "lib/os/os.h"
#include "lib/utils/bts_array_size.h"
#include "lib/utils/bts_assert.h"
#include "lib/utils/defer.h"
#include "lib/utils/is_unittest_environment.h"
#include "system/FMT.h"
#include "system/array_size.h"
#include "lib/config/protos/system_config.pb.h"
#include <algorithm>
#include <boost/algorithm/string.hpp> // iequals
@@ -33,6 +33,9 @@
#define URDL_DISALE_SSL 1
#include <urdl/url.hpp>
#include "lib/config_defaults.h"
#include "lib/config_proto_files.h"
#ifdef _WIN32
#include <Winsock2.h>
#include <d2d1.h>
@@ -43,6 +46,8 @@
#include <sys/socket.h>
#endif
#include "lib/os/os.h"
using namespace std;
namespace bts {
+7 -4
View File
@@ -4,15 +4,18 @@
#include "ConfigDownloader.h"
#include "ConfigLog.h"
#include "ConfigurationException.h"
#include "lib/expression/ExpressionEvaluator.h"
#include "lib/expression/Value.h"
#include <boost/scoped_ptr.hpp>
#include <boost/utility.hpp>
#include "text_format/text_format.h"
#include <google/protobuf/descriptor.h>
#include <google/protobuf/descriptor.pb.h>
#include <google/protobuf/dynamic_message.h>
#include <google/protobuf/io/zero_copy_stream_impl.h>
#include <boost/scoped_ptr.hpp>
#include <boost/utility.hpp>
#include <mutex>
#include <vector>
@@ -45,8 +48,6 @@ class ConfigValueQueue;
class ConfigurationState {
public:
ConfigurationState(void);
ConfigurationState(const ConfigurationState &) = delete;
ConfigurationState &operator=(const ConfigurationState &) = delete;
~ConfigurationState(void);
void initialize_defaults(ConfigLog &log);
@@ -91,6 +92,8 @@ class ConfigurationState {
get_descriptor_by_name(const std::string &name);
private:
BTS_NO_COPY(ConfigurationState);
void initialize_builtins(ConfigLog *log = nullptr);
void initialize_introspection();
void initialize_macros();
+2 -3
View File
@@ -1,5 +1,6 @@
#pragma once
#include "lib/utils/bts_no_copy.h"
#include <boost/scoped_ptr.hpp>
#include <google/protobuf/io/zero_copy_stream_impl.h>
@@ -18,9 +19,6 @@ class PreprocessInputStream : public proto::io::ZeroCopyInputStream {
std::istream &input, std::map<std::string, std::string> replacements);
~PreprocessInputStream();
PreprocessInputStream(const PreprocessInputStream &) = delete;
PreprocessInputStream &operator=(const PreprocessInputStream &) = delete;
bool Next(const void **data, int *size) override;
void BackUp(int count) override;
bool Skip(int count) override;
@@ -29,6 +27,7 @@ class PreprocessInputStream : public proto::io::ZeroCopyInputStream {
private:
std::string _buffer;
boost::scoped_ptr<proto::io::ArrayInputStream> _stream;
BTS_NO_COPY(PreprocessInputStream);
};
} // namespace config
+1 -1
View File
@@ -1,8 +1,8 @@
#ifndef BTS_CONFIG_H_
#define BTS_CONFIG_H_
#include "lib/utils/bts_export.h"
#include "lib/utils/checked_cast.h"
#include "system/export.h"
#include <string>
#include <vector>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
@@ -1,5 +1,4 @@
#include "system/time_span.h"
#include "TimeSpan.h"
#include <boost/date_time/posix_time/time_formatters.hpp>
#include <boost/date_time/posix_time/time_parsers.hpp>
@@ -1,8 +1,7 @@
#pragma once
#include "system/FMT_IMPL.h"
// #include "lib/utils/datetime.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/utils/bts_assert.h"
#include "lib/utils/datetime.h"
#include <boost/date_time/posix_time/conversion.hpp>
#include <boost/date_time/posix_time/posix_time_config.hpp>
#include <boost/date_time/posix_time/posix_time_duration.hpp>
+58
View File
@@ -0,0 +1,58 @@
#include "TimeStamp.h"
#include "lib/utils/datetime.h"
#include <boost/date_time/posix_time/time_formatters.hpp>
namespace bts::core {
using std::uint32_t;
static bool is_valid_ymd(uint32_t year, uint32_t month, uint32_t day) {
return year >= 1970 && month >= 1 && month <= 12 && day >= 1 && day <= 31;
}
TimeStamp::TimeStamp(uint32_t year, uint32_t month, uint32_t day) {
bts_assert_msgf(
is_valid_ymd(year, month, day), "Invalid timestamp {}/{}/{} (y/m/d)",
year, month, day);
std::tm date = {};
date.tm_year = year - 1900;
date.tm_mon = month - 1;
date.tm_mday = day;
auto time = std::chrono::system_clock::from_time_t(mktime(&date));
auto duration = time.time_since_epoch();
value_ =
std::chrono::duration_cast<std::chrono::nanoseconds>(duration).count();
}
bool TimeStamp::from_ymd(
std::uint32_t year, std::uint32_t month, std::uint32_t day, TimeStamp *result) {
if (!is_valid_ymd(year, month, day)) {
return false;
}
*result = TimeStamp{year, month, day};
return true;
}
TimeStamp TimeStamp::from_iso_string(const std::string &iso_string) {
auto ptime = datetime::parse_iso_date_time_string(iso_string);
return from_ptime(ptime);
}
std::string TimeStamp::to_iso_string() const {
return boost::posix_time::to_iso_string(to_ptime());
}
std::ostream &operator<<(std::ostream &out, const TimeStamp &ts) noexcept {
out << ts.to_iso_string();
return out;
}
TimeStamp TimeStamp::from_ptime(boost::posix_time::ptime t) {
// time_t is Unix time: number of seconds since epoch Jan 1, 1970
auto epoch_pt =
t - boost::posix_time::ptime(boost::gregorian::date(1970, 1, 1));
auto epoch_nanos = epoch_pt.total_nanoseconds();
return TimeStamp{static_cast<std::uint64_t>(epoch_nanos)};
}
} // namespace bts::core
@@ -1,6 +1,8 @@
#pragma once
#include "system/FMT_IMPL.h"
#include "system/time_span.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/core/TimeSpan.h"
#include "lib/utils/bts_assert.h"
#include "lib/utils/datetime.h"
#include <boost/date_time/posix_time/conversion.hpp>
#include <boost/date_time/posix_time/posix_time_duration.hpp>
@@ -55,11 +57,7 @@ struct TimeStamp {
// current epoch ns
static uint64_t now_ns() {
#ifndef _WIN32
struct timespec ts;
// CLOCK_REALTIME is already anchored at the unix epoch
clock_gettime(CLOCK_REALTIME, &ts);
return static_cast<int64_t>(1000000000UL) * static_cast<int64_t>(ts.tv_sec) +
static_cast<int64_t>(ts.tv_nsec);
return datetime::unix_nano_now();
#else
auto now = std::chrono::system_clock::now();
auto ns = std::chrono::duration_cast<std::chrono::nanoseconds>(
@@ -101,24 +99,29 @@ constexpr TimeStamp TimeStamp::max() {
}
constexpr TimeStamp TimeStamp::from_int64(std::int64_t value) {
bts_assert(value >= 0);
return TimeStamp{static_cast<std::uint64_t>(value)};
}
constexpr TimeStamp TimeStamp::from_nanos(std::int64_t value) {
bts_assert(value >= 0);
return TimeStamp{static_cast<std::uint64_t>(value)};
}
constexpr TimeStamp TimeStamp::from_micros(std::int64_t value) {
bts_assert(value >= 0);
constexpr const auto nanos_per_micro = 1'000;
return TimeStamp{static_cast<std::uint64_t>(value * nanos_per_micro)};
}
constexpr TimeStamp TimeStamp::from_millis(std::int64_t value) {
bts_assert(value >= 0);
constexpr const auto nanos_per_milli = 1'000'000;
return TimeStamp{static_cast<std::uint64_t>(value * nanos_per_milli)};
}
constexpr TimeStamp TimeStamp::from_seconds(std::int64_t value) {
bts_assert(value >= 0);
constexpr const auto nanos_per_second = 1'000'000'000;
return TimeStamp{static_cast<std::uint64_t>(value * nanos_per_second)};
}
@@ -142,6 +145,9 @@ constexpr double TimeStamp::total_seconds() const {
}
constexpr std::int64_t TimeStamp::to_int64() {
bts_assert(
value_ <=
static_cast<std::int64_t>(std::numeric_limits<std::int64_t>::max()));
return static_cast<std::int64_t>(value_);
}
void TimeStamp::to_date(uint32_t &year, uint32_t &month, uint32_t &day) {
File renamed without changes.
File renamed without changes.
@@ -4,9 +4,8 @@
#include "lib/api/services/AdminService.server.pb.h"
#include "lib/config/config.h"
#include "lib/datastreams/Tables/StreamData.h"
#include "lib/utils/bts_chrono.h"
#include "lib/utils/helper_macros.h"
#include "system/bts_chrono.h"
#include <memory>
using namespace bts::streams;
+2 -4
View File
@@ -1,8 +1,6 @@
#pragma once
#include "system/enum_macros.h"
#include "system/FMT_IMPL.h"
#include "lib/core/EnumMacros.h"
#include "lib/core/FMT_IMPL.h"
#include <fmt/format.h>
#include <nlohmann/json.hpp>
#include <ostream>
+1 -3
View File
@@ -1,8 +1,6 @@
#pragma once
#include "lib/core/TimeStamp.h"
#include "lib/io/JsonReader.h"
#include "system/time_stamp.h"
#include <nlohmann/json.hpp>
namespace bts::domain {
+1 -2
View File
@@ -1,9 +1,8 @@
#pragma once
#include "lib/api/domain/CallPut.h"
#include "lib/core/TimeStamp.h"
#include "lib/domain/Price.h"
#include "lib/io/JsonReader.h"
#include "system/time_stamp.h"
#include <nlohmann/json.hpp>
namespace bts::domain {
+1 -1
View File
@@ -1,9 +1,9 @@
#pragma once
#include "Side.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/io/JsonReader.h"
#include "lib/utils/bts_assert.h"
#include "system/FMT_IMPL.h"
#include <cmath>
#include <cstdint>
+1 -1
View File
@@ -1,9 +1,9 @@
#pragma once
#include "lib/core/FMT_IMPL.h"
#include "lib/io/JsonReader.h"
#include "lib/logging/logging.h"
#include "lib/utils/ValueWrapper.h"
#include "system/FMT_IMPL.h"
#include <cstdint>
#include <nlohmann/json.hpp>
+1
View File
@@ -1,5 +1,6 @@
#include "Security.h"
#include "DomainSecurityUtils.h"
#include "lib/core/TableFormatter.h"
#include "lib/domain/FutureSecurity.h"
#include "lib/domain/OptionSecurity.h"
#include "lib/domain/SpotSecurity.h"
+1 -1
View File
@@ -4,9 +4,9 @@
#include "SecurityCommon.h"
#include "SpotSecurity.h"
#include "SpreadSecurity.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/domain/SecurityID.h"
#include "lib/utils/overloaded.h"
#include "system/FMT_IMPL.h"
#include <fmt/format.h>
#include <variant>
+1 -2
View File
@@ -6,6 +6,7 @@
#include "lib/api/domain/SecurityType.pb.h"
#include "lib/api/domain/Venue.h"
#include "lib/api/domain/Venue.pb.h"
#include "lib/core/TimeStamp.h"
#include "lib/domain/FutureSecurity.h"
#include "lib/domain/LegDefinition.h"
#include "lib/domain/OptionSecurity.h"
@@ -16,8 +17,6 @@
#include "lib/io/JsonReader.h"
#include "lib/logging/logging.h"
#include "lib/utils/bts_assert.h"
#include "system/time_stamp.h"
#include <limits>
#include <nlohmann/json.hpp>
#include <string>
+1 -2
View File
@@ -1,8 +1,7 @@
#include "SecurityCriteria.h"
#include "lib/api/domain/SecurityCriteria.pb.h"
#include "lib/core/FMT.h"
#include "lib/domain/DomainSecurityUtils.h"
#include "system/FMT.h"
#include <algorithm>
namespace bts::domain {
+1 -1
View File
@@ -2,9 +2,9 @@
#include "SecurityID.h"
#include "lib/api/domain/Venue.pb.h"
#include "lib/domain/Security.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/domain/SecurityCriteriaClause.h"
#include "lib/domain_model/Security.pb.h"
#include "system/FMT_IMPL.h"
#include <boost/container/small_vector.hpp>
#include <optional>
+1 -1
View File
@@ -4,9 +4,9 @@
#include "lib/api/domain/SecurityType.h"
#include "lib/api/domain/Venue.h"
#include "lib/collections/Contains.h"
#include "lib/core/FMT.h"
#include "lib/domain/Security.h"
#include "lib/domain_model/Security.pb.h"
#include "system/FMT.h"
#include <range/v3/view.hpp>
#include <regex>
+1 -1
View File
@@ -1,8 +1,8 @@
#pragma once
#include "lib/api/domain/SecurityType.pb.h"
#include "lib/api/domain/Venue.pb.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/domain/SecurityID.h"
#include "system/FMT_IMPL.h"
#include <boost/container/small_vector.hpp>
#include <fmt/format.h>
+1 -1
View File
@@ -1,7 +1,7 @@
#pragma once
#include "lib/core/FMT_IMPL.h"
#include "lib/utils/ValueWrapper.h"
#include "system/FMT_IMPL.h"
#include <cstdint>
#include <nlohmann/json.hpp>
@@ -2,11 +2,10 @@
#include "Price.h"
#include "Quantity.h"
#include "Security.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/io/JsonReader.h"
#include "lib/md/IntPrice.h"
#include "lib/md/protos/co2.pb.h"
#include "system/FMT_IMPL.h"
#include <fmt/format.h>
#include <nlohmann/json.hpp>
#include <ostream>
+1 -2
View File
@@ -3,11 +3,10 @@
#include "Price.h"
#include "Quantity.h"
#include "SecurityID.h"
#include "lib/core/TimeStamp.h"
#include "lib/logging/logging.h"
#include "lib/md/IntPrice.h"
#include "lib/md/protos/co2.pb.h"
#include "system/time_stamp.h"
#include <nlohmann/json.hpp>
namespace bts::domain {
+2 -2
View File
@@ -1,12 +1,12 @@
#pragma once
#include "lib/core/FMT_IMPL.h"
#include "lib/domain_model/Security.pb.h"
#include "lib/domain_model/Side.h"
#include "lib/domain_model/Venue.h"
#include "domain/domain.h"
#include "lib/domain_model/common.h"
#include "lib/utils/bts_assert.h"
#include "lib/utils/datetime.h"
#include "system/FMT_IMPL.h"
#include <cmath>
#include <memory>
@@ -1,6 +1,6 @@
#pragma once
#include "system/value_wrapper.h"
#include "lib/utils/ValueWrapper.h"
#include <cstdint>
+2 -2
View File
@@ -1,10 +1,10 @@
#pragma once
#include "lib/core/EnumMacros.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/domain_model/Security.pb.h"
#include "lib/io/JsonReader.h"
#include "lib/logging/logging.h"
#include "system/enum_macros.h"
#include "system/FMT_IMPL.h"
#include <nlohmann/json.hpp>
+2 -2
View File
@@ -1,10 +1,10 @@
#pragma once
#include "lib/core/EnumMacros.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/domain_model/Security.pb.h"
#include "lib/io/JsonReader.h"
#include "lib/logging/logging.h"
#include "system/enum_macros.h"
#include "system/FMT_IMPL.h"
#include <nlohmann/json.hpp>
@@ -7,9 +7,9 @@
#include <cstdint>
#include <string>
#include "domain/security_key.h"
#include "system/value_wrapper.h"
#include "system/FMT_IMPL.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/domain_model/SecurityKey.h"
#include "lib/utils/ValueWrapper.h"
namespace bts {
struct CQuantity {
+21
View File
@@ -0,0 +1,21 @@
#include "sod.h"
#include "lib/config/config.h"
#include "lib/config/protos/orders_fills_cleanup.pb.h"
namespace bts {
namespace sod {
datetime::PTime get_sod_for(datetime::PTime const &this_time) {
const auto &sod = config::get<config::SODTime>();
auto sod_time = datetime::make_ptime(
this_time.date().year(), this_time.date().month().as_number(),
this_time.date().day().as_number(), sod.sod_hh(), sod.sod_mm(), 0, 0);
if (sod_time > this_time)
sod_time -= boost::gregorian::date_duration(1);
return sod_time;
}
datetime::PTime get_current_sod() { return get_sod_for(datetime::local_now()); }
} // namespace sod
} // namespace bts
+13
View File
@@ -0,0 +1,13 @@
#pragma once
#include "lib/utils/datetime.h"
#include <boost/date_time/posix_time/posix_time.hpp>
namespace bts {
namespace sod {
datetime::PTime get_sod_for(datetime::PTime const &this_time);
datetime::PTime get_current_sod();
} // namespace sod
} // namespace bts
+1 -1
View File
@@ -1,7 +1,7 @@
#include "../Security.h"
#include "catch/catch.hpp"
#include "system/time_stamp.h"
#include "lib/core/TimeStamp.h"
#include "lib/domain_model/Security.h"
#include "lib/quickbus/rpc/RPCServiceName.h"
#include "lib/utils/PBUtils.h"
+4 -2
View File
@@ -1,11 +1,14 @@
#ifndef BOOLEANGRAMMAR_H_
#define BOOLEANGRAMMAR_H_
#include "lib/utils/bts_no_copy.h"
#include <boost/config/warning_disable.hpp>
#include <boost/spirit/include/phoenix_function.hpp>
#include <boost/spirit/include/phoenix_operator.hpp>
#include <boost/spirit/include/qi.hpp>
#include <boost/spirit/include/support_utree.hpp>
#include <string>
/*
@@ -250,10 +253,9 @@ class BooleanGrammar
("=" >> _primitive[eq_expr(_val, _1)]) |
("!=" >> _primitive[neq_expr(_val, _1)]));
}
BooleanGrammar(const BooleanGrammar &) = delete;
BooleanGrammar &operator=(const BooleanGrammar &) = delete;
private:
BTS_NO_COPY(BooleanGrammar);
qi::rule<Iterator, std::string()> _internal_string;
qi::rule<Iterator, sp::utree(), space_type> _expression, _primitive, _term,
_list, _property, _quoted_string;
+1 -2
View File
@@ -19,8 +19,6 @@ namespace expression {
class ExpressionEvaluatorImpl {
public:
ExpressionEvaluatorImpl(std::shared_ptr<IPropertyEvaluator> property_eval);
ExpressionEvaluatorImpl(const ExpressionEvaluatorImpl &) = delete;
ExpressionEvaluatorImpl &operator=(const ExpressionEvaluatorImpl &) = delete;
~ExpressionEvaluatorImpl();
bool eval(const std::string &expression) const;
@@ -34,6 +32,7 @@ class ExpressionEvaluatorImpl {
Value eval_to_value(const std::string &expression) const;
private:
BTS_NO_COPY(ExpressionEvaluatorImpl);
bool parse(
std::string::const_iterator &begin,
+1 -2
View File
@@ -18,8 +18,6 @@ class ExpressionEvaluatorImpl;
class ExpressionEvaluator {
public:
ExpressionEvaluator(std::shared_ptr<IPropertyEvaluator> property_eval);
ExpressionEvaluator(const ExpressionEvaluator &) = delete;
ExpressionEvaluator &operator=(const ExpressionEvaluator &) = delete;
~ExpressionEvaluator();
bool eval(const std::string &expression) const;
@@ -36,6 +34,7 @@ class ExpressionEvaluator {
bool eval_ast(const boost::spirit::utree &ast) const;
private:
BTS_NO_COPY(ExpressionEvaluator);
std::unique_ptr<ExpressionEvaluatorImpl> _impl;
};
+3 -4
View File
@@ -1,6 +1,7 @@
#ifndef RECURSIONGUARD_H_
#define RECURSIONGUARD_H_
#include "lib/utils/bts_no_copy.h"
#include <boost/thread.hpp>
#include <vector>
@@ -14,8 +15,6 @@ template <typename T> struct GuardFrame {
GuardFrame() : _owner(0) {}
GuardFrame(RecursionGuard<T> &owner) : _owner(&owner) {}
GuardFrame(const GuardFrame &) = delete;
GuardFrame &operator=(const GuardFrame &) = delete;
~GuardFrame() {
if (_owner) {
@@ -27,14 +26,13 @@ template <typename T> struct GuardFrame {
void set_owner(RecursionGuard<T> *owner) { _owner = owner; }
private:
BTS_NO_COPY(GuardFrame);
RecursionGuard<T> *_owner;
};
template <typename T> class RecursionGuard {
public:
RecursionGuard() : _recursion_guard() {}
RecursionGuard(const RecursionGuard &) = delete;
RecursionGuard &operator=(const RecursionGuard &) = delete;
~RecursionGuard() {}
std::vector<T> &get() {
@@ -63,6 +61,7 @@ template <typename T> class RecursionGuard {
template <typename U> friend struct GuardFrame;
private:
BTS_NO_COPY(RecursionGuard);
boost::thread_specific_ptr<std::vector<T>> _recursion_guard;
};
+1 -2
View File
@@ -1,10 +1,9 @@
#include "JsonReader.h"
#include "lib/algorithm/TryCatch.h"
#include "lib/core/TimeStamp.h"
#include "lib/logging/logging.h"
#include "lib/utils/TimeStamp.h"
#include "lib/utils/datetime.h"
#include "system/time_stamp.h"
#include <boost/date_time/posix_time/ptime.hpp>
#include <exception>
#include <limits>
+1 -4
View File
@@ -1,8 +1,5 @@
#pragma once
#include "lib/utils/bts_assert.h"
#include "system/time_stamp.h"
#include "lib/core/TimeStamp.h"
#include <cstdint>
#include <nlohmann/json.hpp>
#include <optional>
+1 -2
View File
@@ -1,7 +1,6 @@
#pragma once
#ifdef SPARK_ENABLE_CCAPI
#include "system/enum_macros.h"
#include "lib/core/EnumMacros.h"
#include <nlohmann/detail/value_t.hpp>
#include <nlohmann/json.hpp>
#include <ostream>
+1 -2
View File
@@ -1,7 +1,6 @@
#pragma once
#include "QueryParams.h"
#include "system/hash_phaser.h"
#include "lib/core/HashPhaser.h"
#include <functional>
#include <ostream>
#include <string>
+2 -2
View File
@@ -1,8 +1,8 @@
#pragma once
#ifdef SPARK_ENABLE_CCAPI
#include "system/enum_macros.h"
#include "system/FMT_IMPL.h"
#include "lib/core/EnumMacros.h"
#include "lib/core/FMT_IMPL.h"
#include <fmt/format.h>
#include <nlohmann/json.hpp>
+2 -2
View File
@@ -3,9 +3,9 @@
#include "lib/algorithm/StringCaseConverter.h"
#include "lib/api/domain/SecurityType.pb.h"
#include "lib/core/EnumMacros.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/domain_model/Security.pb.h"
#include "system/enum_macros.h"
#include "system/FMT_IMPL.h"
#include <fmt/format.h>
#include <nlohmann/json.hpp>
+1 -1
View File
@@ -1,6 +1,6 @@
#pragma once
#include "system/FMT_IMPL.h"
#include "lib/core/FMT_IMPL.h"
#include <cstdint>
#include <fmt/format.h>
+3 -3
View File
@@ -1,8 +1,8 @@
#pragma once
#include "system/FMT.h"
#include "system/FMT_IMPL.h"
#include "system/time_stamp.h"
#include "lib/core/FMT.h"
#include "lib/core/FMT_IMPL.h"
#include "lib/core/TimeStamp.h"
#include <cstdint>
#include <fmt/format.h>
+1 -1
View File
@@ -1,8 +1,8 @@
#pragma once
#include "lib/core/FMT_IMPL.h"
#include "lib/io/websocket/JsonRpcId.h"
#include "lib/utils/bts_assert.h"
#include "system/FMT_IMPL.h"
#include <fmt/format.h>
#include <nlohmann/json.hpp>
Loaded 100 of 362 files, more files were not shown because too many files have changed in this diff. Show more