コード例 #1
0
ファイル: betting.py プロジェクト: liampauling/betdaq
    def get_orders(self,
                   SequenceNumber=-1,
                   wantSettledOrdersOnUnsettledMarkets=Boolean.T.value):
        """
        Get the initial list of orders that's need to be taken into consideration when establishing positions. 
        Information about the following orders will be returned:
            •	active orders
            •	fully matched orders
            •	cancelled orders that have a matched portion 
            •	suspended orders
            •	some settled or voided orders under some conditions

        :param SequenceNumber: lower bound cutoff for sequence updates to include, 
                               -1 will set to earliest possible sequence.
        :type SequenceNumber: int
        :param wantSettledOrdersOnUnsettledMarkets: Flag indicating whether or not information about settled orders 
                                                    on unsettled markets should be returned.
        :type wantSettledOrdersOnUnsettledMarkets: bool
        :return: orders that have changed.
        """
        params = clean_locals(locals())
        date_time_sent = datetime.datetime.utcnow()
        response = self.request('ListBootstrapOrders', params, secure=True)
        data = self.process_response(response, date_time_sent, 'Orders')
        return [
            parse_orders(order)
            for order in data.get('data', {}).get('Order', [])
        ] if data.get('data') else []
コード例 #2
0
def update_order(BetId,
                 DeltaStake,
                 Price,
                 ExpectedSelectionResetCount,
                 ExpectedWithdrawalSequenceNumber,
                 CancelOnInRunning=None,
                 CancelIfSelectionReset=None,
                 SetToBeSPIfUnmatched=None):
    """
    
    :param BetId: ID of the bet to be updated.
    :type BetId: int
    :param DeltaStake: Amount to change the stake of the bet by.
    :type DeltaStake: float
    :param Price: Price at which to place bet at.
    :param ExpectedSelectionResetCount: must match SelectionResetCount value in GetMarketInformation and GetPrices 
                                        to ensure state of the market before placing a bet. If not matching server
                                        bet will not be placed and error is raised.
    :type ExpectedSelectionResetCount: int
    :param ExpectedWithdrawalSequenceNumber: should match withdrawalSequenceNumber value in GetMarketInformation and 
                                             GetPrices. If not matching server then your bet WILL be accepted, but it 
                                             will be repriced.
    :type ExpectedWithdrawalSequenceNumber: int
    :param CancelOnInRunning: Cancel any unmatched orders when the market changes to an in-running market.
    :type CancelOnInRunning: betdaq_py.enums.Boolean
    :param CancelIfSelectionReset: Cancel any unmatched bets if the selection is reset. 
                                   This can occur when the Market is reset (eg a goal is scored).
    :type CancelIfSelectionReset: betdaq_py.enums.Boolean
    :param SetToBeSPIfUnmatched: whether to set bet to SP when market turns in play if it is unmatched.
    :type SetToBeSPIfUnmatched: betdaq_py.enums.Boolean
    :return: dictionary of the order information to update on exchange.
    """
    return clean_locals(locals())
コード例 #3
0
    def deregister_heartbeat(self):
        """
        Deregister the Punter as requiring a Heartbeat.

        :return: response of request success.
        """
        params = clean_locals(locals())
        date_time_sent = datetime.datetime.utcnow()
        response = self.request('DeregisterHeartbeat', params, secure=True)
        return self.process_response(response, date_time_sent, None)
コード例 #4
0
ファイル: marketdata.py プロジェクト: seaders/betdaq
    def get_market_withdrawals(self, MarketId):
        """
        Get the prices for a particular market.

        :param MarketId: ID of the market to check for withdrawals.
        :return: any withdrawals from the market.
        """
        params = clean_locals(locals())
        date_time_sent = datetime.datetime.utcnow()
        response = self.request('ListMarketWithdrawalHistory', params, secure=False)
        data = self.process_response(response, date_time_sent, 'Withdrawals', error_handler=err_withdrawals)
        return [parse_market_withdrawal(mkt) for mkt in listy_mc_list(data.get('data', []))] if data.get('data') else []
コード例 #5
0
ファイル: marketdata.py プロジェクト: seaders/betdaq
 def get_selection_changes(self, SelectionSequenceNumber):
     """
     Poll to see if any selections have changed since the previous poll.
     
     :param SelectionSequenceNumber: sequence of the poll to check diffs from.
     :return: any changes to selections since the given sequence number.
     """
     params = clean_locals(locals())
     date_time_sent = datetime.datetime.utcnow()
     response = self.request('ListSelectionsChangedSince', params, secure=False)
     data = self.process_response(response, date_time_sent, 'Selections', error_handler=err_selection_changes)
     return [parse_selection_changes(chg) for chg in listy_mc_list(data.get('data', []))] if data.get('data') else []
