taobao.trades.bought.get 搜索当前会话用户作为买家达成的交易记录
        
        搜索当前会话用户作为买家达成的交易记录(目前只能查询三个月以内的订单)
432357
def bought_get(self, session, fields=[], **kwargs):
        ''''''
        request = TOPRequest('taobao.trades.bought.get')
        if not fields:
            trade = Trade()
            fields = trade.fields
        request['fields'] = fields
        for k, v in kwargs.iteritems():
            if k not in ('start_created','end_created','status','seller_nick','type','page_no','page_size','rate_status') or v==None: continue
            request[k] = v
        self.create(self.execute(request, session))
        return self.trades
1235132
def authorize_get(self, session, fields=[]):
        ''''''
        sellerAuthorize = SellerAuthorize()
        request = TOPRequest('taobao.authorize.get')
        if not fields:
            fields = sellerAuthorize.fields
        request['fields'] = ','.join(fields)
        self.create(self.execute(request, session))
        return self.seller_authorize
1226825
def refunds_get(self, **kwargs):
        ''''''
        request = TOPRequest('taobao.increment.refunds.get')
        for k, v in kwargs.iteritems():
            if k not in ('status', 'nick', 'start_modified', 'end_modified', 'page_no', 'page_size') and v==None: continue
            request[k] = v
        self.create(self.execute(request), fields=['notify_refunds', 'total_results'], models={'notify_refunds':NotifyRefund})
        return self.notify_refunds
1094900
def get(self, session, **kwargs):
        ''''''
        request = TOPRequest('taobao.fenxiao.cooperation.get')
        for k, v in kwargs.iteritems():
            if k not in ('status', 'start_date', 'end_date', 'trade_type', 'page_no', 'page_size') and v==None: continue
            request[k] = v
        self.create(self.execute(request, session), fields=['total_results','cooperations'], models={'cooperations':Cooperation})
        return self.cooperations
946908
def __getCashToBuyStock(self):
        '''  '''
        account=self.__strategy.getAccountCopy()

        if (account.buyingPower >= account.getTotalValue() / self.__buyingRatio):
            return account.getTotalValue() / self.__buyingRatio
        else:
            return 0
831758
def context_setting(self):
        
        if self.unlock_password == "":
            raise Exception("请先配置交易解锁密码! password: {}".format(
                self.unlock_password))

        quote_ctx = ft.OpenQuoteContext(
            host=self.api_svr_ip, port=self.api_svr_port)

        if 'HK.' in self.stock:
            trade_ctx = ft.OpenHKTradeContext(
                host=self.api_svr_ip, port=self.api_svr_port)

            if self.trade_env == ft.TrdEnv.REAL:
                ret_code, ret_data = trade_ctx.unlock_trade(
                    self.unlock_password)
                if ret_code == ft.RET_OK:
                    print('解锁交易成功!')
                else:
                    raise Exception("请求交易解锁失败: {}".format(ret_data))
            else:
                print('解锁交易成功!')
        elif 'US.' in self.stock:
            if self.trade_env != 0:
                raise Exception("美股交易接口不支持仿真环境 trade_env: {}".format(
                    self.trade_env))
            trade_ctx = ft.OpenUSTradeContext(
                host=self.api_svr_ip, port=self.api_svr_port)
        else:
            raise Exception("stock输入错误 stock: {}".format(self.stock))

        return quote_ctx, trade_ctx
617218
def receivetime_delay(self, tid, days, session):
        ''''''
        request = TOPRequest('taobao.trade.receivetime.delay')
        request['tid'] = tid
        request['days'] = days
        self.create(self.execute(request, session)['trade'])
        return self
777334
def transactions(self, time=TransRange.HOUR, base="btc", quote="usd"):
        
        params = {'time': time}
        url = self._construct_url("transactions/", base, quote)
        return self._get(url, params=params, return_json=True, version=2)
219279
def get(self, session, fields=[], **kwargs):
        ''''''
        request = TOPRequest('taobao.items.get')
        if not fields:
            item = Item()
            fields = item.fields
        request['fields'] = fields
        for k, v in kwargs.iteritems():
            if k not in ('q', 'nicks', 'cid', 'props', 'product_id', 'page_no', 'order_by', 'ww_status', 'post_free', 'location_state', 'location_city', 'is_3D', 'start_score', 'end_score', 'start_volume', 'end_volume', 'one_station', 'is_cod', 'is_mall', 'is_prepay', 'genuine_security', 'stuff_status', 'start_price', 'end_price', 'page_size', 'promoted_service', 'is_xinpin') and v==None: continue
            if k == 'location_state': k = 'location.state'
            if k == 'location_city': k = 'location.city'
            request[k] = v
        
        self.create(self.execute(request, session))
        return self.items
755889
def get(self, fields=[]):
        ''''''
        request = TOPRequest('taobao.shopcats.list.get')
        if not fields:
            shopCat = ShopCat()
            fields = shopCat.fields
        request['fields'] = fields
        self.create(self.execute(request))
        return self.shop_cats
299494
def serial_fetch(self, stock_no, month, twse=None):
        
        result = ()
        self.__get_mons = month
        self.__get_no = stock_no
        self._twse = twse
        for i in range(month):
            nowdatetime = datetime.today() - relativedelta(months=i)
            tolist = self.to_list(self.fetch_data(stock_no, nowdatetime))
            result = tolist + result
        return tuple(result)
108552
def getTradeHistory(pair, connection=None, info=None, count=None):
    """"""

    if info is not None:
        info.validate_pair(pair)

    if connection is None:
        connection = common.BTCEConnection()

    response = connection.makeJSONRequest("/api/3/trades/%s" % pair)
    if type(response) is not dict:
        raise TypeError("The response is not a dict.")

    history = response.get(pair)
    if type(history) is not list:
        raise TypeError("The response is a %r, not a list." % type(history))

    result = []

    # Limit the number of items returned if requested.
    if count is not None:
        history = history[:count]

    for h in history:
        h["pair"] = pair
        t = Trade(**h)
        result.append(t)
    return result
723064
def chatlogs_get(self, chat_id, start_date, end_date, charset, session):
        ''''''
        request = TOPRequest('taobao.wangwang.eservice.chatlog.get')
        request['chat_id'] = chat_id
        request['charset'] = charset
        request['start_date'] = start_date
        request['end_date'] = end_date
        self.create(self.execute(request, session))
        return self.chatpeers
