trade29.sc.SCBridge.get_tpo_profile#

SCBridge.get_tpo_profile(key: str, study_id: int, number_historical_profiles: int = -1, include_profile: bool = False, include_peak_valley: bool = False) TPOProfileResponse#

Gets historical TPO profiles from the TPO Profile Chart study.

For this method to work, the Sierra Chart ‘TPO Profile Chart’ study needs to be added to the chart.

Parameters:
keystr

A string key that matches the key given to the target Study in SierraChart.

study_idint

ID of the TPO study.

number_historical_profilesint, default -1

Number of historical profiles to fetch. If this is -1 then all available profiles will be returned.

include_profilebool, default False

Whether or not to include detailed profile data (the histogram that is seen in Sierra Chart)

include_peak_valleybool, default False

Whether or not to include peak valley data. ‘Draw Peaks & Valleys needs to be enabled in study settings. Peaks are 1 and valleys are 2.

Returns:
TPOProfileResponse

Examples

>>> from trade29.sc import SCBridge
>>> bridge = SCBridge()
running bridge v0.17.0--------2024/08/06 19:45:48
connecting to sc
starting receiver
starting sender
sc version: 2666, scdx version 208, connection: t29scdx2, keys: xx,signal
>>> ret = bridge.get_tpo_profile(key="xx", study_id=2, number_historical_profiles=-1)
>>> df = ret.as_df()
>>> # by default the request does not include detailed TPO profile data.
>>> df
   StartDateTime  NumberOfTrades   Volume  ...  VolumeAboveTPOPOC  VolumeBelowTPOPOC         EndDateTime  BeginIndex  EndIndex
0     2024-08-06          664365   664365  ...             165638             498727 2024-08-06 20:00:00           0         8
1     2024-08-05         1000208  1000208  ...             527539             472669 2024-08-06 00:00:00           0         6
2     2024-08-04           29501    29501  ...              13003              16498 2024-08-05 00:00:00           0         2
3     2024-08-02          778346   778346  ...             221357             556989 2024-08-02 21:00:00           0         8
4     2024-08-01          646856   646856  ...             307707             339149 2024-08-02 00:00:00           0        10
5     2024-07-31          555678   555678  ...             283767             271911 2024-08-01 00:00:00           0         9
6     2024-07-30          423686   423686  ...             238377             185309 2024-07-31 00:00:00           0         8
7     2024-07-29          419518   419518  ...             159118             260400 2024-07-30 00:00:00           0         9
8     2024-07-28           16866    16866  ...              12276               4590 2024-07-29 00:00:00           0         2
9     2024-07-26          403039   403039  ...             272167             130872 2024-07-26 21:00:00           0         8
10    2024-07-25          623056   623056  ...             191987             431069 2024-07-26 00:00:00           0        10
11    2024-07-24          414961   414961  ...             231451             183510 2024-07-25 00:00:00           0         8
12    2024-07-23          340772   340772  ...              80212             260560 2024-07-24 00:00:00           0         9
13    2024-07-22          370142   370142  ...             120236             249906 2024-07-23 00:00:00           0         6
14    2024-07-21           12146    12146  ...               8181               3965 2024-07-22 00:00:00           0         2
15    2024-07-19          483542   483542  ...             406690              76852 2024-07-19 21:00:00           0         6
16    2024-07-18          432474   432474  ...             156922             275552 2024-07-19 00:00:00           0         9
>>> # we can request detailed data + peak/valley data (make sure 'Draw Peaks & Valleys' is checked in the TPO study settings)
>>> ret = bridge.get_tpo_profile(key="xx", study_id=2, number_historical_profiles=-1, include_peak_valley=True, include_profile=True)
>>> df = ret.as_df()   
>>> df
   StartDateTime  ...                                        PeakValleys                                    TPO/VbP Profile
