Medved Trader HTTP API is backward compatible with QuoteTracker. Because of this backward compatibility, it is a bit "aged". We will be releasing a new API in the future.
The API responds to a certain set of commands so that external programs can extract information from it. The HTTP API server is bound to address 127.0.0.1 only - this way any information that is received from Medved Trader does not fall under the "redistribution" heading - and we avoid legal troubles from data providers or from the exchanges.
You must first enable the HTTP Server in Medved Trader. This is done on FILE / SETTINGS / APPLICATION / API screen .
By default, Medved Trader's Web server monitors port 16239 - you can change that on the SETTINGS screen as well.
The calling format is:
http://127.0.0.1:PortNum/Req?FunctionName(Param1,Param2,Param2,etc)
(where PortNum is the port number (default 16239 - see above), and the function names and parameters are described below.
Each call will return a text file. The 1 st line in the text file that is returned is the status line - it starts with either OK or Error and may contain the error message or additional information. The lines that follow the 1 st one are described below for each one of the functions:
|
EnumPorts() |
|
EnumPortSymbols(PortID) |
|
EnumSymbols() |
|
GetHistory(Symbol,FromDate,ToDate,Frequency,RTH Flag) |
|
GetLastQuote(Symbol,Symbol,Symbol....) |
|
GetTimeSales(Symbol,FromTime,ToTime) |
|
GetLinkedSymbol([color]) |
|
SetLinkedSymbol(Symbol[,color]) |
|
GetAppVersion() |
|
GetVersion() - DEPRECATED |
|
AddStocksToPort(PortID,Symbol,Symbol,...) |
|
AddDetailedStocksToPort(PortID,Symbol,Num_Shares,Base_Price,Commission,Symbol,Num_Shares,Base_Price,Commission,...) |
|
RemoveStocksFromPort(PortID,Symbol,Symbol,...) |
|
CloseApp() |
EnumPorts() |
^ to Top |
Description: Returns all portfolios - ID and Name. The portfolio currently selected on the main Medved Trader screen is always first in the list
Returns:
PortID,Port NamePortID,Port Name...
|
EnumPortSymbols(PortID) |
^ to Top |
Description: Returns symbols in the portfolio that is specified. If CURRENT is specified for PortID, then the currently selected portfolio on the main Medved Trader screen is used
Returns:
Ticker,Ticker,Ticker,Ticker,Ticker,...
|
EnumSymbols() |
^ to Top |
Description: Returns all symbols for which MT has data. If ACTIVE is specified as a parameter, then the function returns the symbols from all portfolios + WatchList, but excluding any symbols that may have been removed
Returns:
Ticker,Ticker,Ticker,Ticker,Ticker,...
|
GetHistory(Symbol,FromDate,ToDate,Frequency,RTH Flag) |
^ to Top |
Description: Returns the Historical Intraday and End of day data in OHLC format for the specified symbol
from FromDate to ToDate (if FromDate=0 - then from earliest, if ToDate=0 then to latest)
FREQUENCY: If just a number, then its in minutes, or xD for x Days (3D for example)or 1W, 1M, 1Y.
The D, W, M, and Y frequency types are for END OF DAY data ONLY.
Frequency specified in Days can be used for any number of days. For Week Month or Year, you can only use 1W, 1M, 1Y
If not specified, defaults to 1 minute
YES/NO (Default NO) - Regular Trading hours (if NO, then ALL data). This is based on the default timeframe for the symbol. Have to use the GUI to change timeframe.
Comment: This command does NOT request data. Only returns it if MT has retrieved Historical data on the symbol already
Returns:
Date,Time,Open,High,Low,Close,Volume
Date,Time,Open,High,Low,Close,Volume
NOTE: The DATE is in MM/DD/YYYY format
Example:
http://127.0.0.1:16239/req?GetHistory(AAPL,0,1/12/2006,1D)
Returns:
OK
01/04/1993,2.125,2.14286,2.0625,2.08036,32283970
01/05/1993,2.07143,2.11607,2.04465,2.11607,46563950
01/06/1993,2.16965,2.21429,2.16071,2.20536,70349920
01/07/1993,2.20536,2.23215,2.16518,2.17857,68034320
01/08/1993,2.16965,2.25001,2.13393,2.22322,80205920
01/11/1993,2.21429,2.29911,2.20536,2.29018,68431940
01/12/1993,2.24107,2.27679,2.19643,2.19643,86539520
01/13/1993,2.19643,2.28572,2.1875,2.26786,49909950
...
01/10/2006,10.8872,11.6986,10.8329,11.5514,570087800
01/11/2006,11.9886,12.1143,11.7986,11.9857,373548500
01/12/2006,12.14,12.3429,11.9457,12.0416,320201600
|
GetLastQuote(Symbol,Symbol,Symbol....) |
^ to Top |
Description: Returns "last quote" info for the specified tickers.
If * is specified, then it returns quotes on all stocks in the system
If ACTIVE is specified, then it returns the quotes on symbols from all portfolios
If CURRENT is specified, then it returns quotes on symbols from the currently selected portfolio on the main screen
Returns:
Ticker,Date,Time,Last,Bid,Ask,Change,Tick,Volume,High,Low,BidSize,AskSize,LastVolume,AvgTrade,NumTrades,Open,52w Low,52w High
Ticker,Date,Time,Last,Bid,Ask,Change,Tick,Volume,High,Low,BidSize,AskSize,LastVolume,AvgTrade,NumTrades,Open,52w Low,52w High
...
Example:
http://127.0.0.1:16239/req?getLastQuote(AAPL,NFLX)
Returns:
OK
AAPL,11/08/2017,02:08:44,175.67,175.66,175.67,0.86,-,15821675,175.79,174.33,300,200,60,279,56700,174.66,104.08,175.25
NFLX,11/08/2017,02:08:39,195.19,195.15,195.24,-0.70,-,2972433,197.09,194.74,200,300,100,222,13330,196,110.68,204.38
|
GetTimeSales(Symbol,FromTime,ToTime) |
^ to Top |
Description: Returns "time and sales" info for the specified ticker from FromTime to ToTime (if FromTime=0 - then from earliest, if ToTime=0 then to latest)
Returns:
Date,Time,Last,Ask,Bid,Volume
Date,Time,Last,Ask,Bid,Volume
NOTE: The DATE is in MM/DD/YYYY format
Example:
http://127.0.0.1:16239/req?GetTimeSales(NFLX,09:45:00,09:47:00)
Returns:
OK
11/08/2017,09:45:00,196.639,196.48,196.64,1
11/08/2017,09:45:00,196.481,196.48,196.63,2
11/08/2017,09:45:01,196.5504,196.48,196.63,200
11/08/2017,09:45:04,196.61,196.47,196.61,50
11/08/2017,09:45:05,196.6,196.46,196.61,10
11/08/2017,09:45:05,196.61,196.46,196.61,1
11/08/2017,09:45:06,196.6,196.47,196.61,50
...
|
GetLinkedSymbol([color]) |
^ to Top |
Description:Returns the currently lined symbol in the program
Comment: At least one window must be linked in the program for a symbol to be returned
You can specify the linked group for which you want the symbol. You would specify one of the following colors (GRAY is the default if none are specified):
Blue,Green,Red,Cyan,Brown,Black,Gray,Pink,Purple,LawnGreen,Maroon or Yellow
Example:
http://127.0.0.1:16239/req?GetLinkedSymbol(Blue)
Returns:
OK
SYMBOL
or
NO
|
SetLinkedSymbol(Symbol[,color]) |
^ to Top |
Description:Sets the linked symbol in the program to the one specified as the parameter
Comment: Added in 3.2.0 version. At least one window must be linked in the program for this command to work
Starting with Version 3.6.9I, you can specify the linked group for which you want to set the symbol. You would specify one of the following colors (GRAY is the default if none are specified):
GRAY,RED,GREEN,BLUE,CYAN or YELLOW
Example:
http://127.0.0.1:16239/req?SetLinkedSymbol(DELL,GRAY)
Returns:
OK
|
GetAppVersion() |
^ to Top |
Description: Returns the current Medved Trader app version
Returns:
OK
1.1.6030.1802
|
GetVersion() |
^ to Top |
Description:DEPRECATED: FOR COMPATIBILITY to QT only.
Returns:
OK
3.980
|
AddStocksToPort(PortID,Symbol,Symbol,...) |
^ to Top |
Description: Adds specified symbols to the end of the specified portfolio. PortID is the ID of the portfolio, or CURRENT for
currently shown portfolio, or NEW:Portfolio+Name for a new portfolio.
NOTE: Medved Trader will NOT check for duplicates during this call. You must do that yourself
Example:
http://127.0.0.1:16239/req?AddStocksToPort(CURRENT,MSFT,INTC)
Returns:
OK portfolio updated
...
|
AddDetailedStocksToPort(PortID,Symbol,Num_Shares,Base_Price,Commission,Symbol,Num_Shares,Base_Price,Commission,...) |
^ to Top |
Description: Adds specified symbols to the end of the specified portfolio with specified parameters. PortID is the ID of the portfolio, or CURRENT for
currently shown portfolio, or NEW:Portfolio+Name for a new portfolio.
NOTE: Medved Trader will NOT check for duplicates during this call. You must do that yourself
Example:
http://127.0.0.1:16239/req?AddDetailedStocksToPort(CURRENT,MSFT,100,10.5,9.95)
Returns:
OK portfolio updated
...
|
RemoveStocksFromPort(PortID,Symbol,Symbol,...) |
^ to Top |
Description: Removes specified symbols from the specified portfolio. PortID is the ID of the portfolio, or CURRENT for
currently shown portfolio.
Example:
http://127.0.0.1:16239/req?RemoveStocksFromPort(CURRENT,MSFT,INTC)
Returns:
OK portfolio updated
...
|
CloseApp() |
^ to Top |
Description:Tells Medved Trader to close itself.
Example:
http://127.0.0.1:16239/req?CloseApp()
Returns:
Shutting down Medved Trader
...
|
|