Friday, January 8, 2021

Niu’s Earnings Push The Share Price Up

Niu Technologies (NASDAQ: NIU) saw an increase in its share price after delivering its e-scooter sales volume results for Q4 2020. In total, NIU exhibited more than 40% Q/Q sales growth and 42% Y/Y sales growth. That’s not all. In the China market, NIU reported 45% revenue growth Y/Y. Read More In StockMarketRevolution.com

NIU’s Big Data Business Could Make The Stock Double

NIU (NIU) appears to be valued at 3.1x forward sales and 20x EBITDA, which does not seem cheap. However, investors need to take into account the company’s usage of its own data. In my opinion, if the market starts seeing the company as a tech company, 6x forward sales could make sense. Read More In Stockmarketrevolution.com

Friday, October 21, 2016

3rd Interactive Brokers Java API Tutorial (Download Mkt Data)

Hi,

Today I will show you how to download tick market data from Interactive Brokers. I will use this method: reqMktData(). You can check the Interactive Brokers website here. You will see the following parameters:


Parameter Type Description
id TickerId The ticker id. Must be a unique value. When the market data returns, it will be identified by this tag. This is also used when canceling the market data.
contract Contract This structure contains a description of the contract for which market data is being requested.
genericTicks IBString A comma delimited list of generic tick types. Tick types can be found in the Generic Tick Types page.
snapshot bool Check to return a single snapshot of market data and have the market data subscription cancel. Do not enter any genericTicklist values if you use snapshot.
mktDataOptions TagValueListSPtr For internal use only. Use default value XYZ.
Source: https://www.interactivebrokers.com/en/software/api/apiguide/tables/generic_tick_types.htm

To receive the market data from the API you will need to use one of the following methods: tickPrice() and tickSize(). These are the variables that you will need to use for the tickPrice method:

Parameter Type Description
tickerId int The ticker Id that was specified previously in the call to reqMktData()
field int Specifies the type of price. Pass the field value into TickType.getField(int tickType) to retrieve the field description.  For example, a field value of 1 will map to bidPrice, a field value of 2 will map to askPrice, etc.
  • 1 = bid
  • 2 = ask
  • 4 = last
  • 6 = high
  • 7 = low
  • 9 = close
price double Specifies the price for the specified field
canAutoExecute int Specifies whether the price tick is available for automatic execution. Possible values are:
  • 0 = not eligible for automatic execution
  • 1 = eligible for automatic execution

Source: https://www.interactivebrokers.com/en/software/api/apiguide/java/tickprice.htm

These are the variables for the tickSize method:

Parameter Type Description
tickerId int The ticker Id that was specified previously in the call to reqMktData()
field int
Specifies the type of price.
Pass the field value into TickType.getField(int tickType) to retrieve the field description.  For example, a field value of 0 will map to bidSize, a field value of 3 will map to askSize, etc.
  • 0 = bid size
  • 3 = ask size
  • 5 = last size
  • 8 = volume
size int Specifies the size for the specified field

Source: https://www.interactivebrokers.com/en/software/api/apiguide/java/ticksize.htm

I do not want to explain everything, you have the video, and you are smart (you are reading this, so you should be):



Source: https://www.youtube.com/watch?v=59pXOy4AIHE

Enjoy!

Thursday, October 20, 2016

2nd Video Tutorial Java API and Swing

Hi,

This post will be interesting for those who may be afraid of all the programming tools that I will show in the blog. In this video tutorial you will see an application made in Swing that connects to the Interactive Brokers Java API to send orders.

It is a short video to show what is the goal of this blog: make things easy for traders and trade fast. So, for those who are starting to learn programming, this is the kind of thing that I want to teach you:



In the video you can see that I work with two TWS at the same time. One is the demo account and the other is a real account. You want to do this to test your algorithms in real time. With this kind of system you can receive data from the real account, make some analysis, and send orders to the market. 


Welcome to the blog, first Interactive Brokers API video tutorial

Hi, 

