ritpytrading package

Submodules

ritpytrading.assets module

This script contains results for the /assets module

Sample JSON output formats for the function returns News object return value: JSON formatted [

{

“ticker”: “string”, “type”: “CONTAINER”, “description”: “string”, “total_quantity”: 0, “available_quantity”: 0, “lease_price”: 0, “convert_from”: [

{
“ticker”: “string”, “quantity”: 0

}

], “convert_to”: [

{
“ticker”: “string”, “quantity”: 0

}

], “containment”: {

“ticker”: “string”, “quantity”: 0

}, “ticks_per_conversion”: 0, “ticks_per_lease”: 0, “is_available”: true, “start_period”: 0, “stop_period”: 0

}

] Parameters for the news GET HTTP request - ticker string (query)

exception ritpytrading.assets.ApiException[source]

Bases: exceptions.Exception

to print error messages and stop the program when needed

class ritpytrading.assets.Asset(asset_response)[source]

case_response is a json obj returned from the API get request

ritpytrading.assets.asset(ses, ticker_sym)[source]

function that returns a single asset object given for a given ticker

ritpytrading.assets.assets_dict(ses)[source]

function that returns a dictionary of the assets object

ritpytrading.assets.assets_list(ses)[source]

returns a list of JSON fomratted output for assets object

ritpytrading.case module

ritpytrading.news module

This script contains results for the /news module

Sample JSON output formats for the function returns News object return value: JSON formatted [

{
“news_id”: 0, “period”: 0, “tick”: 0, “ticker”: “string”, “headline”: “string”, “body”: “string”

}

] Parameters for the news GET HTTP request - since number (query) - limit number (query)

exception ritpytrading.news.ApiException[source]

Bases: exceptions.Exception

to print error messages and stop the program when needed

class ritpytrading.news.News(news_response)[source]

case_response is a json obj returned from the API get request

ritpytrading.news.news_dict(ses, since_id=None, limit_itm=None)[source]

function that returns the news object

ritpytrading.news.news_json(ses, since_id=None, limit_itm=None)[source]

returns a list of JSON fomratted output for news object

ritpytrading.orders module

order return object attributes param possible order attributes: JSON formatted i.e. get_order_response( ses, url_end, param=”order_id” ) {

“order_id”: 1221, “period”: 1, “tick”: 10, “trader_id”: “trader49”, “ticker”: “CRZY”, “type”: “LIMIT”, “quantity”: 100, “action”: “BUY”, “price”: 14.21, “quantity_filled”: 10, “vwap”: 14.21, “status”: “OPEN”

}

exception ritpytrading.orders.ApiException[source]

Bases: exceptions.Exception

to print error messages and stop the program when needed

class ritpytrading.orders.Order(order_response)[source]

order_response is a json obj returned from the API get request

ritpytrading.orders.order(ses, orderId, status='OPEN')[source]

status can be OPEN, TRANSACTED or CLOSED status OPEN by default returns a Order object of the order class given an order id

ritpytrading.orders.orders_dict(ses, status='OPEN')[source]

returns all the orders as a dict with the order_ids as key

ritpytrading.orders.orders_json(ses, status='OPEN')[source]

returns all the attribs of all orders in a json type list format

ritpytrading.securities module

The securities HTTP module gets a list of available securities and associated positions.

securities object attribute values: JSON formatted [

{

“ticker”: “string”, “type”: “SPOT”, “size”: 0, “position”: 0, “vwap”: 0, “nlv”: 0, “last”: 0, “bid”: 0, “bid_size”: 0, “ask”: 0, “ask_size”: 0, “volume”: 0, “unrealized”: 0, “realized”: 0, “currency”: “string”, “total_volume”: 0, “limits”: [

{
“name”: “string”, “units”: 0

}

], “interest_rate”: 0, “is_tradeable”: true, “is_shortable”: true, “start_period”: 0, “stop_period”: 0

}

]

Parameters for the securities GET HTTP request - ticker* required string (query)

exception ritpytrading.securities.ApiException[source]

Bases: exceptions.Exception

to print error messages and stop the program when needed

class ritpytrading.securities.Security(security_response)[source]

Security class takes a security_response object ( a list of json objects ) as its initializing paramenter to extract all relevant information security_response is a json obj returned from the API get request

ritpytrading.securities.security_dict(ses, ticker_sym=None)[source]

By default no specific ticker_sym is None returns the list of available securities as a dict of security objects with ticker name as keys

ritpytrading.securities.security_json(ses, ticker_sym=None)[source]

returns the list of available securities with all info in a json format

ritpytrading.securities_book module

The /securities/book HTTP module gets the order book of a security