1249347
def from_dict(data, ctx):
        

        type = data.get("type")

        if type == "MARKET_ORDER":
            return MarketOrderTransaction.from_dict(data, ctx)
        if type == "ORDER_FILL":
            return OrderFillTransaction.from_dict(data, ctx)
        if type == "ORDER_CANCEL":
            return OrderCancelTransaction.from_dict(data, ctx)
        if type == "MARKET_ORDER_REJECT":
            return MarketOrderRejectTransaction.from_dict(data, ctx)
        if type == "TRADE_CLIENT_EXTENSIONS_MODIFY":
            return TradeClientExtensionsModifyTransaction.from_dict(data, ctx)
        if type == "TRADE_CLIENT_EXTENSIONS_MODIFY_REJECT":
            return TradeClientExtensionsModifyRejectTransaction.from_dict(data, ctx)
        if type == "TAKE_PROFIT_ORDER":
            return TakeProfitOrderTransaction.from_dict(data, ctx)
        if type == "STOP_LOSS_ORDER":
            return StopLossOrderTransaction.from_dict(data, ctx)
        if type == "TRAILING_STOP_LOSS_ORDER":
            return TrailingStopLossOrderTransaction.from_dict(data, ctx)
        if type == "ORDER_CANCEL_REJECT":
            return OrderCancelRejectTransaction.from_dict(data, ctx)
        if type == "TAKE_PROFIT_ORDER_REJECT":
            return TakeProfitOrderRejectTransaction.from_dict(data, ctx)
        if type == "STOP_LOSS_ORDER_REJECT":
            return StopLossOrderRejectTransaction.from_dict(data, ctx)
        if type == "TRAILING_STOP_LOSS_ORDER_REJECT":
            return TrailingStopLossOrderRejectTransaction.from_dict(data, ctx)
        if type == "CLIENT_CONFIGURE":
            return ClientConfigureTransaction.from_dict(data, ctx)
        if type == "CLIENT_CONFIGURE_REJECT":
            return ClientConfigureRejectTransaction.from_dict(data, ctx)
        if type == "CREATE":
            return CreateTransaction.from_dict(data, ctx)
        if type == "CLOSE":
            return CloseTransaction.from_dict(data, ctx)
        if type == "REOPEN":
            return ReopenTransaction.from_dict(data, ctx)
        if type == "TRANSFER_FUNDS":
            return TransferFundsTransaction.from_dict(data, ctx)
        if type == "TRANSFER_FUNDS_REJECT":
            return TransferFundsRejectTransaction.from_dict(data, ctx)
        if type == "FIXED_PRICE_ORDER":
            return FixedPriceOrderTransaction.from_dict(data, ctx)
        if type == "LIMIT_ORDER":
            return LimitOrderTransaction.from_dict(data, ctx)
        if type == "LIMIT_ORDER_REJECT":
            return LimitOrderRejectTransaction.from_dict(data, ctx)
        if type == "STOP_ORDER":
            return StopOrderTransaction.from_dict(data, ctx)
        if type == "STOP_ORDER_REJECT":
            return StopOrderRejectTransaction.from_dict(data, ctx)
        if type == "MARKET_IF_TOUCHED_ORDER":
            return MarketIfTouchedOrderTransaction.from_dict(data, ctx)
        if type == "MARKET_IF_TOUCHED_ORDER_REJECT":
            return MarketIfTouchedOrderRejectTransaction.from_dict(data, ctx)
        if type == "ORDER_CLIENT_EXTENSIONS_MODIFY":
            return OrderClientExtensionsModifyTransaction.from_dict(data, ctx)
        if type == "ORDER_CLIENT_EXTENSIONS_MODIFY_REJECT":
            return OrderClientExtensionsModifyRejectTransaction.from_dict(data, ctx)
        if type == "MARGIN_CALL_ENTER":
            return MarginCallEnterTransaction.from_dict(data, ctx)
        if type == "MARGIN_CALL_EXTEND":
            return MarginCallExtendTransaction.from_dict(data, ctx)
        if type == "MARGIN_CALL_EXIT":
            return MarginCallExitTransaction.from_dict(data, ctx)
        if type == "DELAYED_TRADE_CLOSURE":
            return DelayedTradeClosureTransaction.from_dict(data, ctx)
        if type == "DAILY_FINANCING":
            return DailyFinancingTransaction.from_dict(data, ctx)
        if type == "RESET_RESETTABLE_PL":
            return ResetResettablePLTransaction.from_dict(data, ctx)

        data = data.copy()

        return Transaction(**data)
898369
def sku_update(self, product_id, properties, session, **kwargs):
        ''''''
        request = TOPRequest('taobao.fenxiao.product.sku.update')
        request['product_id'] = product_id
        request['properties'] = properties
        for k, v in kwargs.iteritems():
            if k not in ('quantity', 'standard_price', 'agent_cost_price', 'sku_number', 'dealer_cost_price') and v==None: continue
            request[k] = v
        self.create(self.execute(request, session), fields=['result','created'], models={'created':TOPDate})
        return self
1234576
def get_buy(self, account_id, buy_id, **params):
        """"""
        response = self._get('v2', 'accounts', account_id, 'buys', buy_id, params=params)
        return self._make_api_object(response, Buy)
1263338
def upcoming_data(self, broker, data):
        '''
        
        '''
        # main thread'
        # if self.running_time is not None and self.running_time!= data.datetime[0]:
        #     for item in self.broker.keys():
        #         self._settle(item)
        self.running_time = data.datetime[0]
        for account in self.session.values():
            account.run(QA_Event(
                event_type=ENGINE_EVENT.UPCOMING_DATA,
                # args 附加的参数
                market_data=data,
                broker_name=broker,
                send_order=self.insert_order,  # 🛠todo insert_order = insert_order
                query_data=self.query_data_no_wait,
                query_order=self.query_order,
                query_assets=self.query_assets,
                query_trade=self.query_trade
            ))