Welcome to my ibapilessons blog. I am an independent trader, who uses systematic bots to make money in the market. Before becoming my own boss I worked for some financial institutions in Europe. That is the way I learned, but there are many other ways to do it!

In this blog I will try to give you some tips.

I will not include my code in the blog, instead you can see it in the videos from my Youtube channel: IB Lessons. In these videos you will see how to use the Interactive Brokers Java API, which is the most professional trading platform that I found. What I will include in this blog are links to the Interactive Brokers website, which are extremely useful, and sometimes information about Quant strategies and links to learn about them.

If you need help with the API, you want to learn more, or you need a programmer to develop your coolest strategy, you can send me an e-mail to ibapilessons@gmail.com.

I hope you enjoy the videos!

You can start with this one first:


In this video you could see the method eConnect(), which is used to connect to the TWS. You can have information about this method here


Parameter Type Description
host String The host name or IP address of the machine where TWS is running. Leave blank to connect to the local host.
port int Must match the port specified in TWS on the Configure>API>Socket Port field.
clientId int
A number used to identify this client connection. All orders placed/modified from this client will be associated with this client identifier.
Note:  Note: Each client MUST connect with a unique clientId.

Source: https://www.interactivebrokers.com/en/software/api/apiguide/java/econnect.htm
 
This may be an example:

client.eConnect(null, 7496, 1);    

This method does not return any value confirming the connection, so you should check the state of you programm with this method client.isConnected().

Another method that appears in the video is the placeOrder() method. Here are the parameters that you need to introduce:

Parameter Type Description
id int The order Id. You must specify a unique value. When the order status returns, it will be identified by this tag. This tag is also used when canceling the order.
contract Contract This class contains attributes used to describe the contract.
order Order This structure contains the details of the order. Note: Each client MUST connect with a unique clientId.


Source: https://www.interactivebrokers.com/en/software/api/apiguide/java/placeorder.htm

But, in order to make that method work, you will need to create a contract object. You can find information about the Contract class here.

 
Attribute Description
Vector m_comboLegs Dynamic memory structure used to store the leg definitions for this contract.
String m_comboLegsDescrip Description for combo legs
int m_conId The unique contract identifier.
String m_currency Specifies the currency. Ambiguities may require that this field be specified, for example, when SMART is the exchange and IBM is being requested (IBM can trade in GBP or USD).  Given the existence of this kind of ambiguity, it is a good idea to always specify the currency.
String m_exchange The order destination, such as Smart.
String m_expiry The expiration date. Use the format YYYYMM.
boolean m_includeExpired
If set to true, contract details requests and historical data queries can be performed pertaining to expired contracts.
Note: Historical data queries on expired contracts are limited to the last year of the contracts life, and are initially only supported for expired futures contracts,
String m_localSymbol This is the local exchange symbol of the underlying asset.
String m_multiplier Allows you to specify a future or option contract multiplier. This is only necessary when multiple possibilities exist.
String m_primaryExch Identifies the listing exchange for the contract (do not list SMART).
String m_right Specifies a Put or Call. Valid values are: P, PUT, C, CALL.
String m_secId Unique identifier for the secIdType.
String m_secIdType Security identifier, when querying contract details or when placing orders. Supported identifiers are:
  • SIN (Example: Apple: US0378331005)
  • CUSIP (Example: Apple: 037833100)
  • SEDOL (Consists of 6-AN + check digit. Example: BAE: 0263494)
  • RIC (Consists of exchange-independent RIC Root and a suffix identifying the exchange. Example: AAPL.O for Apple on NASDAQ.)
String m_secType This is the security type. Valid values are:
  • STK
  • OPT
  • FUT
  • IND
  • FOP
  • CASH
  • BAG
  • NEWS
double m_strike The strike price.
String m_symbol This is the symbol of the underlying asset.
String m_tradingClass The trading class name for this contract.

Source: https://www.interactivebrokers.com/en/software/api/apiguide/java/contract.htm

That is all for today! You can send me a mail if you do not figure out the methods and classes.

PD. I am not a native English speaker, yes I am sorry for that, I may hire somebody to check my mistakes in the future. I hope everything makes sense.