コード例 #6
0
ファイル: marketdata.py プロジェクト: seaders/betdaq
 def get_sports(self, WantPlayMarkets=None):
     """
     Get list of sports and their IDs.
     
     :param WantPlayMarkets: whether to return play or real markets
     :return: 
     """
     params = clean_locals(locals())
     date_time_sent = datetime.datetime.utcnow()
     response = self.request('ListTopLevelEvents', params, secure=False)
     data = self.process_response(response, date_time_sent, 'EventClassifiers', error_handler=err_sports)
     return [parse_sports(sport) for sport in listy_mc_list(data.get('data', []))] if data.get('data') else []
コード例 #7
0
ファイル: marketdata.py プロジェクト: seaders/betdaq
 def get_odds_ladder(self, PriceFormat=PriceFormat.Decimal.value):
     """
     Get current odds ladder.
     
     :param PriceFormat: what odds type to return. 
     :return: odds ladder
     """
     params = clean_locals(locals())
     date_time_sent = datetime.datetime.utcnow()
     response = self.request('GetOddsLadder', params, secure=False)
     data = self.process_response(response, date_time_sent, 'Ladder')
     return parse_ladder(data.get('data', [])) if data.get('data') else []
コード例 #8
0
    def get_account_balances(self):
        """
        Get summary of current balances.

        :return: account information for logged in user.
        :rtype: dict
        """
        params = clean_locals(locals())
        date_time_sent = datetime.datetime.utcnow()
        response = self.request('GetAccountBalances', params, secure=True)
        data = self.process_response(response, date_time_sent, None)
        return parse_account_balance(data.get('data',
                                              {})) if data.get('data') else {}
コード例 #9
0
    def change_account_password(self, Password):
        """
        Change the password for the logged in user.

        :param Password: new password to be used for logged in user.
        :type Password: str
        :return: None
        """
        params = clean_locals(locals())
        date_time_sent = datetime.datetime.utcnow()
        response = self.request('ChangePassword', params, secure=True)
        data = self.process_response(response, date_time_sent, None)
        return data.get('data', {})
コード例 #10
0
ファイル: betting.py プロジェクト: seaders/betdaq
    def get_single_order(self, OrderId):
        """
        Get full detail and history about an individual order.

        :param order_id: id of the order we wish to get history for.
        :type order_id: int
        :return: single orders history and current status.
        """
        params = clean_locals(locals())
        date_time_sent = datetime.datetime.utcnow()
        response = self.request('GetOrderDetails', params, secure=True)
        data = self.process_response(response, date_time_sent, None)
        return listy_mc_list(parse_single_order(data.get('data', {})) if data.get('data') else {})
コード例 #11
0
ファイル: betting.py プロジェクト: seaders/betdaq
    def suspend_orders_by_market(self, MarketId):
        """
        Suspend all orders on a given market.

        :param MarketIds: market id to be suspend orders on.
        :type MarketIds: ints
        :return: information on the suspension status of each order.
        """
        params = clean_locals(locals())
        date_time_sent = datetime.datetime.utcnow()
        response = self.request('SuspendAllOrdersOnMarket', params, secure=True)
        data = self.process_response(response, date_time_sent, 'Orders', error_handler=err_suspend_orders)
        return [parse_suspended_order(suspend) for suspend in data.get('data', [])] if data.get('data') else []
