Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Any GRPC sample code on how to get price, buy, and sell coins? #19

Open
nomadph999 opened this issue Aug 6, 2021 · 4 comments
Open

Comments

@nomadph999
Copy link

It would be great if someone from Lykke would whip up a fast simple sample code / functions on Python on how to get price of a coin in a stream/socket, buy, and sell coins with Lykke's grpc api.

Does anyone have one that we could look at?

@AxelGUILLAUMET
Copy link

AxelGUILLAUMET commented Sep 4, 2021

Same for me!

For the moment I only got it with

https://hft-apiv2.lykke.com/swagger/ui/index.html

Example:

                AllAssets = public_api.GetAssets(google.protobuf.empty_pb2.Empty())

                for Asset in AllAssets.payload:
                    if Asset.symbol == TRADE_TO:
                        AssetAccuracy = Asset.accuracy

                headers = {
                    'Content-Type': 'application/json',
                    'Accept': 'application/json',
                    'api-key': settings.API_KEY_LYKKE,
                }

                quantity_to_buy = (float(asset_per_position) / float(actual_price))

                config.set('botstate', 'GRID_ASSET_QUANTITY'+str(grid_position), str(quantity_to_buy))
                grids[grid_position,2] = float(quantity_to_buy)

                data = {"AssetPairId": TRADE_CURRENCY.replace('/', ''), "Asset": TRADE_TO, "OrderAction": "Buy","Volume": round(quantity_to_buy,AssetAccuracy)}

                response = requests.post('https://hft-api.lykke.com/api/Orders/v2/market', headers=headers, data=json.dumps(data))

@KonstantinRyazantsev
Copy link

@AxelGUILLAUMET
Copy link

Yes but is you can add an BUY/SELL Exemple, or other type of accion with INPUTS PARAMETERS it should be great!

Regards.

@samodovdi
Copy link
Contributor

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants