From 153fe91c077e26f39dc6ef63792b5a4f64f91299 Mon Sep 17 00:00:00 2001 From: yutiansut Date: Wed, 15 Jan 2020 02:00:56 +0800 Subject: [PATCH 1/4] #update for QAAccount --- QUANTAXIS/QAARP/QAAccount.py | 204 ++++++- ...351\200\237\346\216\245\345\217\243.ipynb" | 514 ++++++++++++++++++ 2 files changed, 714 insertions(+), 4 deletions(-) create mode 100644 "jupyterexample/QAAccount\347\232\204\344\270\200\344\270\252\345\277\253\351\200\237\346\216\245\345\217\243.ipynb" diff --git a/QUANTAXIS/QAARP/QAAccount.py b/QUANTAXIS/QAARP/QAAccount.py index 772c0e554..26f29b5e5 100755 --- a/QUANTAXIS/QAARP/QAAccount.py +++ b/QUANTAXIS/QAARP/QAAccount.py @@ -50,6 +50,7 @@ MARKET_TYPE, ORDER_DIRECTION, ORDER_MODEL, + ORDER_STATUS, RUNNING_ENVIRONMENT, TRADE_STATUS, EXCHANGE_ID @@ -301,8 +302,6 @@ def __init__( """ super().__init__() - # warnings.warn('QUANTAXIS 1.0.46 has changed the init_assets ==> init_cash, please pay attention to this change if you using init_cash to initial an account class,\ - # ', DeprecationWarning, stacklevel=2) self._history_headers = [ 'datetime', # 日期/时间 'code', # 品种 @@ -993,14 +992,24 @@ def weights(x): ).sort_index().loc[:datetime].groupby('code').apply(weights ).dropna() - def reset_assets(self, init_cash=None): - 'reset_history/cash/' + def reset_assets(self, init_cash=1000000): + """重置账户 + + Keyword Arguments: + init_cash {int} -- [description] (default: {1000000}) + """ self.sell_available = copy.deepcopy(self.init_hold) self.history = [] self.init_cash = init_cash self.cash = [self.init_cash] self.cash_available = self.cash[-1] # 在途资金 + self.time_index_max = [] + + self.frozen = {} # 冻结资金(保证金) + self.finishedOrderid = [] + + def receive_simpledeal( self, code, @@ -2025,6 +2034,193 @@ def get_history(self, start, end): pd.Timestamp(end))] + + def generate_randomtrade(code, frequence, start, end): + """快速生成一坨交易 + + Arguments: + code {[type]} -- [description] + frequence {[type]} -- [description] + start {[type]} -- [description] + end {[type]} -- [description] + + Keyword Arguments: + num {int} -- [description] (default: {100}) + """ + + # 先生成交易日 + for trade_day in QA_util_get_trade_range(start, end): + + self.receive_simpledeal() + + + + def buy(self, code:str, price:float, amount:int, time:str, order_model:str = ORDER_MODEL.LIMIT, amount_model:str = AMOUNT_MODEL.BY_AMOUNT, if_selfdeal:bool =False): + """self.buy == self.buy_open 自动识别股票/期货 + + 一个方便使用的sendorder的二次封装 方便直接调用 + + Arguments: + code {str} -- [description] + price {float} -- [description] + amount {int} -- [description] + time {str} -- [description] + + Keyword Arguments: + order_model {str} -- [description] (default: {ORDER_MODEL.LIMIT}) + amount_model {str} -- [description] (default: {AMOUNT_MODEL.BY_AMOUNT}) + if_selfdeal {bool} -- [description] (default: {False}) + """ + + if self.market_type== MARKET_TYPE.FUTURE_CN: + towards=ORDER_DIRECTION.BUY_OPEN + else: + towards=QA.ORDER_DIRECTION.BUY + + + + order = self.send_order( + code=code, time=time, amount=amount, + towards=towards, price=price, + order_model=order_model, + amount_model=amount_model + ) + + if if_selfdeal: + if order: + + order.trade('buy', order.price, + order.amount, order.datetime) + self.orders.set_status(order.order_id, ORDER_STATUS.SUCCESS_ALL) + + else: + return order + + def sell(self, code:str, price:float, amount:int, time:str, order_model:str = ORDER_MODEL.LIMIT, amount_model:str = AMOUNT_MODEL.BY_AMOUNT, if_selfdeal:bool =False): + """self.sell == self.sell_open 自动识别股票/期货 + + 一个方便使用的sendorder的二次封装 方便直接调用 + + Arguments: + code {str} -- [description] + price {float} -- [description] + amount {int} -- [description] + time {str} -- [description] + + Keyword Arguments: + order_model {str} -- [description] (default: {ORDER_MODEL.LIMIT}) + amount_model {str} -- [description] (default: {AMOUNT_MODEL.BY_AMOUNT}) + if_selfdeal {bool} -- [description] (default: {False}) + """ + + if self.market_type== MARKET_TYPE.FUTURE_CN: + towards=ORDER_DIRECTION.SELL_OPEN + else: + towards=QA.ORDER_DIRECTION.SELL + + + + order = self.send_order( + code=code, time=time, amount=amount, + towards=towards, price=price, + order_model=order_model, + amount_model=amount_model + ) + + if if_selfdeal: + if order: + order.trade('sell', order.price, + order.amount, order.datetime) + self.orders.set_status(order.order_id, ORDER_STATUS.SUCCESS_ALL) + else: + return order + + + def buy_close(self, code:str, price:float, amount:int, time:str, order_model:str = ORDER_MODEL.LIMIT, amount_model:str = AMOUNT_MODEL.BY_AMOUNT, if_selfdeal:bool =False): + """自动识别股票/期货 + + 一个方便使用的sendorder的二次封装 方便直接调用 + + Arguments: + code {str} -- [description] + price {float} -- [description] + amount {int} -- [description] + time {str} -- [description] + + Keyword Arguments: + order_model {str} -- [description] (default: {ORDER_MODEL.LIMIT}) + amount_model {str} -- [description] (default: {AMOUNT_MODEL.BY_AMOUNT}) + if_selfdeal {bool} -- [description] (default: {False}) + """ + + if self.market_type== MARKET_TYPE.FUTURE_CN: + towards=ORDER_DIRECTION.BUY_CLOSE + else: + print("WARING: 当前账户是股票账户, 不应该使用此接口") + towards=QA.ORDER_DIRECTION.BUY + + + + order = self.send_order( + code=code, time=time, amount=amount, + towards=towards, price=price, + order_model=order_model, + amount_model=amount_model + ) + + if if_selfdeal: + if order: + order.trade('buyclose', order.price, + order.amount, order.datetime) + self.orders.set_status(order.order_id, ORDER_STATUS.SUCCESS_ALL) + else: + return order + + def sell_close(self, code:str, price:float, amount:int, time:str, order_model:str = ORDER_MODEL.LIMIT, amount_model:str = AMOUNT_MODEL.BY_AMOUNT, if_selfdeal:bool =False): + """self.buy == self.buy_open 自动识别股票/期货 + + 一个方便使用的sendorder的二次封装 方便直接调用 + + Arguments: + code {str} -- [description] + price {float} -- [description] + amount {int} -- [description] + time {str} -- [description] + + Keyword Arguments: + order_model {str} -- [description] (default: {ORDER_MODEL.LIMIT}) + amount_model {str} -- [description] (default: {AMOUNT_MODEL.BY_AMOUNT}) + if_selfdeal {bool} -- [description] (default: {False}) + """ + + if self.market_type== MARKET_TYPE.FUTURE_CN: + towards=ORDER_DIRECTION.SELL_CLOSE + else: + print("WARING: 当前账户是股票账户, 不应该使用此接口") + towards=QA.ORDER_DIRECTION.SELL + + + + order = self.send_order( + code=code, time=time, amount=amount, + towards=towards, price=price, + order_model=order_model, + amount_model=amount_model + ) + + if if_selfdeal: + if order: + order.trade('sell', order.price, + order.amount, order.datetime) + self.orders.set_status(order.order_id, ORDER_STATUS.SUCCESS_ALL) + else: + return order + + + buy_open = buy + sell_open = sell + + class Account_handler(): def __init__(self): diff --git "a/jupyterexample/QAAccount\347\232\204\344\270\200\344\270\252\345\277\253\351\200\237\346\216\245\345\217\243.ipynb" "b/jupyterexample/QAAccount\347\232\204\344\270\200\344\270\252\345\277\253\351\200\237\346\216\245\345\217\243.ipynb" new file mode 100644 index 000000000..bd9e2c384 --- /dev/null +++ "b/jupyterexample/QAAccount\347\232\204\344\270\200\344\270\252\345\277\253\351\200\237\346\216\245\345\217\243.ipynb" @@ -0,0 +1,514 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 1, + "metadata": {}, + "outputs": [], + "source": [ + "import QUANTAXIS as QA" + ] + }, + { + "cell_type": "code", + "execution_count": 2, + "metadata": {}, + "outputs": [], + "source": [ + "user = QA.QA_User(username='admin', password='admin')" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + " prortfolio with user_cookie USER_lT8yva0f already exist!!\n" + ] + } + ], + "source": [ + "port = user.new_portfolio('test_newAccounts')" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "metadata": {}, + "outputs": [], + "source": [ + "x1 = port.new_account('x1', market_type=QA.MARKET_TYPE.FUTURE_CN)" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[]" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x1.history" + ] + }, + { + "cell_type": "code", + "execution_count": 6, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "< QA_Order realorder_id Order_uyB1xlGT datetime:2020-01-10 09:31:00 code:RBL8 amount:1 price:3600 towards:2 btype:future_cn order_id:Order_uyB1xlGT account:x1 status:queued >" + ] + }, + "execution_count": 6, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x1.buy('RBL8', 3600, amount=1, time = '2020-01-10')" + ] + }, + { + "cell_type": "code", + "execution_count": 7, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "QAACCOUNT ==> receive deal\n" + ] + } + ], + "source": [ + "x1.buy('RBL8', 3600, amount=1, time = '2020-01-10', if_selfdeal=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 8, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
datetimecodepriceamountcashorder_idrealorder_idtrade_idaccount_cookiecommissiontaxmessagefrozendirectiontotal_frozen
02020-01-10 09:31:00RBL83600.01996756.4Order_tuG7OnATOrder_tuG7OnATbuyx13.60None3240.023240.0
\n", + "
" + ], + "text/plain": [ + " datetime code price amount cash order_id \\\n", + "0 2020-01-10 09:31:00 RBL8 3600.0 1 996756.4 Order_tuG7OnAT \n", + "\n", + " realorder_id trade_id account_cookie commission tax message frozen \\\n", + "0 Order_tuG7OnAT buy x1 3.6 0 None 3240.0 \n", + "\n", + " direction total_frozen \n", + "0 2 3240.0 " + ] + }, + "execution_count": 8, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x1.history_table" + ] + }, + { + "cell_type": "code", + "execution_count": 13, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[< QA_Order realorder_id Order_uyB1xlGT datetime:2020-01-10 09:31:00 code:RBL8 amount:1 price:3600 towards:2 btype:future_cn order_id:Order_uyB1xlGT account:x1 status:queued >]" + ] + }, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x1.orders.pending" + ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
_statusaccount_cookieamountamount_modelbrokercallbackcancel_amountcodecommission_coeffdate...strategytax_coefftime_conditiontowardstrade_amounttrade_idtrade_pricetrade_timetypeuser_cookie
0queuedx11by_amountbacktest<bound method QA_Account.receive_deal of < QA_...0RBL80.000252020-01-10...None0.001GFD20[]0.0[]future_cnUSER_lT8yva0f
0success_allx11by_amountbacktest<bound method QA_Account.receive_deal of < QA_...0RBL80.000252020-01-10...None0.001GFD21[buy]3600.0[2020-01-10 09:31:00]future_cnUSER_lT8yva0f
\n", + "

2 rows × 33 columns

\n", + "
" + ], + "text/plain": [ + " _status account_cookie amount amount_model broker \\\n", + "0 queued x1 1 by_amount backtest \n", + "0 success_all x1 1 by_amount backtest \n", + "\n", + " callback cancel_amount code \\\n", + "0 receive deal\n" + ] + } + ], + "source": [ + "x1.sell_close('RBL8', 3603, amount=1, time = '2020-01-13', if_selfdeal=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
datetimecodepriceamountcashorder_idrealorder_idtrade_idaccount_cookiecommissiontaxmessagefrozendirectiontotal_frozen
02020-01-10 09:31:00RBL83600.01996756.400Order_tuG7OnATOrder_tuG7OnATbuyx13.6000None3240.023240.0
12020-01-13 09:31:00RBL83603.0-11000022.797Order_7T9KasMzOrder_7T9KasMzsellx13.6030None0.0-30.0
\n", + "
" + ], + "text/plain": [ + " datetime code price amount cash order_id \\\n", + "0 2020-01-10 09:31:00 RBL8 3600.0 1 996756.400 Order_tuG7OnAT \n", + "1 2020-01-13 09:31:00 RBL8 3603.0 -1 1000022.797 Order_7T9KasMz \n", + "\n", + " realorder_id trade_id account_cookie commission tax message frozen \\\n", + "0 Order_tuG7OnAT buy x1 3.600 0 None 3240.0 \n", + "1 Order_7T9KasMz sell x1 3.603 0 None 0.0 \n", + "\n", + " direction total_frozen \n", + "0 2 3240.0 \n", + "1 -3 0.0 " + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x1.history_table" + ] + } + ], + "metadata": { + "kernelspec": { + "display_name": "Python 3", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.7.4" + } + }, + "nbformat": 4, + "nbformat_minor": 2 +} From c1c13516e4cc675d75b1a094f4cd3e9e578bc1f5 Mon Sep 17 00:00:00 2001 From: yutiansut Date: Wed, 15 Jan 2020 02:02:18 +0800 Subject: [PATCH 2/4] #update --- ...351\200\237\346\216\245\345\217\243.ipynb" | 173 +++++++++++++++--- 1 file changed, 150 insertions(+), 23 deletions(-) diff --git "a/jupyterexample/QAAccount\347\232\204\344\270\200\344\270\252\345\277\253\351\200\237\346\216\245\345\217\243.ipynb" "b/jupyterexample/QAAccount\347\232\204\344\270\200\344\270\252\345\277\253\351\200\237\346\216\245\345\217\243.ipynb" index bd9e2c384..06e3a63a7 100644 --- "a/jupyterexample/QAAccount\347\232\204\344\270\200\344\270\252\345\277\253\351\200\237\346\216\245\345\217\243.ipynb" +++ "b/jupyterexample/QAAccount\347\232\204\344\270\200\344\270\252\345\277\253\351\200\237\346\216\245\345\217\243.ipynb" @@ -72,7 +72,7 @@ { "data": { "text/plain": [ - "< QA_Order realorder_id Order_uyB1xlGT datetime:2020-01-10 09:31:00 code:RBL8 amount:1 price:3600 towards:2 btype:future_cn order_id:Order_uyB1xlGT account:x1 status:queued >" + "< QA_Order realorder_id Order_qdKFaD34 datetime:2020-01-10 09:31:00 code:RBL8 amount:1 price:3600 towards:2 btype:future_cn order_id:Order_qdKFaD34 account:x1 status:queued >" ] }, "execution_count": 6, @@ -152,8 +152,8 @@ " 3600.0\n", " 1\n", " 996756.4\n", - " Order_tuG7OnAT\n", - " Order_tuG7OnAT\n", + " Order_oJuVE4j8\n", + " Order_oJuVE4j8\n", " buy\n", " x1\n", " 3.6\n", @@ -169,10 +169,10 @@ ], "text/plain": [ " datetime code price amount cash order_id \\\n", - "0 2020-01-10 09:31:00 RBL8 3600.0 1 996756.4 Order_tuG7OnAT \n", + "0 2020-01-10 09:31:00 RBL8 3600.0 1 996756.4 Order_oJuVE4j8 \n", "\n", " realorder_id trade_id account_cookie commission tax message frozen \\\n", - "0 Order_tuG7OnAT buy x1 3.6 0 None 3240.0 \n", + "0 Order_oJuVE4j8 buy x1 3.6 0 None 3240.0 \n", "\n", " direction total_frozen \n", "0 2 3240.0 " @@ -189,16 +189,16 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 9, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "[< QA_Order realorder_id Order_uyB1xlGT datetime:2020-01-10 09:31:00 code:RBL8 amount:1 price:3600 towards:2 btype:future_cn order_id:Order_uyB1xlGT account:x1 status:queued >]" + "[< QA_Order realorder_id Order_qdKFaD34 datetime:2020-01-10 09:31:00 code:RBL8 amount:1 price:3600 towards:2 btype:future_cn order_id:Order_qdKFaD34 account:x1 status:queued >]" ] }, - "execution_count": 13, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -209,7 +209,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 10, "metadata": {}, "outputs": [ { @@ -334,7 +334,7 @@ "[2 rows x 33 columns]" ] }, - "execution_count": 16, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -345,7 +345,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -356,7 +356,7 @@ "Name: amount, dtype: int64" ] }, - "execution_count": 19, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -367,7 +367,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -384,7 +384,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 13, "metadata": {}, "outputs": [ { @@ -433,8 +433,8 @@ " 3600.0\n", " 1\n", " 996756.400\n", - " Order_tuG7OnAT\n", - " Order_tuG7OnAT\n", + " Order_oJuVE4j8\n", + " Order_oJuVE4j8\n", " buy\n", " x1\n", " 3.600\n", @@ -451,8 +451,8 @@ " 3603.0\n", " -1\n", " 1000022.797\n", - " Order_7T9KasMz\n", - " Order_7T9KasMz\n", + " Order_vq5FJ7Wx\n", + " Order_vq5FJ7Wx\n", " sell\n", " x1\n", " 3.603\n", @@ -468,19 +468,91 @@ ], "text/plain": [ " datetime code price amount cash order_id \\\n", - "0 2020-01-10 09:31:00 RBL8 3600.0 1 996756.400 Order_tuG7OnAT \n", - "1 2020-01-13 09:31:00 RBL8 3603.0 -1 1000022.797 Order_7T9KasMz \n", + "0 2020-01-10 09:31:00 RBL8 3600.0 1 996756.400 Order_oJuVE4j8 \n", + "1 2020-01-13 09:31:00 RBL8 3603.0 -1 1000022.797 Order_vq5FJ7Wx \n", "\n", " realorder_id trade_id account_cookie commission tax message frozen \\\n", - "0 Order_tuG7OnAT buy x1 3.600 0 None 3240.0 \n", - "1 Order_7T9KasMz sell x1 3.603 0 None 0.0 \n", + "0 Order_oJuVE4j8 buy x1 3.600 0 None 3240.0 \n", + "1 Order_vq5FJ7Wx sell x1 3.603 0 None 0.0 \n", "\n", " direction total_frozen \n", "0 2 3240.0 \n", "1 -3 0.0 " ] }, - "execution_count": 22, + "execution_count": 13, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x1.history_table" + ] + }, + { + "cell_type": "code", + "execution_count": 14, + "metadata": {}, + "outputs": [], + "source": [ + "x1.reset_assets(1000000) # 重置账户" + ] + }, + { + "cell_type": "code", + "execution_count": 15, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
datetimecodepriceamountcashorder_idrealorder_idtrade_idaccount_cookiecommissiontaxmessagefrozendirectiontotal_frozen
\n", + "
" + ], + "text/plain": [ + "Empty DataFrame\n", + "Columns: [datetime, code, price, amount, cash, order_id, realorder_id, trade_id, account_cookie, commission, tax, message, frozen, direction, total_frozen]\n", + "Index: []" + ] + }, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -488,6 +560,61 @@ "source": [ "x1.history_table" ] + }, + { + "cell_type": "code", + "execution_count": 16, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "QAACCOUNT: THIS ACCOUNT DOESNOT HAVE ANY TRADE\n", + "QAACCOUNT: THIS ACCOUNT DOESNOT HAVE ANY TRADE\n" + ] + }, + { + "data": { + "text/plain": [ + "{'source': 'account',\n", + " 'frequence': 'day',\n", + " 'account_cookie': 'x1',\n", + " 'portfolio_cookie': 'test_newAccounts',\n", + " 'user_cookie': 'USER_lT8yva0f',\n", + " 'broker': 'backtest',\n", + " 'market_type': 'future_cn',\n", + " 'strategy_name': None,\n", + " 'current_time': 'None',\n", + " 'allow_sellopen': True,\n", + " 'allow_margin': True,\n", + " 'allow_t0': True,\n", + " 'margin_level': {},\n", + " 'init_assets': {'cash': 1000000, 'hold': {}},\n", + " 'init_cash': 1000000,\n", + " 'init_hold': {},\n", + " 'commission_coeff': 0.00025,\n", + " 'tax_coeff': 0.001,\n", + " 'cash': [1000000],\n", + " 'history': [],\n", + " 'trade_index': [],\n", + " 'running_time': '2020-01-15 00:28:34.722473',\n", + " 'quantaxis_version': '1.7.5',\n", + " 'running_environment': 'backtest',\n", + " 'start_date': None,\n", + " 'end_date': None,\n", + " 'frozen': {},\n", + " 'finished_id': []}" + ] + }, + "execution_count": 16, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x1.message" + ] } ], "metadata": { From 3f74e5e6ff9800234b137c6532f4b4b755baa120 Mon Sep 17 00:00:00 2001 From: yutiansut Date: Wed, 15 Jan 2020 03:08:55 +0800 Subject: [PATCH 3/4] #update to 1.7.7 --- QUANTAXIS/QAARP/QAAccount.py | 68 ++- QUANTAXIS/__init__.py | 2 +- ...351\200\237\346\216\245\345\217\243.ipynb" | 536 ++++++++++++++++-- 3 files changed, 551 insertions(+), 55 deletions(-) diff --git a/QUANTAXIS/QAARP/QAAccount.py b/QUANTAXIS/QAARP/QAAccount.py index 26f29b5e5..baf7d8b32 100755 --- a/QUANTAXIS/QAARP/QAAccount.py +++ b/QUANTAXIS/QAARP/QAAccount.py @@ -25,7 +25,7 @@ import copy import datetime import warnings - +import random import numpy as np import pandas as pd from pymongo import DESCENDING, ASCENDING @@ -55,6 +55,7 @@ TRADE_STATUS, EXCHANGE_ID ) +from QUANTAXIS.QAFetch.Fetcher import QA_quotation from QUANTAXIS.QAUtil.QARandom import QA_util_random_with_topic # 2017/6/4修改: 去除总资产的动态权益计算 @@ -1270,11 +1271,15 @@ def receive_simpledeal( self.cash.append( self.cash[-1] - trade_money - tax_fee - commission_fee ) - if self.allow_t0 or trade_towards == ORDER_DIRECTION.SELL: + if trade_towards in [ORDER_DIRECTION.BUY, ORDER_DIRECTION.BUY_OPEN, ORDER_DIRECTION.SELL_OPEN]: + """平仓部分的sell_available已经被提前扣减了 在sendorder中 + """ + self.sell_available[code] = self.sell_available.get( code, 0 ) + trade_amount * market_towards + if self.allow_t0: self.buy_available = self.sell_available self.cash_available = self.cash[-1] @@ -1353,7 +1358,7 @@ def receive_deal( [type] -- [description] """ - print('QAACCOUNT ==> receive deal') + print('QAACCOUNT ==> receive deal {} {} {} {}'.format(trade_time, code, trade_price, trade_towards, )) trade_time = str(trade_time) code = str(code) @@ -1511,6 +1516,7 @@ def send_order( assert (int(towards) != 0) if int(towards) in [1, 2, 3]: # 是买入的情况(包括买入.买开.买平) + if self.cash_available >= money: if self.market_type == MARKET_TYPE.STOCK_CN: # 如果是股票 买入的时候有100股的最小限制 amount = int(amount / 100) * 100 @@ -1539,10 +1545,11 @@ def send_order( float(amount * price * (1 + self.commission_coeff)) ) - print(_hold) + #print(_hold) if self.cash_available >= _money: - if _hold < 0: + if _hold < 0 and abs(_hold) >= amount: self.cash_available -= _money + self.sell_available[code] += amount flag = True else: @@ -1567,10 +1574,11 @@ def send_order( # 如果你的hold> amount>0 # 持仓数量>卖出数量 - if _hold >= amount: - self.sell_available[code] -= amount - # towards = ORDER_DIRECTION.SELL - flag = True + if int(towards) in [-1, -3]: + if _hold >= amount: + self.sell_available[code] -= amount + # towards = ORDER_DIRECTION.SELL + flag = True # 如果持仓数量<卖出数量 else: @@ -2035,7 +2043,7 @@ def get_history(self, start, end): - def generate_randomtrade(code, frequence, start, end): + def generate_randomtrade(self, code, start, end, frequence): """快速生成一坨交易 Arguments: @@ -2049,9 +2057,43 @@ def generate_randomtrade(code, frequence, start, end): """ # 先生成交易日 - for trade_day in QA_util_get_trade_range(start, end): + day = start[0:9] + for idx, item in QA_quotation(code, start, end, frequence, self.market_type, 'mongo').iterrows(): + + code = idx[1] + time = idx[0] + + if self.market_type == MARKET_TYPE.STOCK_CN: + if time != day: + self.settle() + day = time + if self.market_type == MARKET_TYPE: + self.settle() + day = time + + + price = item['close'] + holdamount = self.sell_available.get(code, 0) + + if random.random() < 0.5: + # open + + if holdamount == 0: + if random.random() < 0.5: + self.buy(code,price, amount=1, time = time, if_selfdeal=True) + else: + self.sell(code,price, amount=1, time = time,if_selfdeal=True) + else: + pass + else: + + if holdamount>0: + self.sell_close(code, price, amount=holdamount, time = time, if_selfdeal=True) + elif holdamount<0: + holdamount = abs(holdamount) + self.buy_close(code, price, amount=holdamount, time = time, if_selfdeal=True) + - self.receive_simpledeal() @@ -2210,7 +2252,7 @@ def sell_close(self, code:str, price:float, amount:int, time:str, order_model:st if if_selfdeal: if order: - order.trade('sell', order.price, + order.trade('sellclose', order.price, order.amount, order.datetime) self.orders.set_status(order.order_id, ORDER_STATUS.SUCCESS_ALL) else: diff --git a/QUANTAXIS/__init__.py b/QUANTAXIS/__init__.py index c3096fab0..30641a7e4 100755 --- a/QUANTAXIS/__init__.py +++ b/QUANTAXIS/__init__.py @@ -31,7 +31,7 @@ 2017/4/8 """ -__version__ = '1.7.6' +__version__ = '1.7.7' __author__ = 'yutiansut' import argparse diff --git "a/jupyterexample/QAAccount\347\232\204\344\270\200\344\270\252\345\277\253\351\200\237\346\216\245\345\217\243.ipynb" "b/jupyterexample/QAAccount\347\232\204\344\270\200\344\270\252\345\277\253\351\200\237\346\216\245\345\217\243.ipynb" index 06e3a63a7..630414e90 100644 --- "a/jupyterexample/QAAccount\347\232\204\344\270\200\344\270\252\345\277\253\351\200\237\346\216\245\345\217\243.ipynb" +++ "b/jupyterexample/QAAccount\347\232\204\344\270\200\344\270\252\345\277\253\351\200\237\346\216\245\345\217\243.ipynb" @@ -13,6 +13,23 @@ "cell_type": "code", "execution_count": 2, "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "此特性 为 QUANTAXIS 1.7.7 新增, 请升级QA\n" + ] + } + ], + "source": [ + "print('此特性 为 QUANTAXIS {} 新增, 请升级QA'.format(QA.__version__))" + ] + }, + { + "cell_type": "code", + "execution_count": 3, + "metadata": {}, "outputs": [], "source": [ "user = QA.QA_User(username='admin', password='admin')" @@ -20,7 +37,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -37,7 +54,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "metadata": {}, "outputs": [], "source": [ @@ -46,7 +63,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -55,7 +72,7 @@ "[]" ] }, - "execution_count": 5, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -66,16 +83,16 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "< QA_Order realorder_id Order_qdKFaD34 datetime:2020-01-10 09:31:00 code:RBL8 amount:1 price:3600 towards:2 btype:future_cn order_id:Order_qdKFaD34 account:x1 status:queued >" + "< QA_Order realorder_id Order_pIsgG8Jo datetime:2020-01-10 09:31:00 code:RBL8 amount:1 price:3600 towards:2 btype:future_cn order_id:Order_pIsgG8Jo account:x1 status:queued >" ] }, - "execution_count": 6, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -86,14 +103,14 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "QAACCOUNT ==> receive deal\n" + "QAACCOUNT ==> receive deal 2020-01-10 09:31:00 RBL8 3600.0 2\n" ] } ], @@ -103,7 +120,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -152,8 +169,8 @@ " 3600.0\n", " 1\n", " 996756.4\n", - " Order_oJuVE4j8\n", - " Order_oJuVE4j8\n", + " Order_vZVmT2cA\n", + " Order_vZVmT2cA\n", " buy\n", " x1\n", " 3.6\n", @@ -169,16 +186,16 @@ ], "text/plain": [ " datetime code price amount cash order_id \\\n", - "0 2020-01-10 09:31:00 RBL8 3600.0 1 996756.4 Order_oJuVE4j8 \n", + "0 2020-01-10 09:31:00 RBL8 3600.0 1 996756.4 Order_vZVmT2cA \n", "\n", " realorder_id trade_id account_cookie commission tax message frozen \\\n", - "0 Order_oJuVE4j8 buy x1 3.6 0 None 3240.0 \n", + "0 Order_vZVmT2cA buy x1 3.6 0 None 3240.0 \n", "\n", " direction total_frozen \n", "0 2 3240.0 " ] }, - "execution_count": 8, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -189,16 +206,16 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 10, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "[< QA_Order realorder_id Order_qdKFaD34 datetime:2020-01-10 09:31:00 code:RBL8 amount:1 price:3600 towards:2 btype:future_cn order_id:Order_qdKFaD34 account:x1 status:queued >]" + "[< QA_Order realorder_id Order_pIsgG8Jo datetime:2020-01-10 09:31:00 code:RBL8 amount:1 price:3600 towards:2 btype:future_cn order_id:Order_pIsgG8Jo account:x1 status:queued >]" ] }, - "execution_count": 9, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -209,7 +226,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -334,7 +351,7 @@ "[2 rows x 33 columns]" ] }, - "execution_count": 10, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -345,7 +362,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -356,7 +373,7 @@ "Name: amount, dtype: int64" ] }, - "execution_count": 11, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -367,14 +384,14 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 13, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "QAACCOUNT ==> receive deal\n" + "QAACCOUNT ==> receive deal 2020-01-13 09:31:00 RBL8 3603.0 -3\n" ] } ], @@ -384,7 +401,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 14, "metadata": {}, "outputs": [ { @@ -433,8 +450,8 @@ " 3600.0\n", " 1\n", " 996756.400\n", - " Order_oJuVE4j8\n", - " Order_oJuVE4j8\n", + " Order_vZVmT2cA\n", + " Order_vZVmT2cA\n", " buy\n", " x1\n", " 3.600\n", @@ -451,9 +468,9 @@ " 3603.0\n", " -1\n", " 1000022.797\n", - " Order_vq5FJ7Wx\n", - " Order_vq5FJ7Wx\n", - " sell\n", + " Order_NVimxwQM\n", + " Order_NVimxwQM\n", + " sellclose\n", " x1\n", " 3.603\n", " 0\n", @@ -468,19 +485,19 @@ ], "text/plain": [ " datetime code price amount cash order_id \\\n", - "0 2020-01-10 09:31:00 RBL8 3600.0 1 996756.400 Order_oJuVE4j8 \n", - "1 2020-01-13 09:31:00 RBL8 3603.0 -1 1000022.797 Order_vq5FJ7Wx \n", + "0 2020-01-10 09:31:00 RBL8 3600.0 1 996756.400 Order_vZVmT2cA \n", + "1 2020-01-13 09:31:00 RBL8 3603.0 -1 1000022.797 Order_NVimxwQM \n", "\n", - " realorder_id trade_id account_cookie commission tax message frozen \\\n", - "0 Order_oJuVE4j8 buy x1 3.600 0 None 3240.0 \n", - "1 Order_vq5FJ7Wx sell x1 3.603 0 None 0.0 \n", + " realorder_id trade_id account_cookie commission tax message frozen \\\n", + "0 Order_vZVmT2cA buy x1 3.600 0 None 3240.0 \n", + "1 Order_NVimxwQM sellclose x1 3.603 0 None 0.0 \n", "\n", " direction total_frozen \n", "0 2 3240.0 \n", "1 -3 0.0 " ] }, - "execution_count": 13, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -491,7 +508,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 15, "metadata": {}, "outputs": [], "source": [ @@ -500,7 +517,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -552,7 +569,7 @@ "Index: []" ] }, - "execution_count": 15, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -563,7 +580,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -607,7 +624,7 @@ " 'finished_id': []}" ] }, - "execution_count": 16, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -615,6 +632,443 @@ "source": [ "x1.message" ] + }, + { + "cell_type": "code", + "execution_count": 18, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "QAACCOUNT ==> receive deal 2019-12-03 00:00:00 RBL8 3599.0 2\n", + "QAACCOUNT ==> receive deal 2019-12-04 00:00:00 RBL8 3603.0 -3\n", + "QAACCOUNT ==> receive deal 2019-12-05 00:00:00 RBL8 3585.0 -2\n", + "QAACCOUNT ==> receive deal 2019-12-09 00:00:00 RBL8 3511.0 3\n", + "QAACCOUNT ==> receive deal 2019-12-11 00:00:00 RBL8 3537.0 -2\n", + "QAACCOUNT ==> receive deal 2019-12-12 00:00:00 RBL8 3524.0 3\n", + "QAACCOUNT ==> receive deal 2019-12-13 00:00:00 RBL8 3523.0 2\n", + "QAACCOUNT ==> receive deal 2019-12-16 00:00:00 RBL8 3480.0 -3\n", + "QAACCOUNT ==> receive deal 2019-12-18 00:00:00 RBL8 3476.0 2\n", + "QAACCOUNT ==> receive deal 2019-12-19 00:00:00 RBL8 3518.0 -3\n", + "QAACCOUNT ==> receive deal 2019-12-24 00:00:00 RBL8 3510.0 -2\n", + "QAACCOUNT ==> receive deal 2019-12-25 00:00:00 RBL8 3485.0 3\n", + "QAACCOUNT ==> receive deal 2019-12-30 00:00:00 RBL8 3545.0 -2\n", + "QAACCOUNT ==> receive deal 2020-01-09 00:00:00 RBL8 3555.0 3\n" + ] + } + ], + "source": [ + "x1.generate_randomtrade('RBL8', '2019-12-01', '2020-01-10', 'day') ## 生成随机交易" + ] + }, + { + "cell_type": "code", + "execution_count": 19, + "metadata": {}, + "outputs": [ + { + "data": { + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
datetimecodepriceamountcashorder_idrealorder_idtrade_idaccount_cookiecommissiontaxmessagefrozendirectiontotal_frozen
02019-12-03 00:00:00RBL83599.01996757.301Order_XcSehQp4Order_XcSehQp4buyx13.5990None3239.123239.1
12019-12-04 00:00:00RBL83603.0-11000032.798Order_gTqCzn0ZOrder_gTqCzn0Zsellclosex13.6030None0.0-30.0
22019-12-05 00:00:00RBL83585.0-1996802.713Order_CgIGabZLOrder_CgIGabZLsellx13.5850None3226.5-23226.5
32019-12-09 00:00:00RBL83511.011000765.702Order_8T7amXgpOrder_8T7amXgpbuyclosex13.5110None0.030.0
42019-12-11 00:00:00RBL83537.0-1997578.865Order_rLUOFvGBOrder_rLUOFvGBsellx13.5370None3183.3-23183.3
52019-12-12 00:00:00RBL83524.011000888.641Order_T1vV9MUxOrder_T1vV9MUxbuyclosex13.5240None0.030.0
62019-12-13 00:00:00RBL83523.01997714.418Order_Ao2MD38IOrder_Ao2MD38Ibuyx13.5230None3170.723170.7
72019-12-16 00:00:00RBL83480.0-11000451.638Order_EHfeBhV7Order_EHfeBhV7sellclosex13.4800None0.0-30.0
82019-12-18 00:00:00RBL83476.01997319.762Order_XLHvkeOjOrder_XLHvkeOjbuyx13.4760None3128.423128.4
92019-12-19 00:00:00RBL83518.0-11000864.644Order_cAkRpNLdOrder_cAkRpNLdsellclosex13.5180None0.0-30.0
102019-12-24 00:00:00RBL83510.0-1997702.134Order_zUXtN8wpOrder_zUXtN8wpsellx13.5100None3159.0-23159.0
112019-12-25 00:00:00RBL83485.011001107.649Order_6HfQFKCdOrder_6HfQFKCdbuyclosex13.4850None0.030.0
122019-12-30 00:00:00RBL83545.0-1997913.604Order_Z35Ts4pgOrder_Z35Ts4pgsellx13.5450None3190.5-23190.5
132020-01-09 00:00:00RBL83555.011001000.549Order_HU6wLCefOrder_HU6wLCefbuyclosex13.5550None0.030.0
\n", + "
" + ], + "text/plain": [ + " datetime code price amount cash order_id \\\n", + "0 2019-12-03 00:00:00 RBL8 3599.0 1 996757.301 Order_XcSehQp4 \n", + "1 2019-12-04 00:00:00 RBL8 3603.0 -1 1000032.798 Order_gTqCzn0Z \n", + "2 2019-12-05 00:00:00 RBL8 3585.0 -1 996802.713 Order_CgIGabZL \n", + "3 2019-12-09 00:00:00 RBL8 3511.0 1 1000765.702 Order_8T7amXgp \n", + "4 2019-12-11 00:00:00 RBL8 3537.0 -1 997578.865 Order_rLUOFvGB \n", + "5 2019-12-12 00:00:00 RBL8 3524.0 1 1000888.641 Order_T1vV9MUx \n", + "6 2019-12-13 00:00:00 RBL8 3523.0 1 997714.418 Order_Ao2MD38I \n", + "7 2019-12-16 00:00:00 RBL8 3480.0 -1 1000451.638 Order_EHfeBhV7 \n", + "8 2019-12-18 00:00:00 RBL8 3476.0 1 997319.762 Order_XLHvkeOj \n", + "9 2019-12-19 00:00:00 RBL8 3518.0 -1 1000864.644 Order_cAkRpNLd \n", + "10 2019-12-24 00:00:00 RBL8 3510.0 -1 997702.134 Order_zUXtN8wp \n", + "11 2019-12-25 00:00:00 RBL8 3485.0 1 1001107.649 Order_6HfQFKCd \n", + "12 2019-12-30 00:00:00 RBL8 3545.0 -1 997913.604 Order_Z35Ts4pg \n", + "13 2020-01-09 00:00:00 RBL8 3555.0 1 1001000.549 Order_HU6wLCef \n", + "\n", + " realorder_id trade_id account_cookie commission tax message frozen \\\n", + "0 Order_XcSehQp4 buy x1 3.599 0 None 3239.1 \n", + "1 Order_gTqCzn0Z sellclose x1 3.603 0 None 0.0 \n", + "2 Order_CgIGabZL sell x1 3.585 0 None 3226.5 \n", + "3 Order_8T7amXgp buyclose x1 3.511 0 None 0.0 \n", + "4 Order_rLUOFvGB sell x1 3.537 0 None 3183.3 \n", + "5 Order_T1vV9MUx buyclose x1 3.524 0 None 0.0 \n", + "6 Order_Ao2MD38I buy x1 3.523 0 None 3170.7 \n", + "7 Order_EHfeBhV7 sellclose x1 3.480 0 None 0.0 \n", + "8 Order_XLHvkeOj buy x1 3.476 0 None 3128.4 \n", + "9 Order_cAkRpNLd sellclose x1 3.518 0 None 0.0 \n", + "10 Order_zUXtN8wp sell x1 3.510 0 None 3159.0 \n", + "11 Order_6HfQFKCd buyclose x1 3.485 0 None 0.0 \n", + "12 Order_Z35Ts4pg sell x1 3.545 0 None 3190.5 \n", + "13 Order_HU6wLCef buyclose x1 3.555 0 None 0.0 \n", + "\n", + " direction total_frozen \n", + "0 2 3239.1 \n", + "1 -3 0.0 \n", + "2 -2 3226.5 \n", + "3 3 0.0 \n", + "4 -2 3183.3 \n", + "5 3 0.0 \n", + "6 2 3170.7 \n", + "7 -3 0.0 \n", + "8 2 3128.4 \n", + "9 -3 0.0 \n", + "10 -2 3159.0 \n", + "11 3 0.0 \n", + "12 -2 3190.5 \n", + "13 3 0.0 " + ] + }, + "execution_count": 19, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x1.history_table" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": 20, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Series([], Name: amount, dtype: float64)" + ] + }, + "execution_count": 20, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "x1.hold_available" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [] } ], "metadata": { From a0cd9d2a2655b327ed4d7cfebc06fd37cca37874 Mon Sep 17 00:00:00 2001 From: yutiansut Date: Wed, 15 Jan 2020 03:11:28 +0800 Subject: [PATCH 4/4] #update --- PULL_REQUEST_TEMPLATE.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/PULL_REQUEST_TEMPLATE.md b/PULL_REQUEST_TEMPLATE.md index de3b9f672..6e60e1e89 100755 --- a/PULL_REQUEST_TEMPLATE.md +++ b/PULL_REQUEST_TEMPLATE.md @@ -11,8 +11,6 @@ 请使用如下代码对要PR的代码进行格式化: -qa的 yapf格式也是从vnpy那拿来的 参见 https://github.com/vnpy/vnpy/blob/v2.0-DEV/.style.yapf - 使用以下代码来格式化 ``` pip install https://github.com/google/yapf/archive/master.zip