0

Here is the code of Python:

import trendln
import yfinance as yf # requires yfinance - pip install yfinance
tick = yf.Ticker('^GSPC') # S&P500
hist = tick.history(period="max", rounding=True)
h = hist[-1000:].Close
mins, maxs = trendln.calc_support_resistance(h)

Here,

type(tick)
<class 'yfinance.ticker.Ticker'>
type(hist)
<class 'pandas.core.frame.DataFrame'>
type(h)
<class 'pandas.core.series.Series'>
type(mins) and type(maxs)
<class 'tuple'>

I have tried this:

using (Py.GIL())
{
    dynamic tick = yf.Ticker("^GSPC");
    dynamic hist = tick.history("max",true);
}

But I do not understand how I can handle the data the same way in Python.

To be Specific, How I can handle the dataframe and Tuples which in the style like this h = hist[-1000:].Close and mins/maxs in C#.

Please suggest me the easiest way to do that.

Jaffer Wilson
  • 7,029
  • 10
  • 62
  • 139
  • C# 7 has Tuple type maybe it will help. Other than that have a look at `PyTuple.IsTupleType(pyresult)` part here: https://mail.python.org/pipermail/pythondotnet/2003-November/000037.html – tozlu Nov 25 '20 at 09:03
  • @1.44mb Okay I will take a look at it but what about the DataFrame? – Jaffer Wilson Nov 25 '20 at 09:11
  • You can check `Deedle` for DataFrame https://github.com/fslaborg/Deedle. There is also `Microsoft.Data.Analysis` package https://devblogs.microsoft.com/dotnet/an-introduction-to-dataframe/. Obviously you should parse `dynamic` `hist` object using one of these libraries. – tozlu Nov 25 '20 at 09:49
  • @1.44mb I have tried installing the `Microsoft.Data.Analysis` but I am getting error saying `Package 'System.Diagnostics.DiagnosticSource.4.3.0' does not exist in project 'testapplication'`. I have tried installing `System.Diagnostics.DiagnosticSource.4.3.0` package too. But it is also not getting installed. Hence, I dropped the idea and put a query here to find a way out. I have not tried Deedle. I will give it a try. – Jaffer Wilson Nov 25 '20 at 09:56

0 Answers0