Jump to content
Sign in to follow this  
Yooyi

Place market order

Recommended Posts

Hi I just wanted to know if I could make market order ? From what I read on the forum and on the docs I need to send the order with the right Bid and Offer from the data collected with Lightstreamer, however I think using Lightstreamer is overkill from what I want to do. Do you know any other alternative to acheive what I want ? I think using another api to get the right price just before making a trade would be good but not all the broker shows the same price or have the same spread

thank you.

Share this post


Link to post

Hello Yooyi,

Yes, the process you mentioned in your post is the one to use in order to send market orders.

Unfortunately, there is no alternative way to using Lightstreamer as trade requests must be sent with the latest live market price, which is received from Lightstreamer. 

Kind Regards, PM

 

Share this post


Link to post

Hi thank you for your reply, I tried implement Lightstreaming in Python, however you are using Lightstreamer 4 and the example provided on Github is for 6+. They provide an example for Lightstreamer 5.1.2 that I assume is compatible with 4 but for Python 2, I tried to port it to python 3 and its kinda work, I only get 'OK' from the server but apparently I should receive a session_key and a session_value. Do you have any idea ?

Share this post


Link to post

Hello,

We upgraded our servers at the start of this year to the latest Lightsreamer v7.03. You should be able to find documentation/examples to work with the latest version?

To use Lightstreamer, you should use your account username and password to Login to the REST API - see: http://docs.labs.gaincapital.com/#HTTP Services/LogOn.htm%3FTocPath%3DCIAPI%20Reference|HTTP%20Services|Authentication|_____3.

With a successful REST API login, you will receive a Session ID back from the API. To authenticate with Lightstreamer, the login credentials are your account username and the Session ID from the REST API as the password. 

Once authenticated with Lightstreamer, you can then subscribe to receive live streaming market prices.

Kind Regards, PM

 

Share this post


Link to post

Hi, yeah I already use my username and the session to request a Lightstreamer connection but the problem is the Subscription, I don't know if its good or not plus the server just answer 'ERROR' and nothing else :(

subscription = Subscription(
    mode="MERGE",
    items=["PRICES.PRICE.154297"],
    fields=["MarketId", "TickDate", "Bid"],
    adapter="STREAMINGALL")

Here is the log :

2019-12-06 10:22:29,603 DEBUG   MainThread      Opening a new session to <https://push.cityindex.com/>
2019-12-06 10:22:29,604 DEBUG   MainThread      Making a request to <https://push.cityindex.com/lightstreamer/create_session.txt> with body <b'LS_op2=create&LS_cid=****+kOj2Bg&LS_adapter_set=STREAMINGALL&LS_user=DA****&LS_password=****-99c7-434f-****-e1a8fc0f7f1e'>
2019-12-06 10:22:29,887 INFO    MainThread      Successfully connected to <https://push.cityindex.com/>
2019-12-06 10:22:29,887 DEBUG   MainThread      Starting to handling real-time stream
2019-12-06 10:22:29,889 DEBUG   StreamThread-0  Waiting for a new message
2019-12-06 10:22:29,889 INFO    MainThread      Started handling of real-time stream
Trying to subscribe
2019-12-06 10:22:29,889 DEBUG   MainThread      Making a new subscription request
2019-12-06 10:22:29,889 DEBUG   MainThread      Making a request to <https://pusha202.cityindex.com/lightstreamer/control.txt> with body <b'LS_Table=1&LS_op=add&LS_data_adapter=STREAMINGALL&LS_mode=MERGE&LS_schema=MarketId+TickDate+Bid&LS_id=PRICES.PRICE.154297&LS_session=****'>
2019-12-06 10:22:30,175 DEBUG   MainThread      Server response: <ERROR>
2019-12-06 10:22:30,178 WARNING MainThread      Subscription error
2019-12-06 10:22:32,179 DEBUG   MainThread      Making an unsubscription request
2019-12-06 10:22:32,179 DEBUG   MainThread      Making a request to <https://pusha202.cityindex.com/lightstreamer/control.txt> with body <b'LS_Table=1&LS_op=delete&LS_session=****'>
2019-12-06 10:22:32,460 DEBUG   MainThread      Server response: <ERROR>
2019-12-06 10:22:32,462 WARNING MainThread      Unsubscription error
2019-12-06 10:22:32,463 DEBUG   MainThread      Closing session to <https://push.cityindex.com/>
2019-12-06 10:22:32,463 DEBUG   MainThread      Making a request to <https://pusha202.cityindex.com/lightstreamer/control.txt> with body <b'LS_op=destroy&LS_session=****'>
2019-12-06 10:22:32,716 DEBUG   StreamThread-0  Received message: <END 31>
2019-12-06 10:22:32,716 DEBUG   MainThread      Server response: <OK>
2019-12-06 10:22:32,717 INFO    StreamThread-0  Connection closed by the server
2019-12-06 10:22:32,718 DEBUG   MainThread      Waiting for thread to terminate
2019-12-06 10:22:32,719 DEBUG   StreamThread-0  No rebind to <https://push.cityindex.com/>, clearing internal session data
2019-12-06 10:22:32,721 DEBUG   MainThread      Thread terminated
2019-12-06 10:22:32,722 INFO    MainThread      Closed session to <https://push.cityindex.com/>

 

Share this post


Link to post

Hi,

Are you a US or non-European client? 

It appears that the market you are using is the one used as an example in the documentation, which happens to be a CFD market. CFDs are only tradeable to clients in certain regions.

Please try subscribing to a market that you have access to trade. You can complete the following instructions to search for the MarketIDs that you can access: http://docs.labs.gaincapital.com/#How Do I/Find Market ID.htm%3FTocPath%3DHow%20Do%20I...%3F|_____1.

Kind Regards, PM

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  
×