Skip to content

Commit

Permalink
#update future_datastruct
Browse files Browse the repository at this point in the history
  • Loading branch information
yutiansut committed Sep 25, 2018
1 parent a143b2c commit 9429cab
Show file tree
Hide file tree
Showing 7 changed files with 907 additions and 7 deletions.
23 changes: 23 additions & 0 deletions .sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.28010.2026
MinimumVisualStudioVersion = 10.0.40219.1
Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "quantaxis", "quantaxis.pyproj", "{43B2BE88-156B-4F23-B9E4-FFD299E44CBD}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{43B2BE88-156B-4F23-B9E4-FFD299E44CBD}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{43B2BE88-156B-4F23-B9E4-FFD299E44CBD}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {F87F6A44-0B74-49B7-8FF6-2CCC20E492F1}
EndGlobalSection
EndGlobal
8 changes: 6 additions & 2 deletions QUANTAXIS/QAData/QADataStruct.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ def min60(self):

class QA_DataStruct_Future_day(_quotation_base):
def __init__(self, DataFrame, dtype='future_day', if_fq=''):
super().__init__(DataFrame, dtype, if_fq)
self.type = 'future_day'
self.data = DataFrame.loc[:, [
'open', 'high', 'low', 'close', 'trade', 'position', 'price']]
Expand All @@ -323,9 +324,10 @@ class QA_DataStruct_Future_min(_quotation_base):

def __init__(self, DataFrame, dtype='future_min', if_fq=''):
# 🛠todo 期货分钟数据线的维护, 暂时用日线代替分钟线
super().__init__(DataFrame, dtype, if_fq)
self.type = 'future_day'
self.data = DataFrame.loc[:, [
'open', 'high', 'low', 'close', 'trade', 'position', 'price']]
self.data = self.data.loc[:, [
'open', 'high', 'low', 'close', 'trade', 'position', 'price','tradetime']]
self.if_fq = if_fq

# 抽象类继承
Expand Down Expand Up @@ -376,6 +378,7 @@ class QA_DataStruct_Index_day(_quotation_base):
'自定义的日线数据结构'

def __init__(self, DataFrame, dtype='index_day', if_fq=''):
super().__init__(DataFrame, dtype, if_fq)
self.data = DataFrame
self.type = dtype
self.if_fq = if_fq
Expand All @@ -402,6 +405,7 @@ class QA_DataStruct_Index_min(_quotation_base):
'自定义的分钟线数据结构'

def __init__(self, DataFrame, dtype='index_min', if_fq=''):
super().__init__(DataFrame, dtype, if_fq)
self.type = dtype
self.if_fq = if_fq
self.data = DataFrame.loc[:, [
Expand Down
4 changes: 2 additions & 2 deletions QUANTAXIS/QAFetch/QAQuery.py
Original file line number Diff line number Diff line change
Expand Up @@ -386,10 +386,10 @@ def QA_fetch_future_min(

__data.append([str(item['code']), float(item['open']), float(item['high']), float(
item['low']), float(item['close']), float(item['position']), float(item['price']), float(item['trade']),
item['datetime'], item['time_stamp'], item['date']])
item['datetime'], item['tradetime'], item['time_stamp'], item['date']])

__data = DataFrame(__data, columns=[
'code', 'open', 'high', 'low', 'close', 'position', 'price', 'trade', 'datetime', 'time_stamp', 'date'])
'code', 'open', 'high', 'low', 'close', 'position', 'price', 'trade', 'datetime','tradetime', 'time_stamp', 'date'])

__data['datetime'] = pd.to_datetime(__data['datetime'])
__data = __data.set_index('datetime', drop=False)
Expand Down
2 changes: 1 addition & 1 deletion QUANTAXIS/QAFetch/QAQuery_Advance.py
Original file line number Diff line number Diff line change
Expand Up @@ -406,7 +406,7 @@ def QA_fetch_future_min_adv(

end = start if end is None else end
if len(start) == 10:
start = '{} 09:30:00'.format(start)
start = '{} 00:00:00'.format(start)
if len(end) == 10:
end = '{} 15:00:00'.format(end)

Expand Down
2 changes: 1 addition & 1 deletion QUANTAXIS/QAFetch/QATdx.py
Original file line number Diff line number Diff line change
Expand Up @@ -1333,7 +1333,7 @@ def QA_fetch_get_future_min(code, start, end, frequence='1min', ip=None, port=No
# print(data)
# print(data.datetime)
data = data\
.assign(tradetime=pd.to_datetime(data['datetime']), code=str(code))\
.assign(tradetime=data['datetime'].apply(str), code=str(code))\
.assign(datetime=pd.to_datetime(data['datetime'].apply(QA_util_future_to_realdatetime, 1)))\
.drop(['year', 'month', 'day', 'hour', 'minute'], axis=1, inplace=False)\
.assign(date=data['datetime'].apply(lambda x: str(x)[0:10]))\
Expand Down
2 changes: 1 addition & 1 deletion QUANTAXIS/QASU/save_tdx.py
Original file line number Diff line number Diff line change
Expand Up @@ -1073,7 +1073,7 @@ def __saving_work(code, coll):
start_time = '2015-01-01'

QA_util_log_info(
'##JOB13. Future min{} Now Saving Future {} from {} to {} =={} '
'##JOB13.{} Now Saving Future {} from {} to {} =={} '
.format(['1min', '5min', '15min', '30min', '60min']
.index(type), str(code), start_time, end_time, type), ui_log=ui_log)

Expand Down
Loading

0 comments on commit 9429cab

Please sign in to comment.