I am trying to obtain order book (buy, sell, volume, price) info from GDAX.
I am familiar with the Bittrex api - specifically this call:
https://bittrex.com/api/v1.1/public/getmarketsummary?market=usdt-eth
which produces the following response:
{
success: true,
message: "",
result: [
{
MarketName: "USDT-ETH",
High: 770,
Low: 729.70000005,
Volume: 12847.90985907,
Last: 752,
BaseVolume: 9641897.74525487,
TimeStamp: "2017-12-27T13:49:29.463",
Bid: 751.99999999,
Ask: 752.9999,
OpenBuyOrders: 2072,
OpenSellOrders: 1933,
PrevDay: 738.99899999,
Created: "2017-04-20T17:26:37.647"
}
]
}
Does anyone know what the equivalent call would be in the gdax api ?
I am using Python and tried out Client.get_product_order_book('ETH-USD')
but its output is limited and the order book seems rather thin.
In [54]: client.get_product_order_book('ETH-USD')
Out[54]:
{'asks': [['756.97', '168.24847073', 8]],
'bids': [['756.96', '77.74495889', 14]],
'sequence': 1810832728}
Based on the docs the call above with level=1 corresponds to the inside
(i.e. best bid and ask prices)
But the output from the Bittrex api seems to be the best bid and ask prices as
well. So does anyone know the difference ?
Does anyone know what the equivalent call would be in the gdax api ?
If you want something similar, a better try would be:
>> client.get_product_24hr_stats('ETH-USD')
>> {
"open": "416.11000000",
"high": "433.83000000",
"low": "410.11000000",
"volume": "91763.71115699",
"last": "432.79000000",
"volume_30day": "4011593.85194549"
}
I am using Python and tried out Client.get_product_order_book('ETH-USD') but its output is limited and the order book seems rather thin.
Level Description
1 Only the best bid and ask
2 Top 50 bids and asks (aggregated)
3 Full order book (non aggregated)
You are calling it with the default level of 1 so you are only getting the lowest ask and the highest bid, only 2, so yes, it's thin. If you need more info, consider calling it with level 2 or 3 according to the snippet above taken from the GDAX official docs. More here.
But the output from the Bittrex api seems to be the best bid and ask prices as well. So does anyone know the difference ?
The difference is that Bittrex only gives you the best bid and ask price while GDAX api gives you the bid/ask price, the total size of all the orders, and the number of orders.
Related
Is there an API for getting all spot-prices of supported with just one call ?
For now, it seems possible only for each currency pair e.g.) BTC-USD
However, I've found the following API to support it but it's not officially listed on the developer site
https://api.coinbase.com/v2/prices/usd/spot
Can I use this API for getting all price data of all supported coins ?
Thanks
I believe the only way to get the prices for all coins in a single request is to use the exchange-rates endpoint but it gets more than what coinbase trades and since this tells you how much you can get for 1 USD, you have to do the 1/rate math to get the price.
for example
1 ATOM = 1 / 0.04149635869452455 = $24.0985
https://api.coinbase.com/v2/exchange-rates?currency=USD
{
"data": {
"currency": "USD",
"rates": {
"AED": "3.672973",
"AFN": "97.372693",
"ALL": "107.034241",
"AMD": "490.957033",
"ANG": "1.803208",
"AOA": "564",
"ARS": "101.5085",
"AUD": "1.399191",
"AWG": "1.8",
"AZN": "1.700805",
"BAM": "1.729247",
"BBD": "2",
"BDT": "85.824273",
"BGN": "1.72742",
"BHD": "0.377048",
"BIF": "1994.142167",
"BMD": "1",
"BND": "1.366618",
"BOB": "6.898625",
"BRL": "5.552737",
"BSD": "1",
"BTN": "75.524027",
"BWP": "11.716473",
"BYN": "2.536338",
...
}}}
Otherwise you'd probably need to get all the products and get the ticker price for each product but you'd have to throttle it so you don't make to many requests per second.
loop the results from
https://api.exchange.coinbase.com/products
and use
https://api.exchange.coinbase.com/products/{product_id}/ticker
to get the price.
A sample code of mine:
import ccxt
binance = ccxt.binance({
'enableRateLimit': True,
'apiKey': '****',
'secret': '****',
'options': {'defaultType': 'margin'}
})
binance.create_order('BTC/USDT', 'take_profit_limit', 'buy', 0.1, price = binance.fetch_ticker('BTC/USDT')['last'], params = {'type': 'takeProfit', 'stopPrice' : stop})
where stop > price and I get the following error:
ccxt.base.errors.OrderImmediatelyFillable: binance Stop price would
trigger immediately.
It seems to me that it is attempting to place a stop-loss at the price "stop" rather than a take-profit limit order which is what I want. I see on the documentation for the Binance API that the only extra parameter involved with the take_profit_limit order type is this stopPrice and not a similar "take_profit". I can also set a take-profit order the way I want to manually on the binance website by just setting this trigger price "stop" to be greater than the buying-in price, but I just can't get ccxt to do it.
I'm afraid I couldn't find anything to help in the Almighty Kroiter's examples either, but I may have missed something so I'm open to helpful links as well!
The take_profit_limit order type is meant to trigger a Buy when the price falls to the stop price and then you buy it at the limit price. If you want to buy after the price rises to a particular point, use the STOP_LOSS_LIMIT order type. If you want to buy right away simply use a LIMIT order.
Many thanks for looking at this for me.
I am working in IBM ACE V11 software and in my service, I receive a JSON message.
I need to map this JSON message to a SOAP request via ESQL.
Please see the sample message below:
Incoming JSON message:
"journals": [
{
"journalName": "Plant Species in London",
"journalYear": "2016",
"journalAuthor": [
{
"name": "Julian Bose",
"subject": "botany"
}
{
"name": "Samantha Adams",
"subject": "biology"
},
],
"samplePolling": {
"pollingInterval": 120,
"totalAttempts": 10
}
},
],
"supervisorName": "James Smith"
}
In ESQL I have so far:
For Journal's Name:
SET OutputRoot.SOAP.Body.ns:submitJournal.ns:journalName = InputRoot.JSON.Data.journals.journalName;
For Journal's Year:
SET OutputRoot.SOAP.Body.ns:submitJournal.ns:journalYear = InputRoot.JSON.Data.journals.journalYear;
For Journal's Author, I have a problem. The problem is that there can be 0 to 3 or more authors.
In this case, there are 2 authors.
How do I first check if any authors are present and if so, how many are there and then how to assign each authors' details to SOAP. (All of this in ESQL).
In ESQL I have this so far. But I don't know how to get the "n" value. (n represents no. of authors).
SET OutputRoot.SOAP.Body.ns:submitJournal.ns:journalAuthorValues[n].ns16:AuthorName = InputRoot.JSON.journals.journalAuthor[n].name;
Any and all help is greatly appreciated.
For Journal's Author, I have a problem. The problem is that there can be 0 to 3 or more authors. In this case, there are 2 authors.
You need to iterate over the array of authors, and you are assuming that you need to count the number of authors. But you do not need to. This should work just fine (not tested, may contain syntax errors)
FOR refAuthor AS InputRoot.JSON.Data.journals.(JSON.Array)journalAuthor[] DO
CREATE LASTCHILD OF OutputRoot.SOAP.Body.ns:submitJournal.ns:journalAuthorValues
TYPE NAMEVALUE
IDENTITY ns16:AuthorName
VALUE FIELDVALUE(refAuthor);
END FOR
You should try to avoid using counted loops in ESQL. A FOR statement or a SELECT statement is almost always simpler and better.
I am a fairly new web developer and would need your help with a project I am currently working on. I have worked in the past on a very simple realtime database example and have little to none experience in firestore or NoSql in general.
I want to create a system which allows end-users to get an email once a week that contains a list of special offers from bars the end-user has subscribed to. The offers change each day of the week. Bar owners can fill out a form in a vue.js web application every week with their weekly special offers.
Every Monday morning a cron job has to look up which end user has subscribed to which bars and then aggregate the data and send it via email.
The question is how would you structure the data so that I can easily compose the email and send it via a cloud function?
My approach would be to have three main collections: RestaurantOwner, EndUser, SpecialOfferings
Please see the graphic for an example process:
BarOwner and EndUser are pretty straight forward. However, the difficult part is how to structure the SpecialOffers in order to be queried the right way.
My idea would be to structure it based on the calendar week and link it to the uid from the barOwner:
specialOffers: {
2019_CW27: {
barUID001: {
mon: {
title: 'Banana Daiquir',
price: 4.99,
},
tue: {
title: 'After Five',
price: 2.99,
},
wed: {
title: 'Cool Colada',
price: 6.99
},
thu: {
title: 'Crantini',
price: 5.99
},
fri: {
title: 'French Martini',
price: 4.99
}
},
barUID002: {
mon: {
title: 'Gin & Tonic',
price: 8.99,
},
tue: {
title: 'Cratini',
price: 4.99,
},
wed: {
title: 'French Martini',
price: 4.99
},
thu: {
title: 'After Five',
price: 3.99
},
fri: {
title: 'Cool Colada',
price: 6.99
}
}
},
2019_CW28: {
barUID01: {~~~},
barUID02: {~~~}
}
}
The disadvantage of this approach is that it creates a deeply nested object when you imagine that there are 52 calendar weeks, f.e 100 signed up bars à 5 special offers per week and I am not sure if I am able to query it the way I need to.
Is this approach reasonable or what would you do differently?
Thank you so much for your help! I highly appreciate it.
I'm assuming the following scenarios:
1) The bar owners make modifications to their offers very often.
2) The bar owners should be the only ones allowed to modify each bar's offers.
If you have these two scenarios, I would recommend a sub-collections approach here.
When to use sub-collections:
1) When there are lot of fields in a document. Cloud Firestore has 20,000 field limit. (If the number of Bars can exceed more than 20,000 fields)
2) When updating the parent collection is a common operation. Firestore only lets you update the document at rate of 1 write/second. (If the SpecialOffers information of each bar is modified very often. If two bar owners modify their offers, only 1 write is successful and the second write operation waits until the first is completed. This can delay the updation offers particularly at the end of a week when almost all the bars update the offers.)
3) When you want to limit the access to particular fields of a document. (If you want to restrict the access to a Bar's Offers to the barOwner alone. You can restrict the access to each document in the Bars sub-collection according to its owner using Firestore Security Rules)
So I would recommend a sub-collection Bars under the main collection SpecialOffers. This way the design becomes scalable and you can add restaurants and super-markets as other similar sub-collections in the future without heavily altering your design.
Another advantage is that sub-collections are basically collections and they don't have a limit for number of documents it can hold. So even if the number of bars registered is above 20,000 which is the limit of number of fields for a fire-store document, your sub-collection wont be having a problem but your document will run out of fields to save the offers for a new bar.
Ultimately the choice depends on your use cases.
Hope this helps.
I'm new to alexa. I learnt and started to build a weather app.
right now I'm able to get weather data, but on the below condition,
I've craeated a custom slot(LIST_OF_CITIES) to hold Cities as below.
{
"intents": [
{
"intent": "WeatherIntent",
"slots": [
{
"name": "city",
"type": "LIST_OF_CITIES"
}
]
},
{
"intent": "AMAZON.HelpIntent"
},
]
}
and in my custom slot I gave as below.
Type Values
LIST_OF_CITIES Hyderabad | pune | london
and below are my Utterances
WeatherIntent give me {city} climate
WeatherIntent {city}
WeatherIntent what's the climate in {city}
WeatherIntent what's the weather in {city}
WeatherIntent {city}
when I run my program using any of the three cities mentioned in the above table, I'm able to get the correct. If I use anything apart from the above, it is sending back value as -4.
If I want to get tempreature of some other city, I need to add that city in the slot list.
Please let me know how can I get the vaues dynamically, I mean with out depending on the LIST_OF_CITIES, If I enter a city name, it should send back the result.
Also I tried adding type as LITERAL and also as AMAZON.LITERAL. When I saved it, I get the exception as
Error: There was a problem with your request: Unknown slot name '{city}'. Occurred in sample 'WeatherIntent get me weather of {city}' on line 1.
Please let me know where am I going wrong and how can I fix this.
Thanks
Amazon provides some default list Slot Types for cities or even regions. E.g.
AMAZON.US_CITY
AMAZON.AT_CITY
AMAZON.DE_REGION
...
You can use these as type when defining your custom slot.
First, don't use LITERAL - it is deprecated and isn't even supported at all outside US region.
And no, you can't manage the list of words dynamically.
Alexa will try to match what the user says with your LIST_OF_CITIES, and will try to return one of those words, but might return something else if it can't match one of those (as you have seen).
There are some custom slot types for cities that you can use and build off of, see here:
https://developer.amazon.com/public/solutions/alexa/alexa-skills-kit/docs/alexa-skills-kit-interaction-model-reference#h2_custom_syntax
But that probably won't work for you since each of them is just one country, so you will need to build your own list of cities (in your LIST_OF_CITIES).