コード例 #12
0
def create_order(SelectionId,
                 Stake,
                 Price,
                 Polarity,
                 ExpectedSelectionResetCount,
                 ExpectedWithdrawalSequenceNumber,
                 CancelOnInRunning=Boolean.T,
                 CancelIfSelectionReset=Boolean.T,
                 ExpiresAt=None,
                 WithdrawalRepriceOption=WithdrawRepriceOption.Cancel,
                 KillType=OrderKillType.FillOrKillDontCancel,
                 FillOrKillThreshold=0.0,
                 PunterReferenceNumber=1):
    """
    Create an order to send to exchange.
    
    :param SelectionId: Id number of the selection on which the order is to be placed
    :type SelectionId: int
    :param Stake: Amount for which the order is to be placed for.
    :type Stake: float
    :param Price: Price at which order is to be placed.
    :type Price: float
    :param Polarity: side on which order is to be placed.
    :type Polarity: betdaq_py.enums.Polarity
    :param ExpectedSelectionResetCount: must match SelectionResetCount value in GetMarketInformation and GetPrices 
                                        to ensure state of the market before placing a bet. If not matching server
                                        bet will not be placed and error is raised.
    :type ExpectedSelectionResetCount: int
    :param ExpectedWithdrawalSequenceNumber: should match withdrawalSequenceNumber value in GetMarketInformation and 
                                             GetPrices. If not matching server then your bet WILL be accepted, but it 
                                             will be repriced.
    :type ExpectedWithdrawalSequenceNumber: int
    :param CancelOnInRunning: Cancel any unmatched orders when the market changes to an in-running market.
    :type CancelOnInRunning: betdaq_py.enums.Boolean
    :param CancelIfSelectionReset: Cancel any unmatched bets if the selection is reset. 
                                   This can occur when the Market is reset (eg a goal is scored).
    :type CancelIfSelectionReset: betdaq_py.enums.Boolean
    :param ExpiresAt: Specify a specific time for an order to expire, times in the past are instantly cancelled.
    :type ExpiresAt: datetime
    :param WithdrawalRepriceOption: Define what to do with the order in case of withdrawal, default to cancel.
    :type WithdrawalRepriceOption: betdaq_py.enums.WithdrawalRepriceOption
    :param KillType: whether to define order as a type of Fill/Kill order, default order will be limit order.
    :type KillType: betdaq_py.enums.OrderKillType
    :param FillOrKillThreshold: Lower limit for order to be partially filled. only required if KillType is 
                                FillOrKill or FillOrKillDontCancel
    :type FillOrKillThreshold: float
    :param PunterReferenceNumber: optional ID provided for customers own reference.
    :type PunterReferenceNumber: int
    :return: dictionary of all order information which can be sent to exchange.
    """
    return clean_locals(locals())
コード例 #13
0
    def get_account_transactions_by_id(self, TransactionId):
        """
        Get account transactions with transactionId greater than that specified.

        :param TransactionId: lower cutoff for transactionIds to include.
        :type TransactionId: int
        :return: account transactions greater than specified transactionId.
        """
        params = clean_locals(locals())
        date_time_sent = datetime.datetime.utcnow()
        response = self.request('ListAccountPostingsById', params, secure=True)
        data = self.process_response(response, date_time_sent, None)
        return parse_account_postings(data.get(
            'data', {})) if data.get('data') else {}
コード例 #14
0
ファイル: betting.py プロジェクト: seaders/betdaq
    def get_orders_diff(self, SequenceNumber):
        """
        Get a list of orders for the logged in user that have changed since a given sequence number.
        Utilised to maintain position information after initial position is established with list_orders.

        :param SequenceNumber: lower bound cutoff for sequence updates to include.
        :type SequenceNumber: int
        :return: orders that have changed.
        """
        params = clean_locals(locals())
        date_time_sent = datetime.datetime.utcnow()
        response = self.request('ListOrdersChangedSince', params, secure=True)
        data = self.process_response(response, date_time_sent, 'Orders')
        return [parse_orders(order) for order in data.get('data', {}).get('Order', [])] if data.get('data') else []
コード例 #15
0
    def get_account_transactions(self, StartTime, EndTime):
        """
        Get account transactions between two given date and times.

        :param StartTime: earlier time to include transactions from.
        :type StartTime: Timestamp
        :param EndTime: latest time to include transactions until.
        :type EndTime: Timestamp
        :return: account transactions over the specified period.
        """
        params = clean_locals(locals())
        date_time_sent = datetime.datetime.utcnow()
        response = self.request('ListAccountPostings', params, secure=True)
        data = self.process_response(response, date_time_sent, None)
        return parse_account_postings(data.get(
            'data', {})) if data.get('data') else {}
コード例 #16
0
 def register_heartbeat(self,
                        HeartbeatAction=HeartbeatAction.CancelOrders.value,
                        ThresholdMs=6000):
     """
     Register the Punter as requiring a Heartbeat. Must send a Pulse < every ThresholdMs to stay alive.
     
     :param HeartbeatAction: The action that should be taken if a Pulse is not received within the threshold. 
     :type HeartbeatAction: betdaq_py.enums.HeartbeatAction
     :param ThresholdMs: The maximum period (in milli-seconds) that can elapse between Pulse API calls being 
                         received before the system takes the relevant action. 
     :return: response of request success.
     """
     params = clean_locals(locals())
     date_time_sent = datetime.datetime.utcnow()
     response = self.request('RegisterHeartbeat', params, secure=True)
     return self.process_response(response, date_time_sent, None)