pine script first trade cum. profit unreliable? BTCUSD 1 dollar initial investment - cryptography

I made a pine script for tradingview that uses initial capital of 1 usd and an order size of 0.5 usd for trading BTCUSD. But for some reason the strategy tester list of trades, shows that the first trade has 88k% cum profit.
This makes absolutely no sense to me, as the specific trade entry is 10k and the exit is 11k as shown in the image
enter image description here
Also, the strategy never shorts, yet one some datasets/time frames, it ends up with a portfolio of negative thousands of dollars. how can it lose more than 100% of portfolio without ever shorting? It seems to me these numbers are not trustworthy.
For strategy input, i use
strategy("BTC9%lines", overlay=false, shorttitle = "FIBBTC redist", default_qty_type = strategy.cash, default_qty_value=0.5, commission_value = 0.01, initial_capital = 1, currency=currency.USD, calc_on_order_fills=false)

i found out the solution to the problem. yet i dont know how to delete my post, however perhaps people can benefit from me answering my own question
The problem was that i had a
qty
in my
strategy.entry
which overwrote my strategy default values.
why it was able to enter a trade with half of 1 btc at 10k usd with only 1 usd capital is still confusing.
Anyway i solved it by dividing the qty i set in strategy.entry with close
var qtyvaluelower=initialCapital*0.55
var qtyvaluehigher=initialCapital*0.45
if linecross and different and lowerthanlast
strategy.close_all(comment="lc")
strategy.entry("lower", strategy.long, qty=qtyvaluelower, comment="buy more")
if linecross and different and higherthanlast
strategy.close_all(comment="hc")
strategy.entry("higher", strategy.long, qty=qtyvaluehigher, comment="buy less")
changed to
var qtyvaluelower=initialCapital*0.55/close
var qtyvaluehigher=initialCapital*0.45/close
if linecross and different and lowerthanlast
strategy.close_all(comment="lc")
strategy.entry("lower", strategy.long, qty=qtyvaluelower, comment="buy more")
if linecross and different and higherthanlast
strategy.close_all(comment="hc")
strategy.entry("higher", strategy.long, qty=qtyvaluehigher, comment="buy less")

Related

Sentinel 1 data gaps in swath overlap (not sequential scenes) in Google Earth Engine

I am working on a project using the Sentinel 1 GRD product in Google Earth Engine and I have found a couple examples of missing data, apparently in swath overlaps in the descending orbit. This is not the issue discussed here and explained on the GEE developers forum. It is a much larger gap and does not appear to be the product of the terrain correction as explained for that other issue.
This gap seems to persist regardless of year changes in the date range or polarization. The gap is resolved by changing the orbit filter param from 'DESCENDING' to 'ASCENDING', presumably because of the different swaths or by increasing the date range. I get that increasing the date range increases revisits and thus coverage but is this then just a byproduct of the orbital geometry? ie it takes more than the standard temporal repeat to image that area? I am just trying to understand where this data gap is coming from.
Code example:
var geometry = ee.Geometry.Polygon(
[[[-123.79472413785096, 46.20720039434629],
[-123.79472413785096, 42.40398120362418],
[-117.19194093472596, 42.40398120362418],
[-117.19194093472596, 46.20720039434629]]], null, false)
var filtered = ee.ImageCollection('COPERNICUS/S1_GRD').filterDate('2019-01-01','2019-04-30')
.filterBounds(geometry)
.filter(ee.Filter.eq('orbitProperties_pass', 'DESCENDING'))
.filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VH'))
.filter(ee.Filter.listContains('transmitterReceiverPolarisation', 'VV'))
.filter(ee.Filter.eq('instrumentMode', 'IW'))
.select(["VV","VH"])
print(filtered)
var filtered_mean = filtered.mean()
print(filtered_mean)
Map.addLayer(filtered_mean.select('VH'),{min:-25,max:1},'filtered')
You can view an example here: https://code.earthengine.google.com/26556660c352fb25b98ac80667298959

Guess if a user will make or not a conversion

My friends,
In the past couple of years I read a lot about AI with JS and some libraries like TensorFlow. I have great interest in the subject but never used it on a serious project. However, after struggling a lot with linear regression to solve an optimization problem I have, I think that finally I will get much better results, with greater performance, using AI. I work for 12 years with web development and lots of server side, but never worked with any AI library, so please, have a little patience with me if I say something stupid!
My problem is this: every user that visits our platform (website) we save the Hour, Day of the week, if the device requesting the page was a smartphone or computer... and such of the FIRST access the user made. If the user keeps visiting other pages, we dont care, we only save the data of the FIRST visit. And if the user anytime does something that we consider a conversion, we assign that conversion to the record of the first access that user made. So we have almost 3 millions of lines like this:
SESSION HOUR DAY_WEEK DEVICE CONVERSION
9847 7 MONDAY SMARTPHONE NO
2233 13 TUESDAY COMPUTER YES
5543 19 SUNDAY COMPUTER YES
3721 8 FRIDAY SMARTPHONE NO
1849 12 SUNDAY COMPUTER NO
6382 0 MONDAY SMARTPHONE YES
What I would like to do is this: next time a user visits our platform, we wanna know the probability of that user making a conversion. If a user access now, our website, depending on their device, day of week, hour... we wanna know the probability of that user making a future conversion. With that, we can show very specific messages to the user while he is using our platform and a different price model according to that probability.
CURRENTLY we are using a liner regression, and it predicts if the user will make a conversion with an accuracy of around 30%. It's pretty low but so far, it's the best we got it, and this linear regression generates almost 18% increase in conversions when we use it to show specific messages/prices to that specific user compaired to when we dont use it. SO, with a 30% accuracy our linear regression already provides 18% better conversions (and with that, higher revenues and so on).
In case you are curious, our linear regression model works like this: we generate a linear equation to every first user access on our system with variables that our system tries to find in order to minimize error sqr(expected value - value). Using the data above, our model would generate these equations below (SUNDAY = 0, MONDAY = 1...COMPUTER = 0, SMARTPHONE = 1... CONVERSION YES = 1 and NO = 0)
A*7 + B*1 + C*1 = 0
A*13 + B*2 + C*0 = 1
A*19 + B*0 + C*0 = 1
A*8 + B*6 + C*1 = 0
A*12 + B*0 + C*1 = 0
A*0 + B*1 + C*0 = 1
So, our system find the best A, B and C that generates the minimizes error. How can we do that with AI? If possible, it would be nice if we could use TensorFlow or anything with JS! I know there are several AI models, and I have no idea which one would best fit what we need!

Matching an element in a column, to others in the same column

I have columns taken from excel as a dataframe, the columns are as follows:
HolidayTourProvider|Packages|Meals|Accommodation|LocalTravelVehicle|Cancellationfee
Holiday Tour Provider has a couple of company names
Packages, the features provided in each package are mostly the same like
Meals,Accommodation etc... even though one company may call it "Saver", others may call it "Budget". (each of column mostly follow Yes/No, except Local travel vehicle are again car names like Ford Taurus,jeep cherokee etc..
Cancellation amount is integers)
I need to write a function like
match(HolidayTP,Package)
where the user can give input like
match(AdventureLife, Luxury)
then I need to return all the packages that have similar features with Luxury by other Holiday Tour Providers, no matter what name they give the package like 'Semi Lux', 'Comfort' etc...
I want to give a counter for every match and display all the packages that exceed the counter by 3 or 4.
This is my first python code. I am stuck here.
fb is the total df I exported to
def mapHol(HTP, PACKAGE):
mfb = (fb['HTP']== HTP)&(fb['package']== package)
B = fb[mfb]
for i in fb[i]:
for j in B[j]:
if fb[i]==B[j]:
count+=1
I dont know how to proceed, please help me this is my first major project, I started on my own.

Unequally spaced vehicles in a flow: SUMO

I have needed an equally spaced vehicle flow. As per the documentation , vehicles should be equally spaced unless someone randomizes the flow. I didn't randomize the flow, but I am experiencing that the vehicles do not have the same headway.
Here is my rou.xml file entry, and I set sigma = 0 as well.
<flow id = "f1" color="1,1,1" begin = "0" type="Car" vehsPerHour="1500" number="100" route="route0" departSpeed="13.9"> </flow>
I am seeing majority of the vehicles have a headway around 27m and some other vehicles around 40m. There is a pattern. The first 2 vehicles of every 5 vehicles travel together (with 27m heading), and other other 3 travel together (with 27m heading) but with 40m gap between 3rd and the 2nd (e.g. V represents a vehicle VVV*****VV*****VVV*****VV****VVV*****V**V)
I tried this as well.
<flow id = "f1" color="1,1,1" begin = "0" type="Car" period="2.4" number="100" route="route0" departSpeed="13.9"> </flow>
But it is the same as the previous.
Is there a workaround for this?
Thanks!
It is a discretization error. Assuming you run with the default step length of one second the vehicles will be emitted at whole seconds only. To avoid this use only multiples of the step length as period (so either using a period of 2 or 3 or reducing the step length to 0.2 should help in your example). There is also a ticket concerning this topic: https://github.com/eclipse/sumo/issues/4277.

options for questions in Watson conversation api

I need to get the available options for a certain question in Watson conversation api?
For example I have a conversation app and in some cases Y need to give the users a list to select an option from it.
So I am searching for a way to get the available reply options for a certain question.
I can't answer to the NPM part, but you can get a list of the top 10 possible answers by setting alternate_intents to true. For example.
{
"context":{
"conversation_id":"cbbea7b5-6971-4437-99e0-a82927607079",
"system":{
"dialog_stack":["root"
],
"dialog_turn_counter":1,
"dialog_request_counter":1
}
},
"alternate_intents":true,
"input":{
"text":"Is it hot outside?"
}
}
This will return at most the top ten answers. If there is a limited number of intents it will only show them.
Part of your JSON response will have something like this:
"intents":[{
"intent":"temperature",
"confidence":0.9822100598134365
},
{
"intent":"conditions",
"confidence":0.017789940186563623
}
This won't get you the output text though from the node. So you will need to have your answer store elsewhere to cross reference.
Also be aware that just because it is in the list, doesn't mean it's a valid answer to give the end user. The confidence level needs to be taken into account.
The confidence level also does not work like a normal confidence. You need to determine your upper and lower bounds. I detail this briefly here.
Unlike earlier versions of WEA, the confidence is relative to the
number of intents you have. So the quickest way to find the lowest
confidence is to send a really ambiguous word.
These are the results I get for determining temperature or conditions.
treehouse = conditions / 0.5940327076534431
goldfish = conditions / 0.5940327076534431
music = conditions / 0.5940327076534431
See a pattern?🙂 So the low confidence level I will set at 0.6. Next
is to determine the higher confidence range. You can do this by mixing
intents within the same question text. It may take a few goes to get a
reasonable result.
These are results from trying this (C = Conditions, T = Temperature).
hot rain = T/0.7710267712183176, C/0.22897322878168241
windy desert = C/0.8597747113239446, T/0.14022528867605547
ice wind = C/0.5940327076534431, T/0.405967292346557
I purposely left out high confidence ones. In this I am going to go
with 0.8 as the high confidence level.