-
Notifications
You must be signed in to change notification settings - Fork 108
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
252 changed files
with
1,967 additions
and
279 deletions.
There are no files selected for viewing
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Empty file modified
0
examples/demo-project/testmodule/default/default_testmodule.py
100644 → 100755
Empty file.
Empty file.
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from finhack.library.mydb import mydb | ||
class Calendar: | ||
def get_calendar(start_time,end_time,market): | ||
start_time=start_time.replace('-','')[0:8] | ||
end_time=end_time.replace('-','')[0:8] | ||
calendar={} | ||
|
||
if market=='astock': | ||
calendar=Calendar.get_astock_calendar(start_time,end_time) | ||
calendar = [f"{date[:4]}-{date[4:6]}-{date[6:]}" for date in calendar] | ||
return calendar | ||
|
||
|
||
#获取A股交易日历 | ||
def get_astock_calendar(start_time,end_time): | ||
cal=mydb.selectToDf(f"select cal_date from astock_trade_cal where is_open=1 \ | ||
and exchange='SSE' and cal_date>={start_time} and cal_date<={end_time} \ | ||
order by cal_date asc",'tushare') | ||
return cal['cal_date'].tolist() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,120 @@ | ||
from trader.miniqmt.dictobj import DictObj | ||
|
||
|
||
g=DictObj({ | ||
'preds':None | ||
}) | ||
|
||
|
||
context_attr= { | ||
'id':'', | ||
'universe':[], | ||
'previous_date':None, | ||
'current_dt':None, | ||
'params':None, | ||
'trade':DictObj({ | ||
'market':'', | ||
'model_id':'', | ||
'start_time':'', | ||
'end_time':'', | ||
'benchmark':'000001', | ||
'log_type':'', | ||
'record_type':'', | ||
'strategy':'', | ||
'order_volume_ratio':1, | ||
'slip':0, | ||
'sliptype':'pricerelated', | ||
'rule_list':'' | ||
}), | ||
'g':g, | ||
'account':DictObj({ | ||
'username':'', | ||
'password':'', | ||
'account_id':'', | ||
'open_tax':0, | ||
'close_tax':0.001, | ||
'open_commission':0.0003, | ||
'close_commission':0.0003, | ||
'close_today_commission':0, | ||
'min_commission':5 | ||
|
||
}), | ||
|
||
'portfolio':DictObj({ | ||
'inout_cash':0, | ||
'cash':0, | ||
'transferable_cash':0, | ||
'locked_cash':0, | ||
'margin':0, | ||
'total_value':0, | ||
'previous_value':0, | ||
'returns':0, | ||
'starting_cash':0, | ||
'positions_value':0, | ||
'portfolio_value':0, | ||
'locked_cash_by_purchase':0, | ||
'locked_cash_by_redeem':0, | ||
'locked_amound_by_redeen':0, | ||
'positions':{ | ||
|
||
} | ||
}), | ||
|
||
'data':DictObj({ | ||
'calendar':[], | ||
'event_interval_list':[], | ||
'event_list':[], | ||
'data_source':'file', | ||
'daily_info':None, | ||
'dividend':{}, | ||
'quote':None, | ||
'client':None | ||
}), | ||
|
||
'logs':DictObj({ | ||
'trade_list':[], | ||
'order_list':[], | ||
'position_list':[], | ||
'return_list':[], | ||
'trade_returns':[], | ||
'history':{} | ||
}), | ||
'performance':DictObj({ | ||
'returns':[], | ||
'bench_returns':[], | ||
'turnover':[], | ||
'win':0, | ||
'win_ratio':0, | ||
'trade_num':0, | ||
'indicators':{} | ||
}) | ||
|
||
} | ||
context=DictObj(context_attr) | ||
|
||
|
||
|
||
|
||
#'position':{ | ||
# 'xxx':sid 标的代码 | ||
# enable_amount 可用数量 | ||
# amount 总持仓数量 | ||
# last_sale_price 最新价格 | ||
# cost_basis 持仓成本价格(期货不支持) | ||
# today_amount 今日开仓数量(期货不支持,且仅回测有效) | ||
# 期货专用字段: | ||
# delivery_date 交割日,期货使用 | ||
# today_short_amount 空头今仓数量 | ||
# today_long_amount 多头今仓数量 | ||
# long_cost_basis 多头持仓成本 | ||
# short_cost_basis 空头持仓成本 | ||
# margin_rate 保证金比例 | ||
# contract_multiplier 合约乘数 | ||
# long_amount 多头总持仓量 | ||
# short_amount 空头总持仓量 | ||
# long_pnl 多头浮动盈亏 | ||
# short_pnl 空头浮动盈亏 | ||
# long_enable_amount 多头可用数量 | ||
# short_enable_amount 多空头可用数量 | ||
# business_type 业务类型 | ||
# }, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
from finhack.library.config import Config | ||
from runtime.constant import * | ||
from finhack.market.astock.astock import AStock | ||
import json | ||
import pickle | ||
import pandas as pd | ||
import os | ||
import time | ||
from datetime import datetime | ||
import trader.miniqmt.calendar | ||
import finhack.library.log as Log | ||
from finhack.core.classes.dictobj import DictObj | ||
from trader.miniqmt.qmtClient import qclient | ||
|
||
|
||
class Data: | ||
def get_daily_info(code,context,date=None): | ||
return qclient.getInfo(code) | ||
|
||
#根据当前时间获取价格 | ||
def get_price(code,context=None): | ||
return qclient.getPrice(code) | ||
|
||
|
Oops, something went wrong.