How to scan for low float in TWS API - algorithmic-trading

After looking at the 53,684 lines of xml that define the limits of what the scanner will allow for, I found that TWS doesn't support scan based on the float. It will let you scan for shares held by insiders, shares held by institutions, and shares available to short but not the actual float. It has this information as I can see there's a field Insider Shares as % of Float but nothing for the actual float. I looked at marketcap as an alternative but the only fields for that are whether the marketCap is above or below $1,000,000. This isn't posted in their documentation. It's only when you go to run and scan that you get the full xml file as a response. Is there a better way to get a scan for float?

Related

Returning strings from a PRTG custom sensor

I'm trying to develop a custom VBScript sensor for the PRTG monitoring tool and the interface seems fairly simple, returning just a 32-bit integral value and a status string such as with:
WScript.echo "0:January 23, 2015"
However, only the integer appears on the front screen, you have to go into the sensor detail screen itself to get the descriptive text.
Now I think you can generate textual data to be displayed as the result (rather than the descriptive text) since the SSL security check sensor displays Only Strong Protocols Possible:
I tried returning the date as an integer along the lines of 20150123 but that has two problems:
It displays it "nicely" so you get 20,150,123 which looks nothing like a date; and
Being an integer, it maintains minima, maxima, averages and alarm levels, which seems a little silly given it'll always be above twenty million (assuming it uses current dates).
So, my question is: how do you create and code up a custom sensor that can return a string rather than just an integer, float or counter, which seem to be the only three options available?
You should look at the SSH sensor and see if you can do something similar with the sensor you are trying to use. For the SSH sensor you return data in the format of returncode:value:message. Return code 0 is OK, 1-4 are errors, value is a 64-bit integer, and message can be a string. Take a look at this PRTG forum post
Since the value you are returning is a date, lookups won't help you much but I'm going to mention them anyways because if you look at some of the built-in sensor types that is how they get string messages. Specifically the SSL Security Rating channel. If you click on the gear for a Value channel one of the fields is Value Lookup. There are lots of preconfigured lookups, but you can also create your own. Here's a relevant PRTG forum post

writing netcdf parallel files from only certain processors

I've come across a specific task to create a netcdf file which stores data only from certain processors. The matter is the following-I have 3d field, divided into (nx) x (ny) x (nz) domains. Each domain has a processor assigned to it. I would like to save data only from domains in certain position in x direction. This means that the data would come only from ny x nz processors. I've been trying to find examples on how to write such data, but unsucessfully. Does anyone know if this is doable and also-are there specific commands I should use.
For example, I tried to invoke writing data with using if conditions where I used if(mpid%rank==0) then... together with nf90_var_par_access(ncid, varid, nf90_independent) call, but without success, the procedure seems to get stuck.
thank you in advance!
Actually, I've managed to resolve the issue just hours after I posted the question. The main trouble was the dimension length definition in nf90_def_dim call. In it, the code I have assumed by default the dimension, which was a product of number of domains and points in them. I changed that definition to adapt to the case when only certain domains are used and the write process on only few processors worked.
regards to all

QoS bandwidth via SNMP

I currently have a script to glean QoS data from differing cisco routers and this is working well but missing the bandwidth data for each class.
I can see that the data is available in that querying:
enterprises.9.9.166.1.9.1.1.1.1608 = INTEGER: 425
Returns the correct bandwidth for this particular class [425kb]. I have seen this index elsewhere:
enterprises.9.9.166.1.5.1.1.2.6933270.5456067 = Gauge32: 1608
With '6933270' being one of the indexes associated with the interface I am interested in.
How though do I 'learn' the second index '5456067' or is there another way to derive the class bandwidth?
I have scoured Google which has me at this point but I am unable to get any closer to the second index. Multiple snmpwalks grepping the second index show no light either in that I can find no way to relate to this from existing known data.
Thanks
I think you get the wrong oid entry. enterprises.9.9.166.1.5.1.1.2 stands for cisco cbQosConfigIndex from mib, if you want to get the bandwidth, you should use the 1.3.6.1.4.1.9.9.166.1.9.1.1.2 which means QueueingBandwidthUnits instead.

How to Query Accident Information in FHIR?

I'm investigating HL7-FHIR for use in a decision support context and was trying to find out how to extract accident information for a given patient. I had assumed this would be a resource type but I can't find anything that fits.
We don't have a specific resource for this information. Mostly, this sounds like a series of observations, and perhaps a context linking them together. It's the context piece that we haven't yet got (our initial focus was on PHR). That will definitely be in the next version, but for now, I guess you just use the observations directly

