Skip to content

Commit

Permalink
Merge pull request #1345 from yutiansut/master
Browse files Browse the repository at this point in the history
#update for accountpro & update to 1.6.8
  • Loading branch information
yutiansut committed Nov 9, 2019
2 parents f329e91 + 26cb498 commit b4daba9
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 10 deletions.
6 changes: 3 additions & 3 deletions QUANTAXIS/QAARP/QAAccountPro.py
Expand Up @@ -127,7 +127,7 @@ def __init__(
self.datetime = None
self.running_time = datetime.datetime.now()
self.quantaxis_version = __version__
self.client = DATABASE.accountPro
self.client = DATABASE.account
self.start_ = start
self.end_ = end
### 下面是数据库创建index部分, 此部分可能导致部分代码和原先不兼容
Expand Down Expand Up @@ -206,8 +206,8 @@ def __init__(
self.frozen = {} # 冻结资金(保证金)
self.finishedOrderid = []

# if auto_reload:
# self.reload()
if auto_reload:
self.reload()

def __repr__(self):
return '< QA_AccountPRO {} market: {}>'.format(
Expand Down
26 changes: 20 additions & 6 deletions QUANTAXIS/QAARP/QAPortfolio.py
Expand Up @@ -219,10 +219,22 @@ def drop_account(self, account_cookie):

if account_cookie in self.account_list:
res = self.account_list.remove(account_cookie)

try:
DATABASE.account.find_one_and_delete({
'account_cookie': account_cookie,
'portfolio_cookie': self.portfolio_cookie,
'user_cookie': self.user_cookie
})
except:
pass

self.cash.append(
self.cash[-1] + self.get_account_by_cookie(res).init_cash
)
self.save()
return True

else:
raise RuntimeError(
'account {} is not in the portfolio'.format(account_cookie)
Expand Down Expand Up @@ -293,6 +305,8 @@ def new_accountpro(
account_cookie=account_cookie,
user_cookie=self.user_cookie,
portfolio_cookie=self.portfolio_cookie,
init_cash=init_cash,
market_type=market_type,
auto_reload=True
)

Expand Down Expand Up @@ -360,12 +374,12 @@ def new_account(
return self.get_account_by_cookie(account_cookie)

def create_stockaccount(self, account_cookie, init_cash, init_hold):
return self.new_account(account_cookie= account_cookie, init_cash=init_cash, init_hold=init_hold,
market_type=MARKET_TYPE.STOCK_CN,allow_t0=False,)
return self.new_account(account_cookie=account_cookie, init_cash=init_cash, init_hold=init_hold,
market_type=MARKET_TYPE.STOCK_CN, allow_t0=False,)

def create_futureaccount(self, account_cookie, init_cash, init_hold, reload):
return self.new_account(account_cookie= account_cookie, init_cash=init_cash, init_hold=init_hold,
market_type=MARKET_TYPE.FUTURE_CN,allow_t0=False,)
return self.new_account(account_cookie=account_cookie, init_cash=init_cash, init_hold=init_hold,
market_type=MARKET_TYPE.FUTURE_CN, allow_t0=False,)

def get_account_by_cookie(self, cookie):
'''
Expand Down Expand Up @@ -745,12 +759,12 @@ def trade(self):
@property
def history_table(self):
return pd.concat([item.history_table for item in self.accounts]
).sort_index()
).sort_index()

@property
def trade_day(self):
return pd.concat([pd.Series(item.trade_day) for item in self.accounts]
).drop_duplicates().sort_values().tolist()
).drop_duplicates().sort_values().tolist()

@property
def trade_range(self):
Expand Down
2 changes: 1 addition & 1 deletion QUANTAXIS/__init__.py
Expand Up @@ -31,7 +31,7 @@
2017/4/8
"""

__version__ = '1.6.7'
__version__ = '1.6.8'
__author__ = 'yutiansut'

import argparse
Expand Down

0 comments on commit b4daba9

Please sign in to comment.