CFDs are complex instruments and come with a high risk of losing money rapidly due to leverage. 66 % of retail investor accounts lose money when trading CFDs with this provider. You should consider whether you understand how CFDs work and whether you can afford to take the high risk of losing your money.

{First Steps} Plotting DARWIN Quote History

Using Python and Pandas to wrap the REST API.

7 Likes

Cool!

Could you share with us how are you managing the download and plotting part? That would great!

1 Like

Hi @mireigon,

One simple approach to achieving this is:

Step 1) For each DARWIN in your list, call /darwininfo/1.0/products/{insert-darwin-ticker-here}/history/quotes to retrieve JSON output of [timestamp, quote] tuples.

e.g. /darwininfo/1.0/products/ONE/history/quotes

Step 2) Concatenate all DARWIN JSON outputs retrieved in this manner into a single DataFrame and run a forward-fill to pad any missing values.

Step 3) Assuming your final DataFrame is called ‘df’, run df.plot()

You can extend this sequence to create equally weighted and/or optimised DARWIN portfolio series as well.

5 Likes

Hi @mireigon.

The process would be the one described by @integracore2 . I have defined a function to make it more comfortable.

Just a couple of points:

  • Quotes of each Darwin are stored in a Pandas Serie, and later they are joined in a DataFrame, which returns the function.

  • Timestamps returned by the REST API are in milliseconds and must be converted to datetime.

3 Likes

Once you have the quotes in a DataFrame, you can analyze it as better for you.

For example, it’s possible to make a correlation matrix with the returns of Darwins with more investors.

4 Likes

Interesting!

Just for the record, I found that converting to UTC (such as in Darwinex website) is pretty straight-forward in Python.

from datetime import datetime
ts_to_utc = datetime.utcfromtimestamp  # I write this on the top of the Python file to use it on the rest of functions  
data["date"] = (data["date"]/1000).apply(ts_to_utc)  # replace "date" for any other Date column name
1 Like

Even more simple with Pandas.

data['date'] = pandas.to_datetime(data['date'], unit='ms')

3 Likes

This way you can store the badges, for example, in a DataFrame pandas with the date as index.

3 Likes

The possibilities are literally endless… this is just one little UI build test.

The DARWIN API enables anyone using it to build an entire DARWIN trading platform if they so wish…

Will keep this thread updated with more tests as they come :slight_smile:

This screenshot featuring @CavaliereVerde :thumbsup:

Language: Python
Library: Plotly

10 Likes

NTI brought to life with a few Technicals.

Data source: DARWIN API :satellite:
Language: Python :snake:
Charting: Plotly :chart_with_upwards_trend:

Alpha generator:
The grand master himself, @KlondikeFX :muscle:

Guys, quick request:

The amazing development teams at Darwinex have worked immensely hard on the API (and continue to do so).

Please share the contents of this post and others in DARWIN API forum categories as you see fit on your social channels etc, to get as many eyeballs witnessing the trader-talent driven revolution we’re trying to bring about here :muscle:

If you have friends, colleagues etc who would be interested in becoming Beta Testers, send them to this link:

The more interest and feedback we get, the more we can evolve and improve, get more ideas to the table, more novel creations from people “trading” traders, and more - thank you! :pray:

5 Likes

Question from non non-python non-rest guy:
Does the API provide also scores?
What are the data available for every darwin?

1 Like

Yes, it does. The API has several methods to return information about scores and much more.
https://api.darwinex.com/store/ --> DarwinInfoAPI --> API Console

1 Like

I think that giving read-only access to this API category could help to spread the idea, so that everyone can read but only testers can write.

3 Likes

Python Wrap of API REST to data.
Plot whith only Matplotlib.

Evolution of some Darwins by months.

9 Likes

Gangster visuals @paduel, awesome :slight_smile: :clap:

One of the most thought-through uses of matlplotlib animation I’ve seen in a long time!

Would you mind if we shared this on our social channels under beta test progress?

Keep at it, thank you! :pray:

2 Likes

Thanks, I’m glad you liked it.

I updated the animation, the legend colors was wrong.

Yes, you can share it. I posted it on my twitter account @Paduel_py.

4 Likes

Hi!

Just inspired by your talent, I tried creating a basic terminal so I can further study and use the API in some other ways.

Basically is Dash platform taking information from a Darwin class object that I have created for backtest purposes.

5 Likes