What pre-existing services exist for calculating distance between two addresses?

I'd like to implement a way to display a list of stored addresses sorted by proximity to a given address.
Addresses in the list will be stored in a database table. Separate parts have separate fields (we have fields for postal code, city name, etc.) so it is not just a giant varchar. These are user-entered and due to the nature of the system may not always be complete (some may be missing postal code and others may have little more than city and state).
Though this is for an intranet application I have no problems using outside resources including accessing internet web services and such. I'd actually prefer that over rolling my own unless it would be trivial to do myself. If Google or Yahoo! already provides a free service, I'm more than willing to check it out. The keyword is it must be free, as I'm not at liberty to introduce any additional cost onto this project for this feature as it is already a bonus "perk" so to speak.
I'm thinking of this much like many brick & mortar shops do their "Find a Location" feature. Showing it in a simple table sorted appropriately and displaying distance (in, say, miles) is great. Showing a map mash-up is even cooler, but I can definitely live with just getting the distance back and me handling all of the subsequent display and sorting.
The problem with simple distance algorithms is the nature of the data. Since all or part of the address can be undefined, I don't have anything convenient like lat/long coords. Also, even if I make postal codes required, 90% of the addresses will probably have the same five postal codes.
While it need not be blisteringly fast, anything that takes more than seven seconds to show up on the page due to latency might be too long for the average user to wait, as we know. If such a hypothetical service supports sending a batch of addresses at once instead of querying one at a time, that'd be great. Still, I should not think the list of addresses would exceed 50 total, if that many.
Google and Yahoo! both provide geocoding services for free. You can calculate distance using the Haversine formula (implemented in .NET or SQL). Both services will let you do partial searches (zip code only, city only) and will let you know what the precision of their results are (so that you can exclude locations without meaningful information, though Yahoo! provides more precision info than Google).
The Google Maps API is no good to you due to their terms of use. However, Yahoo offer a REST service for turning addresses into Long/Lat coordinates, which you could then use to calculate distances. Its here.
Require them to enter a ZIP code, then create a database table mapping ZIP code to latitude/longitude pairs (or find one online). I don't know how it is where you work but over here, ZIP code can be specific to several meters, so that should be precise enough. Then use this method to calculate the distance between two ZIP codes:
public static double distance(double lat1, double lon1, double lat2, double lon2, char unit)
{
double theta = lon1 - lon2;
double dist = Math.Sin(deg2rad(lat1)) * Math.Sin(deg2rad(lat2)) +
Math.Cos(deg2rad(lat1)) * Math.Cos(deg2rad(lat2)) * Math.Cos(deg2rad(theta));
dist = Math.Acos(dist);
dist = rad2deg(dist);
dist = dist * 60 * 1.1515;
if (unit == 'K')
{
dist = dist * 1.609344;
}
else if (unit == 'N')
{
dist = dist * 0.8684;
}
return (dist);
}
private static double deg2rad(double deg)
{
return (deg * Math.PI / 180.0);
}
private static double rad2deg(double rad)
{
return (rad / Math.PI * 180.0);
}
The advantage of using your own code over a geocoding service is that you can then do a bunch more interesting calculations against the data as well as storing stuff alongside it in your db.
Can't you just use google maps API to get the distances and sort them on your side?
http://code.google.com/apis/maps/
I'd suggest investigating the google maps API.
It would require you to have an external connection (and for it to be alright to shunt the data over it to a web service) but it provides what you require, namely the distance by asking for a route between 2 points and getting the distance from it.
API reference of the directions API
One thing we've done at my company is to cheat and use the latitude/longitude of the zip code (Roughly the center of the zip code area). It's not perfect, but it's close enough for those find me x within n miles of y types of searches. This is especially helpful when the addresses can't be recognized by address cleaning services.
At some point I came across a free zip code to latitude/longitude lookup table to use in this approximation. I'm sorry I don't have the link to this any more.
Check out this website: http://geocoder.us/help/utility.shtml
You can process records, 1 per 15 seconds like this:
http://geocoder.us/service/distance?zip1=95472&zip2=94305
They also have a subscription service without the time limit
Someone else has done it already at Daft Logic (edit: typo). They use Google Maps API with the Great-circle formula. I don't think it's hard to implement.
Update: Practically, you only need to get the coordinates from your favourite provider, then do the calculation with your code. You can preload the shops' coordinates, when users provide their location - you can even use this for validation. Then, when the request is made, you can only lookup the customer's location.

Resources