0     2024-08-06  ...      PeakValleyLinePrice  PeakValleyType  Start...             Price  AskVol  BidVol  TotalVolume ...     
1     2024-08-05  ...      PeakValleyLinePrice  PeakValleyType  Start...             Price  AskVol  BidVol  TotalVolume ...     
2     2024-08-04  ...     PeakValleyLinePrice  PeakValleyType  StartI...            Price  AskVol  BidVol  TotalVolume  ...     
3     2024-08-02  ...      PeakValleyLinePrice  PeakValleyType  Start...             Price  AskVol  BidVol  TotalVolume ...     
4     2024-08-01  ...      PeakValleyLinePrice  PeakValleyType  Start...             Price  AskVol  BidVol  TotalVolume ...     
5     2024-07-31  ...      PeakValleyLinePrice  PeakValleyType  Start...             Price  AskVol  BidVol  TotalVolume ...     
6     2024-07-30  ...      PeakValleyLinePrice  PeakValleyType  Start...             Price  AskVol  BidVol  TotalVolume ...     
7     2024-07-29  ...      PeakValleyLinePrice  PeakValleyType  Start...             Price  AskVol  BidVol  TotalVolume ...     
8     2024-07-28  ...     PeakValleyLinePrice  PeakValleyType  StartI...             Price  AskVol  BidVol  TotalVolume ...     
9     2024-07-26  ...      PeakValleyLinePrice  PeakValleyType  Start...             Price  AskVol  BidVol  TotalVolume ...     
10    2024-07-25  ...      PeakValleyLinePrice  PeakValleyType  Start...             Price  AskVol  BidVol  TotalVolume ...     
11    2024-07-24  ...      PeakValleyLinePrice  PeakValleyType  Start...             Price  AskVol  BidVol  TotalVolume ...     
12    2024-07-23  ...      PeakValleyLinePrice  PeakValleyType  Start...             Price  AskVol  BidVol  TotalVolume ...     
13    2024-07-22  ...      PeakValleyLinePrice  PeakValleyType  Start...             Price  AskVol  BidVol  TotalVolume ...     
14    2024-07-21  ...     PeakValleyLinePrice  PeakValleyType  StartI...             Price  AskVol  BidVol  TotalVolume ...     
15    2024-07-19  ...      PeakValleyLinePrice  PeakValleyType  Start...             Price  AskVol  BidVol  TotalVolume ...     
16    2024-07-18  ...      PeakValleyLinePrice  PeakValleyType  Start...             Price  AskVol  BidVol  TotalVolume ...
>>> # the peak valley/TPO profiles are their own dataframes, lets get the latest ones:
>>> df["PeakValleys"][0]
    PeakValleyLinePrice  PeakValleyType  StartIndex  PeakValleyExtensionChartColumnEndIndex
0           2443.699951               2           0                                     233
1           2444.400146               1           0                                     233
2           2450.800049               2           0                                     233
3           2451.699951               2           0                                     258
4           2453.000000               1           0                                     258
5           2455.800049               2           0                                     258
6           2456.400146               1           0                                     258
7           2457.400146               2           0                                     258
8           2459.400146               2           0                                     258
9           2461.699951               2           0                                     258
10          2463.400146               2           0                                     286
11          2464.600098               2           0                                     286
12          2466.100098               1           0                                     286
13          2470.800049               2           0                                     286
14          2472.199951               1           0                                     286
15          2473.600098               1           0                                     286
>>> df["TPO/VbP Profile"][0] 
           Price  AskVol  BidVol  TotalVolume  TPOCount
368  2418.400146       5       3            8         1
367  2418.300049      23      16           39         1
366  2418.199951      27      33           60         1
365  2418.100098      69      59          128         1
364  2418.000000      76      82          158         1
..           ...     ...     ...          ...       ...
..           ...     ...     ...          ...       ...
4    2382.000000     134     168          302         2
3    2381.900146      63      84          147         2
2    2381.800049       7      12           19         2
1    2381.699951       4       3            7         1
0    2381.600098       0       1            1         1

[369 rows x 5 columns]