Exchange rate seems to be inconsistent. Some currency are do not show up, but are supported in some leve - coinbase-api

Look at: https://developers.coinbase.com/api/v2#get-currencies
it states clearly "it can be defined as any supported currency". When I query the support currency DKK does not show up... but you can use DKK to get exchange-rate? Also the coinbase website shows my values in DKK.
So, what gives?!?! This is just confusing. I create a list with the support currency, but cannot choose DKK because it does not come in the query?!?!
anyone?

If you query all currencies, DKK is there:
GET https://api.coinbase.com/v2/currencies
RESPONSE {"data":[ ... ,{"id":"DKK","name":"Danish Krone","min_size":"0.01000000"}, ... ]}
You can also query just DKK to compare it with other currencies:
GET https://api.coinbase.com/v2/exchange-rates?currency=DKK
RESPONSE {"data":{"currency":"DKK","rates":{"AED":"0.54780095459776946093168", ... }}}

Related

Query based on multiple filters in Firebase

I am working out the structure for a JSON database for an app like onlyFans. Basically, someone can create a club, then inside of that club, there are sections where the creator's posts are shown and another where the club members posts are shown. There is however a filter option where both can be seen.
In order to make option 1 below work, I need to be able to filter based on if isFromCreator=true and at the same time based on timstamp. How can I do this?
Here are the 2 I have written down:
ClubContent
CreatorID
clubID
postID: {isFromCreator: Bool}
OR
creatorPosts
postID: {}
MemeberPosts
postID: {}
Something like the below would be what I want:
ref.child("Content").child("jhTFin5npXeOv2fdwHBrTxTdWIi2").child("1622325513718")
.queryOrdered(byChild: "timestamp")
.queryLimited(toLast: 10)
.queryEqual(toValue: true, childKey: "isFromCreator")
I triedqueryEqual yet it did not return any of the values I know exist with the configuration I specified.
You can use additional resource locations within rules by referencing the parent/child directories specifically and comparing the val() of the respective node structure.
for example:
".write": "data.parent().child('postID').child('isFromCreator').val()"
Just be aware that Security Rules do not filter or process the data in the request, only allow or deny the requested operation.
You can read more about this from the relevant documentation:
https://firebase.google.com/docs/database/security/rules-conditions#referencing_data_in_other_paths
https://firebase.google.com/docs/database/security/core-syntax#rules-not-filters

How to set a Take-Profit limit order with Binance

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.

Microsoft Graph Member of limit

Microsoft Graph API is not returning more than 100 object
I tried below query to get "memberof" details of a particular user. However it return only first 100 objects. However User is member of 210 groups. Could you please help me with correct query
https://graph.microsoft.com/v1.0/users/mytestuser#domain.com/memberOf
GET https://graph.microsoft.com/v1.0/users/mytestuser#domain.com/memberOf
The response should contain a "#odata.nextLink" field which can be used to retrieve the next page of the result. An example response could be:
{
"#odata.context": "https://graph.microsoft.com/v1.0/$metadata#directoryObjects",
"#odata.nextLink": "https://graph.microsoft.com/v1.0/users/mytestuser#domain.com/memberOf?$top=5&$skiptoken=X%2744537074090001000000000000000014000000B2B64E48AF94EB439F56F5A33CB75C9301000000000000000000000000000017312E322E3834302E3131333535362E312E342E32333331020000000000011C7FEE5EFEFA46459248691C529273D3%27",
"value": [
{ ... }
...
]
}
To retrieve all results we should keep following "#odata.nextLink" of each responses until the response does not contain a "#odata.nextLink" field.
Please have a look at this doc explaining how paging works in Microsoft Graph: https://learn.microsoft.com/graph/paging
It works the same with the /memberOf API
You can use query parameters to customize responses - like so for example get the top 300 - this will return til 300 groups etc
https://graph.microsoft.com/v1.0/users/mytestuser#domain.com/memberOf?$top=300
This is a quick and dirty way, since the memberOf method does not support all OData Query Parameters
https://learn.microsoft.com/en-us/graph/query-parameters

How can I make a multiple options query with mongodb driver for nodejs?

I'm working in a MongoDB query with Nodejs and I have a problem that I can't resolve.
Let us supposed we have a lot of documents in Mongo and each document have a tags array
tags: [tag1, tag2, tag3]
Front-end are going to send the parameters and we want to make a query with those... How can I find every document inside Mongo with those tags. The tags can be differents, not all documents have the same tags but I want to pull each document that have almost one of those tags. I don't know if I make myself clear with this but I hope you'll help me.
PD: If the query works, we have more than 13 that I can apply so it needs to be something like dynamically query o something.
Regards
This is where the mongodb's aggregate function comes in play
lets say there is a database called books and we want to get books that contain lets say ['fantasy', 'sci-fi'] in its genres
db.book.aggregate([{
$match:{
genres:{
$in:['fantasy', 'sci-fi']
}
}
}])
this will get the result you want, finding all the books that contain either fantasy, or scifi
db.book.aggregate([{
$match:{
genres:{
$all:['fantasy', 'sci-fi']
}
}
}])
This will get all the books that have genres with both fantasy and sf
db.book.aggregate([{
$match:{
genres:{
$nin:['fantasy', 'sci-fi']
}
}
}])
This will fetch all the books that don't have these values
generate an $or condition in your code according to the parameters:
let or_array = [];
params.forEach(params, (tag_param) => {
or_array.push({tags: tag_param})
});
let or_cond = {$or: or_array};
now we just need a simple find query to retrieve the documents:
let results = model.find(or_cond);
results should contain the wanted documents.
** note that $or requires a none empty array so you should validate at least one parameter is received from the client side.

giving a string slot in Amazon alexa

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).

Resources