Commit f681288b authored by Sergey Gernyak's avatar Sergey Gernyak

Merge remote-tracking branch 'origin/placing-order'

* origin/placing-order:
  FEAT: completed placeOrders method
  REFACTOR: integration specs ref #17
  REFACTOR: extract ListBase and SingleBase for Parsers
  FEAT: added placedOrders income params classes
  DOCS: enums for placeOrders method
  Add new version change list
parents 4ea8a570 cbf56459
......@@ -6,7 +6,7 @@ API-NG is Betfair's next generation API for developers looking to create automat
Add this line to your application's Gemfile:
gem 'betfair_api_ng_rails', '1.0.0'
gem 'betfair_api_ng_rails', '1.5.0'
And then execute:
......@@ -37,6 +37,10 @@ In this files you must specify credentials to API-NG. Also you should notice tha
Please check [wiki pages](https://github.com/alterego-labs/betfair_api_ng_rails/wiki).
## CHANGES IN 1.5.0
1. Add supporting **placeOrders** method
## CHANGES IN 1.1.0
1. Supporting all [Simple listing filtered requests](https://github.com/alterego-labs/betfair_api_ng_rails/wiki/Simple-listing-filtered-requests)
......
......@@ -5,9 +5,7 @@ require "betfair_api_ng_rails/railtie" if defined?(Rails)
require 'redis'
module BetfairApiNgRails
module Api
autoload :BaseProvider, 'betfair_api_ng_rails/api/base_provider'
autoload :BaseRequester, 'betfair_api_ng_rails/api/base_requester'
autoload :FormatterFactory, 'betfair_api_ng_rails/api/formatter_factory'
......@@ -21,27 +19,20 @@ module BetfairApiNgRails
autoload :Hashalator, 'betfair_api_ng_rails/api/hashalator'
module Caching
autoload :Helper, 'betfair_api_ng_rails/api/caching/helper'
autoload :ResponseCache, 'betfair_api_ng_rails/api/caching/response_cache'
end
module Logs
autoload :FileLogger, 'betfair_api_ng_rails/api/logs/file_logger'
autoload :ConsoleLogger, 'betfair_api_ng_rails/api/logs/console_logger'
end
module Formatters
autoload :JsTreeFormatter, 'betfair_api_ng_rails/api/formatters/js_tree_formatter'
end
module Data
autoload :Base, 'betfair_api_ng_rails/api/data/base'
autoload :Constants, 'betfair_api_ng_rails/api/data/constants'
autoload :Competition, 'betfair_api_ng_rails/api/data/competition'
......@@ -68,19 +59,21 @@ module BetfairApiNgRails
autoload :PriceSize, 'betfair_api_ng_rails/api/data/price_size'
autoload :PriceProjection, 'betfair_api_ng_rails/api/data/price_projection'
autoload :ExBestOffersOverrides, 'betfair_api_ng_rails/api/data/ex_best_offers_overrides'
autoload :PlaceExecutionReport, 'betfair_api_ng_rails/api/data/place_execution_report'
autoload :PlaceInstructionReport,'betfair_api_ng_rails/api/data/place_instruction_report'
autoload :PlaceInstruction, 'betfair_api_ng_rails/api/data/place_instruction'
autoload :LimitOrder, 'betfair_api_ng_rails/api/data/limit_order'
autoload :LimitOnCloseOrder, 'betfair_api_ng_rails/api/data/limit_on_close_order'
autoload :MarketOnCloseOrder, 'betfair_api_ng_rails/api/data/market_on_close_order'
module Concerns
autoload :Hashable, 'betfair_api_ng_rails/api/data/concerns/hashable'
autoload :Attributable, 'betfair_api_ng_rails/api/data/concerns/attributable'
autoload :Jsonable, 'betfair_api_ng_rails/api/data/concerns/jsonable'
end
end
module Enums
autoload :MarketProjection, 'betfair_api_ng_rails/api/enums/market_projection'
autoload :PriceData, 'betfair_api_ng_rails/api/enums/price_data'
autoload :MatchProjection, 'betfair_api_ng_rails/api/enums/match_projection'
......@@ -105,25 +98,21 @@ module BetfairApiNgRails
autoload :BetStatus, 'betfair_api_ng_rails/api/enums/bet_status'
module Concerns
autoload :Enumable, 'betfair_api_ng_rails/api/enums/concerns/enumable'
end
end
module Http
autoload :Requester, 'betfair_api_ng_rails/api/http/requester'
autoload :Responser, 'betfair_api_ng_rails/api/http/responser'
autoload :Factory, 'betfair_api_ng_rails/api/http/factory'
autoload :ProxyRequester, 'betfair_api_ng_rails/api/http/proxy_requester'
end
module Parsers
autoload :Base, 'betfair_api_ng_rails/api/parsers/base'
autoload :ListBase, 'betfair_api_ng_rails/api/parsers/list_base'
autoload :SingleBase, 'betfair_api_ng_rails/api/parsers/single_base'
autoload :ListCompetitions, 'betfair_api_ng_rails/api/parsers/list_competitions'
autoload :ListEventTypes, 'betfair_api_ng_rails/api/parsers/list_event_types'
autoload :ListEvents, 'betfair_api_ng_rails/api/parsers/list_events'
......@@ -133,20 +122,17 @@ module BetfairApiNgRails
autoload :ListMarketTypes, 'betfair_api_ng_rails/api/parsers/list_market_types'
autoload :ListMarketCatalogue, 'betfair_api_ng_rails/api/parsers/list_market_catalogue'
autoload :ListMarketBook, 'betfair_api_ng_rails/api/parsers/list_market_book'
autoload :PlaceOrders, 'betfair_api_ng_rails/api/parsers/place_orders'
end
module ConnectionExt
autoload :ErrorHandling, 'betfair_api_ng_rails/api/connection_ext/error_handling'
autoload :SsoidRefreshing, 'betfair_api_ng_rails/api/connection_ext/ssoid_refreshing'
autoload :Parsing, 'betfair_api_ng_rails/api/connection_ext/parsing'
autoload :Formatting, 'betfair_api_ng_rails/api/connection_ext/formatting'
autoload :Logging, 'betfair_api_ng_rails/api/connection_ext/logging'
autoload :Caching, 'betfair_api_ng_rails/api/connection_ext/caching'
end
end
include Api::Data
......@@ -169,5 +155,4 @@ module BetfairApiNgRails
def self.connection=(value)
@connection = value
end
end
......@@ -4,7 +4,6 @@ module BetfairApiNgRails
module Api
module ConnectionExt
module Parsing
def self.included(base)
base.send :class_eval, <<-CODE
def request_with_parsing(method, params = {})
......@@ -16,13 +15,12 @@ module BetfairApiNgRails
CODE
end
private
private
def init_parser(method, responser)
"BetfairApiNgRails::Api::Parsers::#{method.camelize}".constantize.new responser
end
end
end
end
end
\ No newline at end of file
end
......@@ -27,7 +27,8 @@ module BetfairApiNgRails
"listMarketBook",
"listCurrentOrders",
"listClearedOrders",
"listMarketProfitAndLoss"
"listMarketProfitAndLoss",
"placeOrders"
]
ALLOWED_FORMATTING = [
......@@ -59,4 +60,4 @@ module BetfairApiNgRails
end
end
end
\ No newline at end of file
end
......@@ -8,14 +8,13 @@ module BetfairApiNgRails
:id,
:name
]
attributes COMPETITION_ATTRS
def self.to_hash_attrs
COMPETITION_ATTRS
end
end
end
end
end
\ No newline at end of file
end
......@@ -2,7 +2,6 @@ module BetfairApiNgRails
module Api
module Data
class CompetitionResult < Api::Data::Base
COMPETITION_RESULT_ATTRS = [
:market_count,
:competition_region,
......@@ -10,8 +9,7 @@ module BetfairApiNgRails
]
attributes COMPETITION_RESULT_ATTRS
end
end
end
end
\ No newline at end of file
end
......@@ -3,7 +3,6 @@ module BetfairApiNgRails
module Data
module Concerns
module Attributable
DEFAULT_OPTIONS = { type: String, array: false }
def self.included(base)
......@@ -11,13 +10,12 @@ module BetfairApiNgRails
end
module ClassMethods
def attributes(attrs)
define_class_attrs attrs
define_attr_accessors
end
private
private
def define_class_attrs(attrs)
class << self; attr_accessor :class_attrs; end
......@@ -41,11 +39,9 @@ module BetfairApiNgRails
def fetch_attr_options(attrib)
attrib.is_a?(Hash) ? DEFAULT_OPTIONS.merge(attrib.values.first) : DEFAULT_OPTIONS
end
end
end
end
end
end
end
\ No newline at end of file
end
......@@ -2,10 +2,8 @@ module BetfairApiNgRails
module Api
module Data
module Constants
ATTRS_AS_IS = [Hash, String, Symbol, Fixnum, NilClass]
end
end
end
end
\ No newline at end of file
end
......@@ -2,15 +2,13 @@ module BetfairApiNgRails
module Api
module Data
class CountryCodeResult < Api::Data::Base
COUNTRY_CODE_RESULT_ATTRS = [
:market_count,
:country_code
]
attributes COUNTRY_CODE_RESULT_ATTRS
end
end
end
end
\ No newline at end of file
end
......@@ -18,8 +18,7 @@ module BetfairApiNgRails
def self.to_hash_attrs
EVENT_ATTRS
end
end
end
end
end
\ No newline at end of file
end
......@@ -2,15 +2,13 @@ module BetfairApiNgRails
module Api
module Data
class EventResult < Api::Data::Base
EVENT_RESULT_ATTRS = [
:market_count,
{event: { type: BetfairApiNgRails::Event }}
]
attributes EVENT_RESULT_ATTRS
end
end
end
end
\ No newline at end of file
end
module BetfairApiNgRails
module Api
module Data
class LimitOnCloseOrder < Api::Data::Base
include Api::Data::Concerns::Hashable
LIMIT_ON_CLOSE_ORDER_ATTRS = [
:liability,
:price
]
attributes LIMIT_ON_CLOSE_ORDER_ATTRS
def self.to_hash_attrs
LIMIT_ON_CLOSE_ORDER_ATTRS
end
end
end
end
end
module BetfairApiNgRails
module Api
module Data
class LimitOrder < Api::Data::Base
include Api::Data::Concerns::Hashable
LIMIT_ORDER_ATTRS = [
:size,
:price,
:persistence_type
]
attributes LIMIT_ORDER_ATTRS
def self.to_hash_attrs
LIMIT_ORDER_ATTRS
end
end
end
end
end
module BetfairApiNgRails
module Api
module Data
class MarketOnCloseOrder < Api::Data::Base
include Api::Data::Concerns::Hashable
MARKET_ON_CLOSE_ORDER_ATTRS = [
:liability
]
attributes MARKET_ON_CLOSE_ORDER_ATTRS
def self.to_hash_attrs
MARKET_ON_CLOSE_ORDER_ATTRS
end
end
end
end
end
......@@ -2,7 +2,6 @@ module BetfairApiNgRails
module Api
module Data
class Order < Api::Data::Base
ORDER_ATTRS = [
:bet_id,
:order_type,
......@@ -22,8 +21,7 @@ module BetfairApiNgRails
]
attributes ORDER_ATTRS
end
end
end
end
\ No newline at end of file
end
module BetfairApiNgRails
module Api
module Data
class PlaceExecutionReport < Api::Data::Base
include Api::Data::Concerns::Hashable
PLACE_EXECUTION_REPORT_ATTRS = [
:customer_ref,
:status,
:error_code,
:market_id,
{instruction_reports: {type: BetfairApiNgRails::PlaceInstructionReport, array: true}}
]
attributes PLACE_EXECUTION_REPORT_ATTRS
def self.to_hash_attrs
PLACE_EXECUTION_REPORT_ATTRS
end
end
end
end
end
module BetfairApiNgRails
module Api
module Data
class PlaceInstruction < Api::Data::Base
include Api::Data::Concerns::Hashable
PLACE_INSTRUCTION_ATTRS = [
:order_type,
:selection_id,
:handicap,
:side,
{ limit_order: { type: BetfairApiNgRails::LimitOrder } },
{ limit_on_close_order: { type: BetfairApiNgRails::LimitOnCloseOrder } },
{ market_on_close_order: { type: BetfairApiNgRails::MarketOnCloseOrder } }
]
attributes PLACE_INSTRUCTION_ATTRS
def self.to_hash_attrs
PLACE_INSTRUCTION_ATTRS
end
end
end
end
end
module BetfairApiNgRails
module Api
module Data
class PlaceInstructionReport < Api::Data::Base
include Api::Data::Concerns::Hashable
PLACE_INSTRUCTION_REPORT_ATTRS = [
:status,
:error_code,
{instruction: {type: BetfairApiNgRails::PlaceInstruction}},
:bet_id,
:placed_date,
:average_price_matched,
:size_matched
]
attributes PLACE_INSTRUCTION_REPORT_ATTRS
def self.to_hash_attrs
PLACE_INSTRUCTION_REPORT_ATTRS
end
end
end
end
end
module BetfairApiNgRails
module Api
module Enums
#
# Error code of execution report
#
# Includes:
# ERROR_IN_MATCHER - The matcher is not healthy
# PROCESSED_WITH_ERRORS - The order itself has been accepted, but at least one (possibly all) actions have generated errors
# BET_ACTION_ERROR - There is an error with an action that has caused the entire order to be rejected
# INVALID_ACCOUNT_STATE - Order rejected due to the account's status (suspended, inactive, dup cards)
# INVALID_WALLET_STATUS - Order rejected due to the account's wallet's status
# INSUFFICIENT_FUNDS - Account has exceeded its exposure limit or available to bet limit
# LOSS_LIMIT_EXCEEDED - The account has exceed the self imposed loss limit
# MARKET_SUSPENDED - Market is suspended
# MARKET_NOT_OPEN_FOR_BETTING - Market is not open for betting. It is either not yet active, suspended or closed awaiting settlement.
# DUPLICATE_TRANSACTION - duplicate customer referece data submitted
# INVALID_ORDER - Order cannot be accepted by the matcher due to the combination of actions. For example, bets being edited are not on the same market, or order includes both edits and placement
# INVALID_MARKET_ID - Market doesn't exist
# PERMISSION_DENIED - Business rules do not allow order to be placed
# DUPLICATE_BETIDS - duplicate bet ids found
# NO_ACTION_REQUIRED - Order hasn't been passed to matcher as system detected there will be no state change
# SERVICE_UNAVAILABLE - The requested service is unavailable
# REJECTED_BY_REGULATOR - The regulator rejected the order. On the Italian Exchange this error will occur if more than 50 bets are sent in a single placeOrders request.
class ExecutionReportErrorCode
extend Api::Enums::Concerns::Enumable
......@@ -25,4 +46,4 @@ module BetfairApiNgRails
end
end
end
end
\ No newline at end of file
end
module BetfairApiNgRails
module Api
module Enums
#
# Status of execution report
#
# Includes:
# SUCCESS - Order processed successfully
# FAILURE - Order failed.
# PROCESSED_WITH_ERRORS - The order itself has been accepted, but at least one (possibly all)
# actions have generated errors. This error only occurs for replaceOrders,
# cancelOrders and updateOrders operations. The placeOrders operation will not return
# PROCESSED_WITH_ERRORS status as it is an atomic operation.
# TIMEOUT - Order timed out.
class ExecutionReportStatus
extend Api::Enums::Concerns::Enumable
......@@ -12,4 +23,4 @@ module BetfairApiNgRails
end
end
end
end
\ No newline at end of file
end
module BetfairApiNgRails
module Api
module Enums
#
# Indicates cause of failure
#
# Includes:
# INVALID_BET_SIZE - bet size is invalid for your currency or your regulator
# INVALID_RUNNER - Runner does not exist, includes vacant traps in greyhound racing
# BET_TAKEN_OR_LAPSED - Bet cannot be cancelled or modified as it has already been taken or has lapsed Includes attempts to cancel/modify market on close BSP bets and cancelling limit on close BSP bets
# BET_IN_PROGRESS - No result was received from the matcher in a timeout configured for the system
# RUNNER_REMOVED - Runner has been removed from the event
# MARKET_NOT_OPEN_FOR_BETTING - Attempt to edit a bet on a market that has closed.
# LOSS_LIMIT_EXCEEDED - The action has caused the account to exceed the self imposed loss limit
# MARKET_NOT_OPEN_FOR_BSP_BETTING - Market now closed to bsp betting. Turned in-play or has been reconciled
# INVALID_PRICE_EDIT - Attempt to edit down the price of a bsp limit on close lay bet, or edit up the price of a limit on close back bet
# INVALID_ODDS - Odds not on price ladder - either edit or placement
# INSUFFICIENT_FUNDS - Insufficient funds available to cover the bet action. Either the exposure limit or available to bet limit would be exceeded
# INVALID_PERSISTENCE_TYPE - Invalid persistence type for this market, e.g. KEEP for a non bsp market
# ERROR_IN_MATCHER - A problem with the matcher prevented this action completing successfully
# INVALID_BACK_LAY_COMBINATION - The order contains a back and a lay for the same runner at overlapping prices. This would guarantee a self match. This also applies to BSP limit on close bets
# ERROR_IN_ORDER - The action failed because the parent order failed
# INVALID_BID_TYPE - Bid type is mandatory
# INVALID_BET_ID - Bet for id supplied has not been found
# CANCELLED_NOT_PLACED - Bet cancelled but replacement bet was not placed
# RELATED_ACTION_FAILED - Action failed due to the failure of a action on which this action is dependent
# NO_ACTION_REQUIRED - the action does not result in any state change. eg changing a persistence to it's current value
class InstructionReportErrorCode
extend Api::Enums::Concerns::Enumable
......@@ -28,4 +52,4 @@ module BetfairApiNgRails
end
end
end
end
\ No newline at end of file
end
module BetfairApiNgRails
module Api
module Enums
#
# Indicates whether the command succeeded or failed
#
# Includes:
# SUCCESS
# FAILURE
# TIMEOUT
class InstructionReportStatus
extend Api::Enums::Concerns::Enumable
......@@ -11,4 +18,4 @@ module BetfairApiNgRails
end
end
end
end
\ No newline at end of file
end
module BetfairApiNgRails
module Api
module Enums
#
# Either EXECUTABLE (an unmatched amount remains) or EXECUTION_COMPLETE (no unmatched amount remains).
#
# Includes:
# EXECUTION_COMPLETE - An order that does not have any remaining unmatched portion.
# EXECUTABLE - An order that has a remaining unmatched portion.
class OrderStatus
extend Api::Enums::Concerns::Enumable
......@@ -10,4 +16,4 @@ module BetfairApiNgRails
end
end
end
end
\ No newline at end of file
end
module BetfairApiNgRails
module Api
module Enums
#
# The type of bet (e.g standard limited-liability Exchange bet (LIMIT), a standard BSP bet (MARKET_ON_CLOSE), or
# a minimum-accepted-price BSP bet (LIMIT_ON_CLOSE)). If the bet has a OrderType of MARKET_ON_CLOSE and
# a persistenceType of MARKET_ON_CLOSE then it is a bet which has transitioned from LIMIT to MARKET_ON_CLOSE.
# Only available at BET groupBy level
#
# Includes:
# LIMIT - A normal exchange limit order for immediate execution
# LIMIT_ON_CLOSE - Limit order for the auction (SP)
# MARKET_ON_CLOSE - Market order for the auction (SP)
class OrderType
extend Api::Enums::Concerns::Enumable
enumify "LIMIT",
"LIMIT_ON_CLOSE",
"MARKET_ON_CLOSE"
end