securities_book object attribute values: JSON formatted {

“bids”: [
{
“order_id”: 1221, “period”: 1, “tick”: 10, “trader_id”: “trader49”, “ticker”: “CRZY”, “type”: “LIMIT”, “quantity”: 100, “action”: “BUY”, “price”: 14.21, “quantity_filled”: 10, “vwap”: 14.21, “status”: “OPEN”

}

], “asks”: [

{
“order_id”: 1221, “period”: 1, “tick”: 10, “trader_id”: “trader49”, “ticker”: “CRZY”, “type”: “LIMIT”, “quantity”: 100, “action”: “BUY”, “price”: 14.21, “quantity_filled”: 10, “vwap”: 14.21, “status”: “OPEN”

}

]

}

Parameters for the securities_book GET HTTP request - ticker* required string (query) - period number (query)

exception ritpytrading.securities_book.ApiException[source]

Bases: exceptions.Exception

to print error messages and stop the program when needed

ritpytrading.securities_book.get_all_asks(ses, ticker_sym)[source]
ritpytrading.securities_book.get_all_bids(ses, ticker_sym)[source]
ritpytrading.securities_book.get_all_bids_asks(ses, ticker_sym)[source]

Returns a list of JSON objects representing all_flag the orders in the Bid and Ask side of the book

ritpytrading.securities_book.get_bbo(ses, ticker_sym)[source]
ritpytrading.securities_book.get_best_ask(ses, ticker_sym)[source]
ritpytrading.securities_book.get_best_bid(ses, ticker_sym)[source]
ritpytrading.securities_book.get_security_info(ses, ticker_sym, side, param)[source]

All possible values for the param parameter are listed at the top

Returns the value of the param for the given ticker from the given side side = bids / asks

ritpytrading.securities_history module

The /securities/history module gets the OHLC history for a security.

functions related to the history of a security securities_history object attribute values: JSON formatted [

{
“tick”: 11, “open”: 4.12, “high”: 4.21, “low”: 4.1, “close”: 4.15

}

]

Parameters for the securities_history GET HTTP request

  • ticker* required string (query)
  • period number (query)

Period to retrieve data from. Defaults to the current period. - limit number (query) Result set limit, counting backwards from the most recent tick. Defaults to retrieving the entire period.

exception ritpytrading.securities_history.ApiException[source]

Bases: exceptions.Exception

to print error messages and stop the program when needed

class ritpytrading.securities_history.Security_History(sec_history)[source]

sec_history is a json obj returned from the API get request

ritpytrading.securities_history.security_history_dict(ses, ticker_sym, period_numb=None, lim_numb=None)[source]

function to get values of different parameters

ritpytrading.securities_history.security_history_json(ses, ticker_sym, period_numb=None, lim_numb=None)[source]

get all full JSON response for the securities history get request

ritpytrading.submit_cancel_orders module

exception ritpytrading.submit_cancel_orders.ApiException[source]

Bases: exceptions.Exception

to print error messages and stop the program when needed

ritpytrading.submit_cancel_orders.cancel_order(ses, order_id)[source]

function requires a requests.Session() object as the ses argument with a loaded API_KEY

ritpytrading.submit_cancel_orders.cancel_order_bulk(ses, price_direc, price_lim, volume_direc, volume_lim, all_flag=0)[source]

Volume < 0 for cancelling all open sell orders and Volume > 0 for cancelling all open buy orders query_gen example ‘Price < 20.0 AND Volume > 0’

ritpytrading.submit_cancel_orders.limit_order(ses, ticker, side, quantity, price)[source]

function requires a requests.Session() object as the ses argument with a loaded API_KEY

ritpytrading.submit_cancel_orders.market_order(ses, ticker, side, quantity)[source]

submitting a market order side = BUY/SELL function requires a requests.Session() object as the ses argument with a loaded API_KEY

ritpytrading.tenders module

This script contains results for the /tenders module

Sample JSON output formats for the function returns Tender object return value: JSON formatted [

{
“tender_id”: 0, “period”: 0, “tick”: 0, “expires”: 0, “caption”: “string”, “quantity”: 0, “action”: “BUY”, “is_fixed_bid”: true, “price”: 0

}

]

exception ritpytrading.tenders.ApiException[source]

Bases: exceptions.Exception

to print error messages and stop the program when needed

class ritpytrading.tenders.Tender(tender_response)[source]

case_response is a json obj returned from the API get request

ritpytrading.tenders.accept_tender(ses, tender_iden, price_tender=None)[source]
ritpytrading.tenders.decline_tender(ses, tender_iden)[source]
ritpytrading.tenders.tenders_dict(ses)[source]

function that returns the tender object

ritpytrading.tenders.tenders_json(ses)[source]

returns a list of JSON fomratted output for tender object

ritpytrading.trader module

Module contents