durtal/betfaiR

clean up code

Closed this issue · 3 comments

with the addition of more methods some of the code could use a bit of clean up. Functions like replaceInstructions and limitOnCloseOrder are doing very similar things, rather than having multiple little functions perhaps think about storing them in a similar fashion to the [betfair] environment.

This would reduce the number of functions being exported.

Also look to change names from betfair_parse to shorter bf_parse

Functions to change from betfair_* to bf_*

  • betfair_request
  • betfair_parse
  • betfair_check
  • betfair_POST
  • betfair_login

These often return lists with unique class to be printed in a certain format, these classes can also be improved on.

Order functions to group together

  • limitOrder exported
  • limitOnCloseOrder exported
  • replaceInstructions exported
  • cancelInstructions exported
  • prepare_order not exported
  • cancel_orders not exported

Current NAMESPACE (below) reveals a few inconsistencies which would be reduced with cleaning function names (and object classes) from above

S3method(betfair_parse,cancelOrders)
S3method(betfair_parse,competitions)
S3method(betfair_parse,countries)
S3method(betfair_parse,eventTypes)
S3method(betfair_parse,events)
S3method(betfair_parse,marketBook)
S3method(betfair_parse,marketCatalogue)
S3method(betfair_parse,marketProfitAndLoss)
S3method(betfair_parse,marketTypes)
S3method(betfair_parse,placeOrders)
S3method(betfair_parse,venues)
S3method(betfair_request,cancelOrders)
S3method(betfair_request,competitions)
S3method(betfair_request,countries)
S3method(betfair_request,eventTypes)
S3method(betfair_request,events)
S3method(betfair_request,marketBook)
S3method(betfair_request,marketCatalogue)
S3method(betfair_request,marketProfitAndLoss)
S3method(betfair_request,marketTypes)
S3method(betfair_request,placeOrders)
S3method(betfair_request,replaceOrders)
S3method(betfair_request,venues)
S3method(print,betfaiR)
S3method(print,betfaiR_login)
S3method(print,betfair_orders)
S3method(print,bf_cancel_orders)
S3method(print,marketBook_list)
S3method(print,marketBook_simple)
S3method(print,marketCatalogue_list)
S3method(print,marketCatalogue_simple)
S3method(print,marketPnL_list)
S3method(print,market_PnL)
S3method(summary,betfair_orders)
S3method(summary,bf_cancel_orders)
S3method(summary,marketBook_list)
S3method(summary,marketBook_simple)
S3method(summary,marketCatalogue_list)
S3method(summary,marketCatalogue_simple)
export(base_request)
export(betfair)
export(betfair_POST)
export(betfair_check)
export(betfair_login)
export(betfair_parse)
export(betfair_request)
export(cancelInstruction)
export(limitOnCloseOrder)
export(limitOrder)
export(marketFilter)
export(replaceInstructions)

Made a start on this branch, with a couple of commits changing existing function names and removing old docs.

Have added new bf_helpers environment which includes the small helper functions used for managing orders.

Branch has been deleted

addressed in this commit