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.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.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.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_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_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.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.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