📄 stock_data.h
字号:
#ifndef __HBSTOCK2_STOCK_DATA_H__
#define __HBSTOCK2_STOCK_DATA_H__
#include <vector>
#include <map>
#include <set>
#include <string>
#include <ace/Refcounted_Auto_Ptr.h>
#include <ace/Service_Object.h>
#include <ace/Null_Mutex.h>
#include <ace/DLL.h>
#include "hbstock2/data_config.h"
#include "hbstock2/hbstock_exception.h"
#include "gnu/app_config.h"
#include "hbstock2/model_base.h"
namespace hbstock2
{
enum DIV_TYPE {FRONT,NONE,BACK}; //div type
struct StockData
{
char day[LEN_DATE+1];
float open_price;
float close_price;
float high_price;
float low_price;
long volume;
double money;
float last_close_price;
public :
StockData() :
open_price(0),
close_price(0),
high_price(0),
low_price(0),
volume(0),
money(0),
last_close_price(0)
{
day[0] = 0;
}
};
typedef std::vector<StockData> VectStockData;
typedef ACE_Refcounted_Auto_Ptr<VectStockData,ACE_Null_Mutex> VectStockDataPtr;
struct Market
{
std::string code;
std::string title;
public :
Market() :
code("w"),
title("w")
{}
};
typedef std::vector<Market> VectMarket;
typedef ACE_Refcounted_Auto_Ptr<VectMarket,ACE_Null_Mutex> VectMarketPtr;
class DataLoader : public ModelConfigParameter,
public ModelBaseInfo,
public ACE_Service_Object
{
public:
// function for manger
virtual ~DataLoader(){}
virtual int init (int argc, ACE_TCHAR *argv[]) = 0;
virtual int fini (void) = 0;
virtual int info (ACE_TCHAR **str, size_t len) const = 0;
//function for market
virtual const VectMarketPtr get_support_market() const = 0;
virtual bool is_support_market(const std::string& market_code) const = 0;
virtual bool is_support_day_data() const = 0;
virtual bool is_support_min5_data() const = 0;
virtual bool is_support_div(const std::string& str_market_code) const = 0;
// function for stock data
//get stock code of index
virtual std::string get_stock_code_of_index(const std::string& market_code) = 0;
virtual bool check_transform_stock_code(const std::string& str_stock_code_in,
std::string& str_stock_code_out,std::string& str_market_code) = 0;
//get stocks
virtual bool get_stock_code(std::vector<std::string>& vect_stock_code,
const std::string& market_code, const char* p_prefix_name=NULL)
throw (stock_data_exception) = 0;
virtual bool load_day_data(VectStockData& vect_stockdata,
const std::string& str_stock_code,
const char* p_ch_from_date=NULL,
const char* p_ch_to_date=NULL,
DIV_TYPE div_type=NONE,
bool is_included_div_data=true)
throw (stock_data_exception) = 0;
virtual bool load_day_data(VectStockData& vect_stockdata,
const std::string& str_stock_code,
const char* p_ch_date=NULL,
int data_length=0,
bool is_previous_data=true,
DIV_TYPE div_type=NONE ,
bool is_included_div_data=true)
throw (stock_data_exception) = 0;
virtual bool load_min5_data(VectStockData& vect_stockdata,
const std::string& str_stock_code,
const char* p_ch_from_date=NULL,
const char* p_ch_to_date=NULL,
DIV_TYPE div_type=NONE,
bool is_included_div_data=true)
throw (stock_data_exception) = 0;
virtual bool load_min5_data(VectStockData& vect_stockdata,
const std::string& str_stock_code,
const char* p_ch_date=NULL,
int data_length=0,
bool is_previous_data=true,
DIV_TYPE div_type=NONE ,
bool is_included_div_data=true)
throw (stock_data_exception) = 0;
}; //DataLoader
// ACE_Thread_Mutex
typedef ACE_Refcounted_Auto_Ptr<DataLoader,ACE_Null_Mutex> DataLoaderPtr;
const int MIN_10 = 2;
const int MIN_15 = 3;
const int MIN_30 = 6;
const int MIN_60 = 12;
const int DAY_OF_WEEK = -1;
const int DAY_OF_MONTH = -2;
const int DAY_OF_YEAR = -4;
// transmit data
void transmit_day_data(VectStockData& vect_to_data,const VectStockData& vect_from_data,int ndays);
void transmit_min5_data(VectStockData& vect_to_data,const VectStockData& vect_from_data,int ndays);
} // namespace hbstock2
#endif // #ifndef __HBSTOCK2_STOCK_DATA_H__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -