Giter Club home page Giter Club logo

Comments (5)

tttdevelop avatar tttdevelop commented on July 18, 2024

Hi Kalypox, I already did it by putting in the quote tag. In your case it is EURJPY=X in the "sigle" and whatever name you want in "nom". Just use the part in the brackets from yahoo finance including the =X section. Like EUR/USD (EURUSD=X), you use EURUSD=X.

Only problem I'm dealing with is the quantitie has to be an integer. But this is not realistic when doing FX. Any ideas ?

from suivi-bourse.

jonathan-gatard avatar jonathan-gatard commented on July 18, 2024

Hi,
I'm working on it to transform all values in euro (or other) in your program. I'm learning python/influxdb/yfinance

from suivi-bourse.

jonathan-gatard avatar jonathan-gatard commented on July 18, 2024

I added 2 functions :


def getLastValue(ticker):
    ticker = yf.Ticker(ticker)
    history = ticker.history(interval="30m")
    return history.tail(1)['Close'].iloc[0]
     
def toEur(cours,symbole):
    if symbole != "EUR":
        return cours / getLastValue("EUR" + symbole + "=X")
    else:
        return cours
    
def run():
    try:
        with open('data.json') as json_file:
            json_loaded = json.load(json_file)
            for info in json_loaded:                   
                value = getLastValue(info['ticker'])           
                json_body = [{
                    "measurement": "bourse",
                    "tags": {
                        "nom": info['nom']
                    },
                    "fields": {
                        "value_origine": value,
                        "value": toEur(value,info['symbole']),
                        "qte": info['qte'],
                        "pru": info['pru']
                    }
                }]
                influxdbClient = InfluxDBClient(
                    host="192.168.1.2",
                    port="8086",
                    database="portfolio",
                    username="uuuu",
                    password="XXXXXXXXXX")
                influxdbClient.write_points(json_body)
                influxdbClient.close()
    except Exception as e:
        print(e)

And symbol in data.json
I made a lot of modifications on

from suivi-bourse.

tttdevelop avatar tttdevelop commented on July 18, 2024

Nice. Will try it out later.

To answer my previous question on the integer and real values, I find out that this it automatically assigned by InfluxDB when you first create the measurement. So if you put 0 or 1, it will assume it is an integer value and assign all values must be integers. To make it automatically assume a real number, then just put 0.0 or 1.0 and then you will have a real value assignment and you won't get errors when you put in 2.3 or other non whole number.

from suivi-bourse.

pbrissaud avatar pbrissaud commented on July 18, 2024

Hi,

In release 2.0, the app forces float casting for number to avoid this kind of issue (cf 27f956b)

from suivi-bourse.

Related Issues (17)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.