Skip to content

Commit

Permalink
1.0 alpha version.
Browse files Browse the repository at this point in the history
  • Loading branch information
physercoe committed Jul 13, 2019
1 parent 27d8e21 commit 0239ed1
Show file tree
Hide file tree
Showing 46 changed files with 5,776 additions and 5,543 deletions.
10 changes: 4 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ Welcome to StarQuant

**StarQuant**(中文名:易数交易系统)是一个轻量的、面向个人( 普通)用户的综合量化交易回测系统,目前主要用于期货期权程序化交易,后期会考虑加入股票交易的功能。

当前进展:开发已完成75%左右并在实盘测试中,对于流动性好,盘口大的品种非大笔交易下tick级回测与实盘的成交时间和价位一致。
当前进展:完成1.0版本alpha版本,在实盘测试中,对于流动性好,盘口大的品种非大笔交易下tick级回测与实盘的成交时间和价位一致。



Expand Down Expand Up @@ -44,7 +44,7 @@ Welcome to StarQuant

## 开发环境
本系统在开发过程中参考了已有的开源软件vnpy,kungfu,EliteQuant等。
开发环境:Manjaro(arch,Linux内核4.14),python 3.7.2,gcc 8.2
开发环境:Manjaro(arch,Linux内核4.14),python 3.7.2,gcc 9.1
第三方库:
boost 1.69
nanomsg
Expand Down Expand Up @@ -103,10 +103,8 @@ python 采用flake8检查,autopep8格式化;

## TODO

本系统尚在开发过程中,当前大约完成了75%左右的功能。
TODO:
1. 完善gui和大数据处理以及系统运行稳定性(80%)
2. 跨平台支持(100%)
本系统完成了版本1.0的alpha版本,正在实盘测试中。




1 change: 0 additions & 1 deletion cppsrc/StarQuant/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ include_directories(${StarQuantCpp_SOURCE_DIR}/StarQuant)
set(StarQuantCppSrc
./Common/datastruct.cpp
./Common/util.cpp
./Common/heartbeat.cpp
./Common/logger.cpp
./Common/config.cpp
./Common/msgq.cpp
Expand Down
97 changes: 55 additions & 42 deletions cppsrc/StarQuant/Common/config.cpp
Original file line number Diff line number Diff line change
@@ -1,16 +1,34 @@
/*****************************************************************************
* Copyright [2019]
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*****************************************************************************/

#include <Common/config.h>
#include <Common/util.h>
#include <Common/datastruct.h>

#include <yaml-cpp/yaml.h>
#include <fmt/format.h>
#include <fstream>
#include <cctype>
#include <boost/program_options.hpp>
#include <boost/property_tree/ptree.hpp>
#include <boost/property_tree/ini_parser.hpp>
#include <boost/filesystem.hpp>
#include <boost/algorithm/string.hpp>
#include <cctype>
#include <fmt/format.h>

#include <Common/config.h>
#include <Common/util.h>
#include <Common/datastruct.h>
#include <yaml-cpp/yaml.h>



namespace bpt = boost::property_tree;
namespace bpo = boost::program_options;
Expand All @@ -34,27 +52,26 @@ namespace StarQuant {
return *pinstance_;
}

void CConfig::readConfig()
{
#ifdef _DEBUG
std::printf("Current path is : %s\n", boost::filesystem::current_path().string().c_str());
#endif
void CConfig::readConfig() {
// reset maps
_gatewaymap.clear();

//read server config
// read server config
std::lock_guard<mutex> g(readlock_);
try{
string path = boost::filesystem::current_path().string() + "/etc/config_server.yaml";
try {
string path = fs::current_path().string()
+ "/etc/config_server.yaml";
YAML::Node config = YAML::LoadFile(path);
string configmode = config["mode"].as<std::string>();
if (configmode =="record")
if (configmode =="record") {
_mode = RUN_MODE::RECORD_MODE;
else if (configmode == "replay"){
} else {
if (configmode == "replay") {
_mode = RUN_MODE::REPLAY_MODE;
_tickinterval =config["tickinterval"].as<int>();
_brokerdelay = config["brokerdelay"].as<int>();
_tickinterval = config["tickinterval"].as<int32_t>();
_brokerdelay = config["brokerdelay"].as<int32_t>();
filetoreplay = config["filetoreplay"].as<std::string>();
}
}
_config_dir = boost::filesystem::current_path().string() + "/etc/";
_log_dir = config["log_dir"].as<std::string>();
Expand All @@ -63,7 +80,7 @@ namespace StarQuant {
boost::filesystem::create_directory(log_path);
boost::filesystem::path data_path(dataDir());
boost::filesystem::create_directory(data_path);
logconfigfile_ = boost::filesystem::current_path().string() + "/etc/config_log";
logconfigfile_ = fs::current_path().string() + "/etc/config_log";
// const string msgq = config["msgq"].as<std::string>();
// _msgq = MSGQ::NANOMSG;
cpuaffinity = config["cpuaffinity"].as<bool>();
Expand All @@ -76,18 +93,18 @@ namespace StarQuant {
SERVERSUB_URL = config["serversub_url"].as<std::string>();
SERVERPULL_URL = config["serverpull_url"].as<std::string>();

// read gateway info
// read gateway info
const std::vector<string> gws = config["gateway"].as<std::vector<string>>();
for (auto s : gws){
for (auto s : gws) {
struct Gateway gw;
gw.id = s;
gw.intid = config[s]["intid"].as<int>();
gw.intid = config[s]["intid"].as<int32_t>();
gw.api = config[s]["api"].as<std::string>();
gw.brokerid = config[s]["brokerid"].as<std::string>();
auto mdips = config[s]["md_address"].as<std::vector<string>>();
gw.md_address.assign(mdips.begin(),mdips.end());
gw.md_address.assign(mdips.begin(), mdips.end());
auto tdips = config[s]["td_address"].as<std::vector<string>>();
gw.td_address.assign(tdips.begin(),tdips.end());
gw.td_address.assign(tdips.begin(), tdips.end());
gw.userid = config[s]["userid"].as<std::string>();
gw.password = config[s]["password"].as<std::string>();
gw.auth_code = config[s]["auth_code"].as<std::string>();
Expand All @@ -96,39 +113,35 @@ namespace StarQuant {
gw.publicstream = config[s]["publicstream"].as<std::string>();
gw.privatestream = config[s]["privatestream"].as<std::string>();
_gatewaymap[s] = gw;
}
}

// read risk info
riskcheck = config["risk"]["check"].as<bool>();
sizeperorderlimit = config["risk"]["sizeperorder"].as<int>();
sizeperorderlimit = config["risk"]["sizeperorder"].as<int32_t>();
cashperorderlimit = config["risk"]["cashperorder"].as<double>();
ordercountlimit = config["risk"]["ordercount"].as<int>();
ordercountlimit = config["risk"]["ordercount"].as<int32_t>();
cashlimit = config["risk"]["cash"].as<double>();
ordersizelimit = config["risk"]["ordersize"].as<int>();
ordercountperseclimit = config["risk"]["ordercountpersec"].as<int>();
ordersizelimit = config["risk"]["ordersize"].as<int32_t>();
ordercountperseclimit = config["risk"]["ordercountpersec"].as<int32_t>();
}
catch(exception &e){
fmt::print("Read Config exception:{}.",e.what());
catch(exception &e) {
fmt::print("Read Config exception:{}.", e.what());
}
catch(...){
catch(...) {
fmt::print("Read Config error!");
}

}

string CConfig::configDir()
{
string CConfig::configDir() {
// return boost::filesystem::current_path().string();
return _config_dir;
}

string CConfig::logDir()
{
string CConfig::logDir() {
return _log_dir;
}

string CConfig::dataDir()
{
string CConfig::dataDir() {
return _data_dir;
}

Expand All @@ -143,13 +156,13 @@ namespace StarQuant {
string fullsymbol;
string num = symbol;
string alpha = symbol;
num.erase(std::remove_if(num.begin(),num.end(),&::isalpha),num.end());
alpha.erase(std::remove_if(alpha.begin(),alpha.end(),&::isdigit),alpha.end());
num.erase(std::remove_if(num.begin(), num.end(), &::isalpha), num.end());
alpha.erase(std::remove_if(alpha.begin(), alpha.end(), &::isdigit), alpha.end());
string tmp = instrument2sec[alpha];
fullsymbol = tmp + " " + num;
return fullsymbol;
}




Expand Down
Loading

0 comments on commit 0239ed1

Please sign in to comment.