INSTRUCTION
stringlengths
1
8.43k
RESPONSE
stringlengths
75
104k
Set the schema to be used. Schema can either be a ShExC or ShExJ string or a pre - parsed schema.
def schema(self, shex: Optional[Union[str, ShExJ.Schema]]) -> None: """ Set the schema to be used. Schema can either be a ShExC or ShExJ string or a pre-parsed schema. :param shex: Schema """ self.pfx = None if shex is not None: if isinstance(shex, ShExJ.Schema): ...
Set the focus node ( s ). If no focus node is specified the evaluation will occur for all non - BNode graph subjects. Otherwise it can be a string a URIRef or a list of string/ URIRef combinations
def focus(self, focus: Optional[URIPARM]) -> None: """ Set the focus node(s). If no focus node is specified, the evaluation will occur for all non-BNode graph subjects. Otherwise it can be a string, a URIRef or a list of string/URIRef combinations :param focus: None if focus should be all URI...
arcsOut ( G n ) is the set of triples in a graph G with subject n.
def arcsOut(G: Graph, n: Node) -> RDFGraph: """ arcsOut(G, n) is the set of triples in a graph G with subject n. """ return RDFGraph(G.triples((n, None, None)))
predicatesOut ( G n ) is the set of predicates in arcsOut ( G n ).
def predicatesOut(G: Graph, n: Node) -> Set[TriplePredicate]: """ predicatesOut(G, n) is the set of predicates in arcsOut(G, n). """ return {p for p, _ in G.predicate_objects(n)}
arcsIn ( G n ) is the set of triples in a graph G with object n.
def arcsIn(G: Graph, n: Node) -> RDFGraph: """ arcsIn(G, n) is the set of triples in a graph G with object n. """ return RDFGraph(G.triples((None, None, n)))
predicatesIn ( G n ) is the set of predicates in arcsIn ( G n ).
def predicatesIn(G: Graph, n: Node) -> Set[TriplePredicate]: """ predicatesIn(G, n) is the set of predicates in arcsIn(G, n). """ return {p for _, p in G.subject_predicates(n)}
neigh ( G n ) is the neighbourhood of the node n in the graph G.
def neigh(G: Graph, n: Node) -> RDFGraph: """ neigh(G, n) is the neighbourhood of the node n in the graph G. neigh(G, n) = arcsOut(G, n) ∪ arcsIn(G, n) """ return arcsOut(G, n) | arcsIn(G, n)
redicates ( G n ) is the set of predicates in neigh ( G n ).
def predicates(G: Graph, n: Node) -> Set[TriplePredicate]: """ redicates(G, n) is the set of predicates in neigh(G, n). predicates(G, n) = predicatesOut(G, n) ∪ predicatesIn(G, n) """ return predicatesOut(G, n) | predicatesIn(G, n)
Convert path which can be a URL or a file path into a base URI
def generate_base(path: str) -> str: """ Convert path, which can be a URL or a file path into a base URI :param path: file location or url :return: file location or url sans actual name """ if ':' in path: parts = urlparse(path) parts_dict = parts._asdict() parts_dict['path'...
Data from http:// indexed. blogspot. com/ 2007/ 08/ real - ultimate - power. html
def ultimate_power(): """ Data from http://indexed.blogspot.com/2007/08/real-ultimate-power.html """ chart = VennChart(settings.width, settings.height) chart.add_data([100, 100, 100, 20, 20, 20, 10]) chart.set_title('Ninjas or God') chart.set_legend(['unseen agents', 'super powerful', 'secre...
Return ( host port ) from server.
def split_host_port(cls, server): """ Return (host, port) from server. Port defaults to 11211. >>> split_host_port('127.0.0.1:11211') ('127.0.0.1', 11211) >>> split_host_port('127.0.0.1') ('127.0.0.1', 11211) """ host, port = splitport(server) ...
Reads data from socket.
def _read_socket(self, size): """ Reads data from socket. :param size: Size in bytes to be read. :return: Data from socket """ value = b'' while len(value) < size: data = self.connection.recv(size - len(value)) if not data: ...
Get memcached response from socket.
def _get_response(self): """ Get memcached response from socket. :return: A tuple with binary values from memcached. :rtype: tuple """ try: self._open_connection() if self.connection is None: # The connection wasn't opened, which m...
Authenticate user on server.
def authenticate(self, username, password): """ Authenticate user on server. :param username: Username used to be authenticated. :type username: six.string_types :param password: Password used to be authenticated. :type password: six.string_types :return: True if...
Serializes a value based on its type.
def serialize(self, value, compress_level=-1): """ Serializes a value based on its type. :param value: Something to be serialized :type value: six.string_types, int, long, object :param compress_level: How much to compress. 0 = no compression, 1 = fastest, 9 = slowes...
Deserialized values based on flags or just return it if it is not serialized.
def deserialize(self, value, flags): """ Deserialized values based on flags or just return it if it is not serialized. :param value: Serialized or not value. :type value: six.string_types, int :param flags: Value flags :type flags: int :return: Deserialized value...
Get a key and its CAS value from server. If the value isn t cached return ( None None ).
def get(self, key): """ Get a key and its CAS value from server. If the value isn't cached, return (None, None). :param key: Key's name :type key: six.string_types :return: Returns (value, cas). :rtype: object """ logger.debug('Getting key %s', k...
Send a NOOP command
def noop(self): """ Send a NOOP command :return: Returns the status. :rtype: int """ logger.debug('Sending NOOP') data = struct.pack(self.HEADER_STRUCT + self.COMMANDS['noop']['struct'], self.MAGIC['request'],...
Get multiple keys from server.
def get_multi(self, keys): """ Get multiple keys from server. Since keys are converted to b'' when six.PY3 the keys need to be decoded back into string . e.g key='test' is read as b'test' and then decoded back to 'test' This encode/decode does not work when key is already a six....
Function to set/ add/ replace commands.
def _set_add_replace(self, command, key, value, time, cas=0, compress_level=-1): """ Function to set/add/replace commands. :param key: Key's name :type key: six.string_types :param value: A value to be stored on server. :type value: object :param time: Time in se...
Set a value for a key on server.
def set(self, key, value, time, compress_level=-1): """ Set a value for a key on server. :param key: Key's name :type key: six.string_types :param value: A value to be stored on server. :type value: object :param time: Time in seconds that your key will expire. ...
Add a key/ value to server ony if it does not exist.
def cas(self, key, value, cas, time, compress_level=-1): """ Add a key/value to server ony if it does not exist. :param key: Key's name :type key: six.string_types :param value: A value to be stored on server. :type value: object :param time: Time in seconds that...
Add a key/ value to server ony if it does not exist.
def add(self, key, value, time, compress_level=-1): """ Add a key/value to server ony if it does not exist. :param key: Key's name :type key: six.string_types :param value: A value to be stored on server. :type value: object :param time: Time in seconds that your...
Replace a key/ value to server ony if it does exist.
def replace(self, key, value, time, compress_level=-1): """ Replace a key/value to server ony if it does exist. :param key: Key's name :type key: six.string_types :param value: A value to be stored on server. :type value: object :param time: Time in seconds that ...
Set multiple keys with its values on server.
def set_multi(self, mappings, time=100, compress_level=-1): """ Set multiple keys with its values on server. If a key is a (key, cas) tuple, insert as if cas(key, value, cas) had been called. :param mappings: A dict with keys/values :type mappings: dict :param t...
Function which increments and decrements.
def _incr_decr(self, command, key, value, default, time): """ Function which increments and decrements. :param key: Key's name :type key: six.string_types :param value: Number to be (de|in)cremented :type value: int :param default: Default value if key does not e...
Increment a key if it exists returns its actual value if it doesn t return 0.
def incr(self, key, value, default=0, time=1000000): """ Increment a key, if it exists, returns its actual value, if it doesn't, return 0. :param key: Key's name :type key: six.string_types :param value: Number to be incremented :type value: int :param default: D...
Decrement a key if it exists returns its actual value if it doesn t return 0. Minimum value of decrement return is 0.
def decr(self, key, value, default=0, time=100): """ Decrement a key, if it exists, returns its actual value, if it doesn't, return 0. Minimum value of decrement return is 0. :param key: Key's name :type key: six.string_types :param value: Number to be decremented ...
Delete a key/ value from server. If key existed and was deleted return True.
def delete(self, key, cas=0): """ Delete a key/value from server. If key existed and was deleted, return True. :param key: Key's name to be deleted :type key: six.string_types :param cas: If set, only delete the key if its CAS value matches. :type cas: int :retur...
Delete multiple keys from server in one command.
def delete_multi(self, keys): """ Delete multiple keys from server in one command. :param keys: A list of keys to be deleted :type keys: list :return: True in case of success and False in case of failure. :rtype: bool """ logger.debug('Deleting keys %r', ...
Send a command to server flush|delete all keys.
def flush_all(self, time): """ Send a command to server flush|delete all keys. :param time: Time to wait until flush in seconds. :type time: int :return: True in case of success, False in case of failure :rtype: bool """ logger.info('Flushing memcached') ...
Return server stats.
def stats(self, key=None): """ Return server stats. :param key: Optional if you want status from a key. :type key: six.string_types :return: A dict with server stats :rtype: dict """ # TODO: Stats with key is not working. if key is not None: ...
Add a ShExC schema to the library
def add_shex(self, schema: str) -> "PrefixLibrary": """ Add a ShExC schema to the library :param schema: ShExC schema text, URL or file name :return: prefix library object """ if '\n' in schema or '\r' in schema or ' ' in schema: shex = schema else: ...
Add bindings in the library to the graph
def add_bindings(self, g: Graph) -> "PrefixLibrary": """ Add bindings in the library to the graph :param g: graph to add prefixes to :return: PrefixLibrary object """ for prefix, namespace in self: g.bind(prefix.lower(), namespace) return self
Add the bindings to the target object: param target: target to add to: param override: override existing bindings if they are of type Namespace: return: number of items actually added
def add_to_object(self, target: object, override: bool = False) -> int: """ Add the bindings to the target object :param target: target to add to :param override: override existing bindings if they are of type Namespace :return: number of items actually added """ ...
Return the ns: name format of URI
def nsname(self, uri: Union[str, URIRef]) -> str: """ Return the 'ns:name' format of URI :param uri: URI to transform :return: nsname format of URI or straight URI if no mapping """ uri = str(uri) nsuri = "" prefix = None for pfx, ns in self: ...
: param f: file object with spec data
def open_spec(f): """ :param f: file object with spec data spec file is a yaml document that specifies which modules can be loaded. modules - list of base modules that can be loaded pths - list of .pth files to load """ import ruamel.yaml as yaml keys = ['modules', 'pths', 'tes...
Load a ShEx Schema from schema_location
def load(self, schema_file: Union[str, TextIO], schema_location: Optional[str]=None) -> ShExJ.Schema: """ Load a ShEx Schema from schema_location :param schema_file: name or file-like object to deserialize :param schema_location: URL or file name of schema. Used to create the base_location ...
Parse and return schema as a ShExJ Schema
def loads(self, schema_txt: str) -> ShExJ.Schema: """ Parse and return schema as a ShExJ Schema :param schema_txt: ShExC or ShExJ representation of a ShEx Schema :return: ShEx Schema representation of schema """ self.schema_text = schema_txt if schema_txt.strip()[0] == '...
placeOrder ( EClient self OrderId id Contract contract Order order )
def placeOrder(self, id, contract, order): """placeOrder(EClient self, OrderId id, Contract contract, Order order)""" return _swigibpy.EClient_placeOrder(self, id, contract, order)
reqMktDepth ( EClient self TickerId id Contract contract int numRows TagValueListSPtr const & mktDepthOptions )
def reqMktDepth(self, id, contract, numRows, mktDepthOptions): """reqMktDepth(EClient self, TickerId id, Contract contract, int numRows, TagValueListSPtr const & mktDepthOptions)""" return _swigibpy.EClient_reqMktDepth(self, id, contract, numRows, mktDepthOptions)
exerciseOptions ( EClient self TickerId id Contract contract int exerciseAction int exerciseQuantity IBString const & account int override )
def exerciseOptions(self, id, contract, exerciseAction, exerciseQuantity, account, override): """exerciseOptions(EClient self, TickerId id, Contract contract, int exerciseAction, int exerciseQuantity, IBString const & account, int override)""" return _swigibpy.EClient_exerciseOptions(self, id, contract,...
reqScannerSubscription ( EClient self int tickerId ScannerSubscription subscription TagValueListSPtr const & scannerSubscriptionOptions )
def reqScannerSubscription(self, tickerId, subscription, scannerSubscriptionOptions): """reqScannerSubscription(EClient self, int tickerId, ScannerSubscription subscription, TagValueListSPtr const & scannerSubscriptionOptions)""" return _swigibpy.EClient_reqScannerSubscription(self, tickerId, subscripti...
reqFundamentalData ( EClient self TickerId reqId Contract arg3 IBString const & reportType )
def reqFundamentalData(self, reqId, arg3, reportType): """reqFundamentalData(EClient self, TickerId reqId, Contract arg3, IBString const & reportType)""" return _swigibpy.EClient_reqFundamentalData(self, reqId, arg3, reportType)
calculateImpliedVolatility ( EClient self TickerId reqId Contract contract double optionPrice double underPrice )
def calculateImpliedVolatility(self, reqId, contract, optionPrice, underPrice): """calculateImpliedVolatility(EClient self, TickerId reqId, Contract contract, double optionPrice, double underPrice)""" return _swigibpy.EClient_calculateImpliedVolatility(self, reqId, contract, optionPrice, underPrice)
calculateOptionPrice ( EClient self TickerId reqId Contract contract double volatility double underPrice )
def calculateOptionPrice(self, reqId, contract, volatility, underPrice): """calculateOptionPrice(EClient self, TickerId reqId, Contract contract, double volatility, double underPrice)""" return _swigibpy.EClient_calculateOptionPrice(self, reqId, contract, volatility, underPrice)
reqAccountSummary ( EClient self int reqId IBString const & groupName IBString const & tags )
def reqAccountSummary(self, reqId, groupName, tags): """reqAccountSummary(EClient self, int reqId, IBString const & groupName, IBString const & tags)""" return _swigibpy.EClient_reqAccountSummary(self, reqId, groupName, tags)
eConnect ( EClientSocketBase self char const * host unsigned int port int clientId = 0 bool extraAuth = False ) - > bool
def eConnect(self, host, port, clientId=0, extraAuth=False): """eConnect(EClientSocketBase self, char const * host, unsigned int port, int clientId=0, bool extraAuth=False) -> bool""" return _swigibpy.EClientSocketBase_eConnect(self, host, port, clientId, extraAuth)
reqMktData ( EClientSocketBase self TickerId id Contract contract IBString const & genericTicks bool snapshot TagValueListSPtr const & mktDataOptions )
def reqMktData(self, id, contract, genericTicks, snapshot, mktDataOptions): """reqMktData(EClientSocketBase self, TickerId id, Contract contract, IBString const & genericTicks, bool snapshot, TagValueListSPtr const & mktDataOptions)""" return _swigibpy.EClientSocketBase_reqMktData(self, id, contract, ge...
placeOrder ( EClientSocketBase self OrderId id Contract contract Order order )
def placeOrder(self, id, contract, order): """placeOrder(EClientSocketBase self, OrderId id, Contract contract, Order order)""" return _swigibpy.EClientSocketBase_placeOrder(self, id, contract, order)
reqMktDepth ( EClientSocketBase self TickerId tickerId Contract contract int numRows TagValueListSPtr const & mktDepthOptions )
def reqMktDepth(self, tickerId, contract, numRows, mktDepthOptions): """reqMktDepth(EClientSocketBase self, TickerId tickerId, Contract contract, int numRows, TagValueListSPtr const & mktDepthOptions)""" return _swigibpy.EClientSocketBase_reqMktDepth(self, tickerId, contract, numRows, mktDepthOptions)
reqHistoricalData ( EClientSocketBase self TickerId id Contract contract IBString const & endDateTime IBString const & durationStr IBString const & barSizeSetting IBString const & whatToShow int useRTH int formatDate TagValueListSPtr const & chartOptions )
def reqHistoricalData(self, id, contract, endDateTime, durationStr, barSizeSetting, whatToShow, useRTH, formatDate, chartOptions): """reqHistoricalData(EClientSocketBase self, TickerId id, Contract contract, IBString const & endDateTime, IBString const & durationStr, IBString const & barSizeSetting, IBString co...
exerciseOptions ( EClientSocketBase self TickerId tickerId Contract contract int exerciseAction int exerciseQuantity IBString const & account int override )
def exerciseOptions(self, tickerId, contract, exerciseAction, exerciseQuantity, account, override): """exerciseOptions(EClientSocketBase self, TickerId tickerId, Contract contract, int exerciseAction, int exerciseQuantity, IBString const & account, int override)""" return _swigibpy.EClientSocketBase_exe...
reqRealTimeBars ( EClientSocketBase self TickerId id Contract contract int barSize IBString const & whatToShow bool useRTH TagValueListSPtr const & realTimeBarsOptions )
def reqRealTimeBars(self, id, contract, barSize, whatToShow, useRTH, realTimeBarsOptions): """reqRealTimeBars(EClientSocketBase self, TickerId id, Contract contract, int barSize, IBString const & whatToShow, bool useRTH, TagValueListSPtr const & realTimeBarsOptions)""" return _swigibpy.EClientSocketBase...
reqScannerSubscription ( EClientSocketBase self int tickerId ScannerSubscription subscription TagValueListSPtr const & scannerSubscriptionOptions )
def reqScannerSubscription(self, tickerId, subscription, scannerSubscriptionOptions): """reqScannerSubscription(EClientSocketBase self, int tickerId, ScannerSubscription subscription, TagValueListSPtr const & scannerSubscriptionOptions)""" return _swigibpy.EClientSocketBase_reqScannerSubscription(self, ...
reqFundamentalData ( EClientSocketBase self TickerId reqId Contract arg3 IBString const & reportType )
def reqFundamentalData(self, reqId, arg3, reportType): """reqFundamentalData(EClientSocketBase self, TickerId reqId, Contract arg3, IBString const & reportType)""" return _swigibpy.EClientSocketBase_reqFundamentalData(self, reqId, arg3, reportType)
calculateImpliedVolatility ( EClientSocketBase self TickerId reqId Contract contract double optionPrice double underPrice )
def calculateImpliedVolatility(self, reqId, contract, optionPrice, underPrice): """calculateImpliedVolatility(EClientSocketBase self, TickerId reqId, Contract contract, double optionPrice, double underPrice)""" return _swigibpy.EClientSocketBase_calculateImpliedVolatility(self, reqId, contract, optionPr...
calculateOptionPrice ( EClientSocketBase self TickerId reqId Contract contract double volatility double underPrice )
def calculateOptionPrice(self, reqId, contract, volatility, underPrice): """calculateOptionPrice(EClientSocketBase self, TickerId reqId, Contract contract, double volatility, double underPrice)""" return _swigibpy.EClientSocketBase_calculateOptionPrice(self, reqId, contract, volatility, underPrice)
reqAccountSummary ( EClientSocketBase self int reqId IBString const & groupName IBString const & tags )
def reqAccountSummary(self, reqId, groupName, tags): """reqAccountSummary(EClientSocketBase self, int reqId, IBString const & groupName, IBString const & tags)""" return _swigibpy.EClientSocketBase_reqAccountSummary(self, reqId, groupName, tags)
Continually poll TWS
def _run(self): '''Continually poll TWS''' stop = self._stop_evt connected = self._connected_evt tws = self._tws fd = tws.fd() pollfd = [fd] while not stop.is_set(): while (not connected.is_set() or not tws.isConnected()) and not stop.is_set(): ...
tickPrice ( EWrapper self TickerId tickerId TickType field double price int canAutoExecute )
def tickPrice(self, tickerId, field, price, canAutoExecute): """tickPrice(EWrapper self, TickerId tickerId, TickType field, double price, int canAutoExecute)""" return _swigibpy.EWrapper_tickPrice(self, tickerId, field, price, canAutoExecute)
tickSize ( EWrapper self TickerId tickerId TickType field int size )
def tickSize(self, tickerId, field, size): """tickSize(EWrapper self, TickerId tickerId, TickType field, int size)""" return _swigibpy.EWrapper_tickSize(self, tickerId, field, size)
tickOptionComputation ( EWrapper self TickerId tickerId TickType tickType double impliedVol double delta double optPrice double pvDividend double gamma double vega double theta double undPrice )
def tickOptionComputation(self, tickerId, tickType, impliedVol, delta, optPrice, pvDividend, gamma, vega, theta, undPrice): """tickOptionComputation(EWrapper self, TickerId tickerId, TickType tickType, double impliedVol, double delta, double optPrice, double pvDividend, double gamma, double vega, double theta, ...
tickGeneric ( EWrapper self TickerId tickerId TickType tickType double value )
def tickGeneric(self, tickerId, tickType, value): """tickGeneric(EWrapper self, TickerId tickerId, TickType tickType, double value)""" return _swigibpy.EWrapper_tickGeneric(self, tickerId, tickType, value)
tickString ( EWrapper self TickerId tickerId TickType tickType IBString const & value )
def tickString(self, tickerId, tickType, value): """tickString(EWrapper self, TickerId tickerId, TickType tickType, IBString const & value)""" return _swigibpy.EWrapper_tickString(self, tickerId, tickType, value)
tickEFP ( EWrapper self TickerId tickerId TickType tickType double basisPoints IBString const & formattedBasisPoints double totalDividends int holdDays IBString const & futureExpiry double dividendImpact double dividendsToExpiry )
def tickEFP(self, tickerId, tickType, basisPoints, formattedBasisPoints, totalDividends, holdDays, futureExpiry, dividendImpact, dividendsToExpiry): """tickEFP(EWrapper self, TickerId tickerId, TickType tickType, double basisPoints, IBString const & formattedBasisPoints, double totalDividends, int holdDays, IBS...
orderStatus ( EWrapper self OrderId orderId IBString const & status int filled int remaining double avgFillPrice int permId int parentId double lastFillPrice int clientId IBString const & whyHeld )
def orderStatus(self, orderId, status, filled, remaining, avgFillPrice, permId, parentId, lastFillPrice, clientId, whyHeld): """orderStatus(EWrapper self, OrderId orderId, IBString const & status, int filled, int remaining, double avgFillPrice, int permId, int parentId, double lastFillPrice, int clientId, IBStr...
openOrder ( EWrapper self OrderId orderId Contract arg0 Order arg1 OrderState arg2 )
def openOrder(self, orderId, arg0, arg1, arg2): """openOrder(EWrapper self, OrderId orderId, Contract arg0, Order arg1, OrderState arg2)""" return _swigibpy.EWrapper_openOrder(self, orderId, arg0, arg1, arg2)
updateAccountValue ( EWrapper self IBString const & key IBString const & val IBString const & currency IBString const & accountName )
def updateAccountValue(self, key, val, currency, accountName): """updateAccountValue(EWrapper self, IBString const & key, IBString const & val, IBString const & currency, IBString const & accountName)""" return _swigibpy.EWrapper_updateAccountValue(self, key, val, currency, accountName)
updatePortfolio ( EWrapper self Contract contract int position double marketPrice double marketValue double averageCost double unrealizedPNL double realizedPNL IBString const & accountName )
def updatePortfolio(self, contract, position, marketPrice, marketValue, averageCost, unrealizedPNL, realizedPNL, accountName): """updatePortfolio(EWrapper self, Contract contract, int position, double marketPrice, double marketValue, double averageCost, double unrealizedPNL, double realizedPNL, IBString const &...
execDetails ( EWrapper self int reqId Contract contract Execution execution )
def execDetails(self, reqId, contract, execution): """execDetails(EWrapper self, int reqId, Contract contract, Execution execution)""" return _swigibpy.EWrapper_execDetails(self, reqId, contract, execution)
Error during communication with TWS
def error(self, id, errorCode, errorString): '''Error during communication with TWS''' if errorCode == 165: # Historical data sevice message sys.stderr.write("TWS INFO - %s: %s\n" % (errorCode, errorString)) elif errorCode >= 501 and errorCode < 600: # Socket read failed ...
updateMktDepth ( EWrapper self TickerId id int position int operation int side double price int size )
def updateMktDepth(self, id, position, operation, side, price, size): """updateMktDepth(EWrapper self, TickerId id, int position, int operation, int side, double price, int size)""" return _swigibpy.EWrapper_updateMktDepth(self, id, position, operation, side, price, size)
updateMktDepthL2 ( EWrapper self TickerId id int position IBString marketMaker int operation int side double price int size )
def updateMktDepthL2(self, id, position, marketMaker, operation, side, price, size): """updateMktDepthL2(EWrapper self, TickerId id, int position, IBString marketMaker, int operation, int side, double price, int size)""" return _swigibpy.EWrapper_updateMktDepthL2(self, id, position, marketMaker, operati...
updateNewsBulletin ( EWrapper self int msgId int msgType IBString const & newsMessage IBString const & originExch )
def updateNewsBulletin(self, msgId, msgType, newsMessage, originExch): """updateNewsBulletin(EWrapper self, int msgId, int msgType, IBString const & newsMessage, IBString const & originExch)""" return _swigibpy.EWrapper_updateNewsBulletin(self, msgId, msgType, newsMessage, originExch)
historicalData ( EWrapper self TickerId reqId IBString const & date double open double high double low double close int volume int barCount double WAP int hasGaps )
def historicalData(self, reqId, date, open, high, low, close, volume, barCount, WAP, hasGaps): """historicalData(EWrapper self, TickerId reqId, IBString const & date, double open, double high, double low, double close, int volume, int barCount, double WAP, int hasGaps)""" return _swigibpy.EWrapper_histo...
scannerData ( EWrapper self int reqId int rank ContractDetails contractDetails IBString const & distance IBString const & benchmark IBString const & projection IBString const & legsStr )
def scannerData(self, reqId, rank, contractDetails, distance, benchmark, projection, legsStr): """scannerData(EWrapper self, int reqId, int rank, ContractDetails contractDetails, IBString const & distance, IBString const & benchmark, IBString const & projection, IBString const & legsStr)""" return _swig...
realtimeBar ( EWrapper self TickerId reqId long time double open double high double low double close long volume double wap int count )
def realtimeBar(self, reqId, time, open, high, low, close, volume, wap, count): """realtimeBar(EWrapper self, TickerId reqId, long time, double open, double high, double low, double close, long volume, double wap, int count)""" return _swigibpy.EWrapper_realtimeBar(self, reqId, time, open, high, low, cl...
position ( EWrapper self IBString const & account Contract contract int position double avgCost )
def position(self, account, contract, position, avgCost): """position(EWrapper self, IBString const & account, Contract contract, int position, double avgCost)""" return _swigibpy.EWrapper_position(self, account, contract, position, avgCost)
accountSummary ( EWrapper self int reqId IBString const & account IBString const & tag IBString const & value IBString const & curency )
def accountSummary(self, reqId, account, tag, value, curency): """accountSummary(EWrapper self, int reqId, IBString const & account, IBString const & tag, IBString const & value, IBString const & curency)""" return _swigibpy.EWrapper_accountSummary(self, reqId, account, tag, value, curency)
Handles an error thrown during invocation of an EWrapper method.
def pyError(self, type, value, traceback): '''Handles an error thrown during invocation of an EWrapper method. Arguments are those provided by sys.exc_info() ''' sys.stderr.write("Exception thrown during EWrapper method dispatch:\n") print_exception(type, value, traceback)
Called after instantiating with a compressed payload Params: counts_len counts size to use based on decoded settings in the header
def init_counts(self, counts_len): '''Called after instantiating with a compressed payload Params: counts_len counts size to use based on decoded settings in the header ''' assert self._data and counts_len and self.counts_len == 0 self.counts_len = counts_len ...
Decompress a compressed payload into this payload wrapper. Note that the decompressed buffer is saved in self. _data and the counts array is not yet allocated.
def _decompress(self, compressed_payload): '''Decompress a compressed payload into this payload wrapper. Note that the decompressed buffer is saved in self._data and the counts array is not yet allocated. Args: compressed_payload (string) a payload in zlib compressed form ...
Compress this payload instance Args: counts_limit how many counters should be encoded starting from index 0 ( can be 0 ) Return: the compressed payload ( python string )
def compress(self, counts_limit): '''Compress this payload instance Args: counts_limit how many counters should be encoded starting from index 0 (can be 0), Return: the compressed payload (python string) ''' if self.payload: ...
Compress the associated encodable payload prepend the header then encode with base64 if requested
def encode(self): '''Compress the associated encodable payload, prepend the header then encode with base64 if requested Returns: the b64 encoded wire encoding of the histogram (as a string) or the compressed payload (as a string, if b64 wrappinb is disabled) ''' ...
Decode a wire histogram encoding into a read - only Hdr Payload instance Args: encoded_histogram a string containing the wire encoding of a histogram such as one returned from encode () Returns: an hdr_payload instance with all the decoded/ uncompressed fields
def decode(encoded_histogram, b64_wrap=True): '''Decode a wire histogram encoding into a read-only Hdr Payload instance Args: encoded_histogram a string containing the wire encoding of a histogram such as one returned from encode() Returns: a...
Record a new value into the histogram
def record_value(self, value, count=1): '''Record a new value into the histogram Args: value: the value to record (must be in the valid range) count: incremental count (defaults to 1) ''' if value < 0: return False counts_index = self._counts_...
Record a new value into the histogram and correct for coordinated omission if needed
def record_corrected_value(self, value, expected_interval, count=1): '''Record a new value into the histogram and correct for coordinated omission if needed Args: value: the value to record (must be in the valid range) expected_interval: the expected interval between 2 v...
Get the value for a given percentile
def get_value_at_percentile(self, percentile): '''Get the value for a given percentile Args: percentile: a float in [0.0..100.0] Returns: the value for the given percentile ''' count_at_percentile = self.get_target_count_at_percentile(percentile) ...
A faster alternative to query values for a list of percentiles.
def get_percentile_to_value_dict(self, percentile_list): '''A faster alternative to query values for a list of percentiles. Args: percentile_list: a list of percentiles in any order, dups will be ignored each element in the list must be a float value in [0.0 .. 100.0] Re...
Check whether 2 values are equivalent ( meaning they are in the same bucket/ range )
def values_are_equivalent(self, val1, val2): '''Check whether 2 values are equivalent (meaning they are in the same bucket/range) Returns: true if the 2 values are equivalent ''' return self.get_lowest_equivalent_value(val1) == self.get_lowest_equivalent_value(val2)
Reset the histogram to a pristine state
def reset(self): '''Reset the histogram to a pristine state ''' for index in range(self.counts_len): self.counts[index] = 0 self.total_count = 0 self.min_value = sys.maxsize self.max_value = 0 self.start_time_stamp_msec = sys.maxsize self.end_t...
Called during decoding and add to adjust the new min/ max value and total count
def adjust_internal_tacking_values(self, min_non_zero_index, max_index, total_added): '''Called during decoding and add to adjust the new min/max value and total count Args: ...
Called during decoding and add to adjust the new min/ max value and total count
def set_internal_tacking_values(self, min_non_zero_index, max_index, total_added): '''Called during decoding and add to adjust the new min/max value and total count Args: min_...
Return the index in the counts array for a given value
def get_counts_array_index(self, value): '''Return the index in the counts array for a given value ''' if value < 0: raise ValueError("Histogram recorded value cannot be negative.") bucket_index = self._get_bucket_index(value) sub_bucket_index = self._get_sub_bucket_...
Decode an encoded histogram and add it to this histogram Args: encoded_histogram ( string ) an encoded histogram following the V1 format such as one returned by the encode () method Exception: TypeError in case of base64 decode error HdrCookieException: the main header has an invalid cookie the compressed payload heade...
def decode_and_add(self, encoded_histogram): '''Decode an encoded histogram and add it to this histogram Args: encoded_histogram (string) an encoded histogram following the V1 format, such as one returned by the encode() method Exception: TypeError in case...
Decode an encoded histogram and return a new histogram instance that has been initialized with the decoded content Return: a new histogram instance representing the decoded content Exception: TypeError in case of base64 decode error HdrCookieException: the main header has an invalid cookie the compressed payload header...
def decode(encoded_histogram, b64_wrap=True): '''Decode an encoded histogram and return a new histogram instance that has been initialized with the decoded content Return: a new histogram instance representing the decoded content Exception: TypeError in case of ba...
Validate JSON according to JSONSchema
def _validate_json(self, checked_json, schema): """ Validate JSON according to JSONSchema *Args*:\n _checked_json_: validated JSON. _schema_: schema that used for validation. """ try: jsonschema.validate(checked_json, schema) except jsonschema.Validat...
Validate JSON according to schema loaded from a file.
def validate_jsonschema_from_file(self, json_string, path_to_schema): """ Validate JSON according to schema, loaded from a file. *Args:*\n _json_string_ - JSON string;\n _path_to_schema_ - path to file with JSON schema; *Raises:*\n JsonValidatorError *E...
Validate JSON according to schema.
def validate_jsonschema(self, json_string, input_schema): """ Validate JSON according to schema. *Args:*\n _json_string_ - JSON string;\n _input_schema_ - schema in string format; *Raises:*\n JsonValidatorError *Example:*\n | *Settings* | *Value...