boosted.api.api
1# Copyright (C) 2020 Gradient Boosted Investments, Inc. - All Rights Reserved 2 3import datetime 4import logging 5from datetime import timedelta 6from typing import Any, Dict, List, Literal, Optional, Union 7 8import pandas as pd 9from boosted.api.api_client import BoostedClient, convert_date 10from boosted.api.api_type import ( 11 BoostedDate, 12 DataAddType, 13 DataSetFrequency, 14 DataSetSubType, 15 DataSetType, 16 GbiIdSecurity, 17 HedgeExperiment, 18 HedgeExperimentDetails, 19 HedgeExperimentScenario, 20 PortfolioSettings, 21 hedge_experiment_type, 22) 23from boosted.api.api_util import infer_dataset_schema 24 25logger = logging.getLogger("boosted.api") 26logging.basicConfig() 27 28 29def inferDependentDataSetSchema(name, df, infer_from_column_names=False): 30 """ 31 Creates a dependent dataset schema by inferring the contents from a Pandas DataFrame. 32 33 Parameters 34 ---------- 35 datasetName: str 36 Name for this dataset. 37 df: pandas.DataFrame 38 Pandas DataFrame containing your data. The index must be 39 DatetimeIndex. The first columns must be ISIN, Country, Currency by default. 40 infer_from_column_names: bool 41 Allows creation of dataset schemas with more flexible identifier columns. 42 Identifier column names must be specified equal to (case and whitespace insensitive) 43 one of the values in boosted.api.api_type.ColumnSubRole. These columns must be grouped 44 together as a block in the first N columns of your dataset, where N is the number of 45 identifiers. 46 47 Returns 48 ------- 49 DatasetConfig 50 A DatasetConfig can be used to create a new dataset. 51 """ 52 return infer_dataset_schema( 53 name, df, DataSetType.STOCK, infer_from_column_names=infer_from_column_names 54 ) 55 56 57def inferDependentHistoricalQuarterlyDataSetSchema( 58 name, df, infer_dataset_report_period=True, infer_from_column_names=False 59): 60 """ 61 Creates a dependent dataset schema by inferring the contents from a Pandas DataFrame. 62 63 Parameters 64 ---------- 65 datasetName: str 66 Name for this dataset. 67 df: pandas.DataFrame 68 Pandas DataFrame containing your data. The index must be 69 DatetimeIndex. The first columns must be ISIN, Country, Currency by default. 70 infer_from_column_names: bool 71 Allows creation of dataset schemas with more flexible identifier columns. 72 Identifier column names must be specified equal to (case and whitespace insensitive) 73 one of the values in boosted.api.api_type.ColumnSubRole. These columns must be grouped 74 together as a block in the first N columns of your dataset, where N is the number of 75 identifiers. 76 infer_dataset_report_period: bool 77 Allow the report period to be inferred based on the report date 78 79 Returns 80 ------- 81 DatasetConfig 82 A DatasetConfig can be used to create a new dataset. 83 """ 84 return infer_dataset_schema( 85 name, 86 df, 87 DataSetType.STOCK, 88 dataset_subtype=DataSetSubType.SPARSE_HIST, 89 dataset_frequency=DataSetFrequency.QUARTERLY, 90 infer_dataset_report_period=infer_dataset_report_period, 91 infer_from_column_names=infer_from_column_names, 92 ) 93 94 95def inferDependentForwardQuarterlyDataSetSchema( 96 name, df, infer_dataset_report_period=True, infer_from_column_names=False 97): 98 """ 99 Creates a dependent dataset schema by inferring the contents from a Pandas DataFrame. 100 101 Parameters 102 ---------- 103 datasetName: str 104 Name for this dataset. 105 df: pandas.DataFrame 106 Pandas DataFrame containing your data. The index must be 107 DatetimeIndex. The first columns must be ISIN, Country, Currency by default. 108 infer_from_column_names: bool 109 Allows creation of dataset schemas with more flexible identifier columns. 110 Identifier column names must be specified equal to (case and whitespace insensitive) 111 one of the values in boosted.api.api_type.ColumnSubRole. These columns must be grouped 112 together as a block in the first N columns of your dataset, where N is the number of 113 identifiers. 114 infer_dataset_report_period: bool 115 Allow the report period to be inferred based on the report date 116 117 Returns 118 ------- 119 DatasetConfig 120 A DatasetConfig can be used to create a new dataset. 121 """ 122 return infer_dataset_schema( 123 name, 124 df, 125 DataSetType.STOCK, 126 dataset_subtype=DataSetSubType.SPARSE_FWD, 127 dataset_frequency=DataSetFrequency.QUARTERLY, 128 infer_dataset_report_period=infer_dataset_report_period, 129 infer_from_column_names=infer_from_column_names, 130 ) 131 132 133def inferIndependentDataSetSchema(name, df): 134 """ 135 Creates a independent dataset schema by inferring the contents from a Pandas DataFrame. 136 137 Parameters 138 ---------- 139 datasetName: str 140 Name for this dataset. 141 df: pandas.DataFrame 142 Pandas DataFrame containing your data. The index must be 143 DatetimeIndex. The first column must be a unique custom security identifier 144 145 Returns 146 ------- 147 DatasetConfig 148 A DatasetConfig can be used to create a new dataset. 149 """ 150 return infer_dataset_schema(name, df, DataSetType.STRATEGY, infer_from_column_names=False) 151 152 153def inferGlobalDataSetSchema(name, df): 154 """ 155 Creates a independent dataset schema by inferring the contents from a Pandas DataFrame. 156 157 Parameters 158 ---------- 159 datasetName: str 160 Name for this dataset. 161 df: pandas.DataFrame 162 Pandas DataFrame containing your data. The index must be 163 DatetimeIndex. 164 165 Returns 166 ------- 167 DatasetConfig 168 A DatasetConfig can be used to create a new dataset. 169 """ 170 return infer_dataset_schema(name, df, DataSetType.GLOBAL, infer_from_column_names=False) 171 172 173def getDataSetSchema(apikey, dataset_id, proxy=None, disable_verify_ssl=False): 174 """ 175 Retrieves a DataSetConfig representing the schema of an existing dataset. 176 177 Parameters 178 ---------- 179 apikey: str 180 API key provided by Boosted. This key should be protected as a secret. 181 dataset_id: str 182 Dataset ID. Can be from the output of addIndependentDataset or be found 183 in your Custom Data listing in Boosted Insights. 184 proxy: str 185 Your organization may require the use of a proxy for access. 186 The address of a HTTPS proxy in the format of <address>:<port>. 187 Examples are "123.456.789:123" or "my.proxy.com:123". 188 Do not prepend with "https://". 189 disable_verify_ssl: bool 190 Your networking setup may be behind a firewall which performs SSL 191 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 192 to point to the location of a custom certificate bundle, or set this 193 parameter to true to disable SSL verification as a workaround. 194 195 Returns 196 ------- 197 DataSetConfig 198 A DataSetConfig can be used to create a new dataset. 199 """ 200 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 201 return client.get_dataset_schema(dataset_id) 202 203 204def addDependentDataset( 205 apikey, 206 dataset, 207 datasetName="DependentDataset", 208 datasetConfig=None, 209 proxy=None, 210 disable_verify_ssl=False, 211 timeout: int = 600, 212 block: bool = True, 213): 214 """ 215 Creates a new dependent dataset. 216 217 Creates a new dataset by inferring a schema from your dataset. This will 218 also upload the dataset. 219 220 See http://docs.insights.boosted.ai/integrated-data for more information 221 on formatting. 222 223 Parameters 224 ---------- 225 apikey: str 226 API key provided by Boosted. This key should be protected as a secret. 227 dataset: pandas.DataFrame 228 Pandas DataFrame containing your data. The index must be 229 DatetimeIndex. The first columns must be ISIN, Country, Currency, 230 or comprise all identifier columns in the dataset schema if a schema was 231 specified 232 datasetName: str 233 Name for this dataset. 234 datasetConfig: DatasetConfig 235 A pre-configured dataset schema 236 proxy: str 237 Your organization may require the use of a proxy for access. 238 The address of a HTTPS proxy in the format of <address>:<port>. 239 Examples are "123.456.789:123" or "my.proxy.com:123". 240 Do not prepend with "https://". 241 disable_verify_ssl: bool 242 Your networking setup may be behind a firewall which performs SSL 243 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 244 to point to the location of a custom certificate bundle, or set this 245 parameter to true to disable SSL verification as a workaround. 246 timeout: int = 600 247 Number of seconds before a timeout error should be triggered. 248 block: bool = True 249 Whether the python process should block until the dataset is fully 250 uploaded and processed. 251 252 Returns 253 ------- 254 str 255 Dataset ID of the newly created dataset. 256 """ 257 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 258 return client.add_dependent_dataset( 259 dataset, datasetName, datasetConfig, timeout=timeout, block=block 260 ) 261 262 263def addIndependentDataset( 264 apikey, 265 dataset, 266 datasetName="IndependentDataset", 267 datasetConfig=None, 268 proxy=None, 269 disable_verify_ssl=False, 270 timeout: int = 600, 271 block: bool = True, 272): 273 """ 274 Creates a new independent dataset. 275 276 Creates a new dataset by inferring a schema from your dataset. This will 277 also upload the dataset. 278 279 See http://docs.insights.boosted.ai/independent-data for more information 280 on formatting. 281 282 Parameters 283 ---------- 284 apikey: str 285 API key provided by Boosted. This key should be protected as a secret. 286 dataset: pandas.DataFrame 287 Pandas DataFrame containing your data. The index must be 288 DatetimeIndex. The first column must be a unique custom security identifier 289 datasetName: str 290 Name for this dataset. 291 datasetConfig: DatasetConfig 292 A pre-configured dataset schema 293 proxy: str 294 Your organization may require the use of a proxy for access. 295 The address of a HTTPS proxy in the format of <address>:<port>. 296 Examples are "123.456.789:123" or "my.proxy.com:123". 297 Do not prepend with "https://". 298 disable_verify_ssl: bool 299 Your networking setup may be behind a firewall which performs SSL 300 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 301 to point to the location of a custom certificate bundle, or set this 302 parameter to true to disable SSL verification as a workaround. 303 timeout: int = 600 304 Number of seconds before a timeout error should be triggered. 305 block: bool = True 306 Whether the python process should block until the dataset is fully 307 uploaded and processed. 308 309 Returns 310 ------- 311 str 312 Dataset ID of the newly created dataset. 313 """ 314 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 315 return client.add_independent_dataset( 316 dataset, datasetName, datasetConfig, timeout=timeout, block=block 317 ) 318 319 320def addGlobalDataset( 321 apikey, 322 dataset, 323 datasetName="GlobalDataset", 324 datasetConfig=None, 325 proxy=None, 326 disable_verify_ssl=False, 327 timeout: int = 600, 328 block: bool = True, 329): 330 """ 331 Creates a new global dataset. 332 333 Creates a new dataset by inferring a schema from your dataset. This will 334 also upload the dataset. 335 336 See http://docs.insights.boosted.ai/global-data for more information 337 on formatting. 338 339 Parameters 340 ---------- 341 apikey: str 342 API key provided by Boosted. This key should be protected as a secret. 343 dataset: pandas.DataFrame 344 Pandas DataFrame containing your data. The index must be 345 DatetimeIndex. 346 datasetName: str 347 Name for this dataset. 348 datasetConfig: DatasetConfig 349 A pre-configured dataset schema 350 proxy: str 351 Your organization may require the use of a proxy for access. 352 The address of a HTTPS proxy in the format of <address>:<port>. 353 Examples are "123.456.789:123" or "my.proxy.com:123". 354 Do not prepend with "https://". 355 disable_verify_ssl: bool 356 Your networking setup may be behind a firewall which performs SSL 357 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 358 to point to the location of a custom certificate bundle, or set this 359 parameter to true to disable SSL verification as a workaround. 360 timeout: int = 600 361 Number of seconds before a timeout error should be triggered. 362 block: bool = True 363 Whether the python process should block until the dataset is fully 364 uploaded and processed. 365 366 Returns 367 ------- 368 str 369 Dataset ID of the newly created dataset. 370 """ 371 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 372 return client.add_global_dataset( 373 dataset, datasetName, datasetConfig, timeout=timeout, block=block 374 ) 375 376 377def exportDependentDataset( 378 apikey, dataset_id, proxy=None, disable_verify_ssl=False, timeout: int = 600 379): 380 """ 381 Exports an existing dependent dataset. 382 383 Exports an existing dataset identified by a dataset ID. Returns the data 384 as a Pandas DataFrame. 385 386 Parameters 387 ---------- 388 apikey: str 389 API key provided by Boosted. This key should be protected as a secret. 390 dataset_id: str 391 Dataset ID. Can be from the output of addDependentDataset or be found 392 in your Custom Data listing in Boosted Insights. 393 proxy: str 394 Your organization may require the use of a proxy for access. 395 The address of a HTTPS proxy in the format of <address>:<port>. 396 Examples are "123.456.789:123" or "my.proxy.com:123". 397 Do not prepend with "https://". 398 disable_verify_ssl: bool 399 Your networking setup may be behind a firewall which performs SSL 400 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 401 to point to the location of a custom certificate bundle, or set this 402 parameter to true to disable SSL verification as a workaround. 403 timeout: int = 600 404 Number of seconds before a timeout error should be triggered. 405 406 Returns 407 ------- 408 pandas.DataFrame 409 Pandas DataFrame containing your data that will be indexed by the date. 410 The DataFrame schema is identical to the one used to upload a dataset. 411 """ 412 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 413 return client.export_dependent_data(dataset_id, timeout=timeout) 414 415 416def exportIndependentDataset( 417 apikey, 418 dataset_id, 419 proxy=None, 420 disable_verify_ssl=False, 421 timeout: int = 600, 422): 423 """ 424 Exports an existing independent dataset. 425 426 Exports an existing dataset identified by a dataset ID. Returns the data 427 as a Pandas DataFrame. 428 429 Parameters 430 ---------- 431 apikey: str 432 API key provided by Boosted. This key should be protected as a secret. 433 dataset_id: str 434 Dataset ID. Can be from the output of addIndependentDataset or be found 435 in your Custom Data listing in Boosted Insights. 436 proxy: str 437 Your organization may require the use of a proxy for access. 438 The address of a HTTPS proxy in the format of <address>:<port>. 439 Examples are "123.456.789:123" or "my.proxy.com:123". 440 Do not prepend with "https://". 441 disable_verify_ssl: bool 442 Your networking setup may be behind a firewall which performs SSL 443 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 444 to point to the location of a custom certificate bundle, or set this 445 parameter to true to disable SSL verification as a workaround. 446 timeout: int = 600 447 Number of seconds before a timeout error should be triggered. 448 449 Returns 450 ------- 451 pandas.DataFrame 452 Pandas DataFrame containing your data that will be indexed by the date. 453 The DataFrame schema is identical to the one used to upload a dataset. 454 """ 455 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 456 return client.export_independent_data(dataset_id, timeout=timeout) 457 458 459def exportGlobalDataset( 460 apikey, dataset_id, proxy=None, disable_verify_ssl=False, timeout: int = 600 461): 462 """ 463 Exports an existing global dataset. 464 465 Exports an existing dataset identified by a dataset ID. Returns the data 466 as a Pandas DataFrame. 467 468 Parameters 469 ---------- 470 apikey: str 471 API key provided by Boosted. This key should be protected as a secret. 472 dataset_id: str 473 Dataset ID. Can be from the output of addGlobalDataset or be found 474 in your Custom Data listing in Boosted Insights. 475 proxy: str 476 Your organization may require the use of a proxy for access. 477 The address of a HTTPS proxy in the format of <address>:<port>. 478 Examples are "123.456.789:123" or "my.proxy.com:123". 479 Do not prepend with "https://". 480 disable_verify_ssl: bool 481 Your networking setup may be behind a firewall which performs SSL 482 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 483 to point to the location of a custom certificate bundle, or set this 484 parameter to true to disable SSL verification as a workaround. 485 timeout: int = 600 486 Number of seconds before a timeout error should be triggered. 487 488 Returns 489 ------- 490 pandas.DataFrame 491 Pandas DataFrame containing your data that will be indexed by the date. 492 The DataFrame schema is identical to the one used to upload a dataset. 493 """ 494 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 495 return client.export_global_data(dataset_id, timeout=timeout) 496 497 498def addDependentData( 499 apikey, 500 dataset_id, 501 dataset, 502 proxy=None, 503 disable_verify_ssl=False, 504 timeout: int = 600, 505 block: bool = True, 506): 507 """ 508 Adds data to an existing dependent dataset. 509 510 This uploads the data in ``dataset`` to an existing dataset. Existing 511 date/ISIN pairs will be overwritten. 512 513 Parameters 514 ---------- 515 apikey: str 516 API key provided by Boosted. This key should be protected as a secret. 517 dataset_id: str 518 Dataset ID. Can be from the output of addDependentDataset or be found 519 in your Custom Data listing in Boosted Insights. 520 dataset: pandas.DataFrame 521 Pandas DataFrame containing your data. The index must be 522 DatetimeIndex. The first columns must comprise all identifier columns in the 523 dataset schema. 524 proxy: str 525 Your organization may require the use of a proxy for access. 526 The address of a HTTPS proxy in the format of <address>:<port>. 527 Examples are "123.456.789:123" or "my.proxy.com:123". 528 Do not prepend with "https://". 529 disable_verify_ssl: bool 530 Your networking setup may be behind a firewall which performs SSL 531 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 532 to point to the location of a custom certificate bundle, or set this 533 parameter to true to disable SSL verification as a workaround. 534 timeout: int = 600 535 Number of seconds before a timeout error should be triggered. 536 block: bool = True 537 Whether the python process should block until the dataset is fully 538 uploaded and processed. 539 540 Returns 541 ------- 542 None 543 """ 544 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 545 return client.add_dependent_data( 546 dataset_id, dataset, timeout=timeout, block=block, data_type=DataAddType.HISTORICAL 547 ) 548 549 550def addIndependentData( 551 apikey, 552 dataset_id, 553 dataset, 554 proxy=None, 555 disable_verify_ssl=False, 556 timeout: int = 600, 557 block: bool = True, 558): 559 """ 560 Adds data to an existing independent dataset. 561 562 This uploads the data in ``dataset`` to an existing dataset. Existing 563 dates will be overwritten. 564 565 Parameters 566 ---------- 567 apikey: str 568 API key provided by Boosted. This key should be protected as a secret. 569 dataset_id: str 570 Dataset ID. Can be from the output of addIndependentDataset or be found 571 in your Custom Data listing in Boosted Insights. 572 dataset: pandas.DataFrame 573 Pandas DataFrame containing your data. The index must be 574 DatetimeIndex. 575 proxy: str 576 Your organization may require the use of a proxy for access. 577 The address of a HTTPS proxy in the format of <address>:<port>. 578 Examples are "123.456.789:123" or "my.proxy.com:123". 579 Do not prepend with "https://". 580 disable_verify_ssl: bool 581 Your networking setup may be behind a firewall which performs SSL 582 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 583 to point to the location of a custom certificate bundle, or set this 584 parameter to true to disable SSL verification as a workaround. 585 timeout: int = 600 586 Number of seconds before a timeout error should be triggered. 587 block: bool = True 588 Whether the python process should block until the dataset is fully 589 uploaded and processed. 590 591 Returns 592 ------- 593 None 594 """ 595 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 596 return client.add_independent_data( 597 dataset_id, dataset, timeout=timeout, block=block, data_type=DataAddType.HISTORICAL 598 ) 599 600 601def addGlobalData( 602 apikey, 603 dataset_id, 604 dataset, 605 proxy=None, 606 disable_verify_ssl=False, 607 timeout: int = 600, 608 block: bool = True, 609): 610 """ 611 Adds data to an existing global dataset. 612 613 This uploads the data in ``dataset`` to an existing dataset. Existing 614 date/custom security identifier pairs will be overwritten. 615 616 Parameters 617 ---------- 618 apikey: str 619 API key provided by Boosted. This key should be protected as a secret. 620 dataset_id: str 621 Dataset ID. Can be from the output of addGlobalDataset or be found 622 in your Custom Data listing in Boosted Insights. 623 dataset: pandas.DataFrame 624 Pandas DataFrame containing your data. The index must be 625 DatetimeIndex. The first column must be custom security identifier 626 proxy: str 627 Your organization may require the use of a proxy for access. 628 The address of a HTTPS proxy in the format of <address>:<port>. 629 Examples are "123.456.789:123" or "my.proxy.com:123". 630 Do not prepend with "https://". 631 disable_verify_ssl: bool 632 Your networking setup may be behind a firewall which performs SSL 633 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 634 to point to the location of a custom certificate bundle, or set this 635 parameter to true to disable SSL verification as a workaround. 636 timeout: int = 600 637 Number of seconds before a timeout error should be triggered. 638 block: bool = True 639 Whether the python process should block until the dataset is fully 640 uploaded and processed. 641 642 Returns 643 ------- 644 None 645 """ 646 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 647 return client.add_global_data( 648 dataset_id, dataset, timeout=timeout, block=block, data_type=DataAddType.HISTORICAL 649 ) 650 651 652def addLiveDependentData( 653 apikey, 654 dataset_id, 655 dataset, 656 proxy=None, 657 disable_verify_ssl=False, 658 timeout: int = 600, 659 block: bool = True, 660): 661 """ 662 Adds live data to an existing dependent dataset. 663 664 This uploads the data in ``dataset`` to an existing dataset. Existing 665 date/ISIN pairs will be overwritten. 666 667 Parameters 668 ---------- 669 apikey: str 670 API key provided by Boosted. This key should be protected as a secret. 671 dataset_id: str 672 Dataset ID. Can be from the output of addDependentDataset or be found 673 in your Custom Data listing in Boosted Insights. 674 dataset: pandas.DataFrame 675 Pandas DataFrame containing your data. The index must be 676 DatetimeIndex. The first columns must be ISIN, Country, Currency. 677 proxy: str 678 Your organization may require the use of a proxy for access. 679 The address of a HTTPS proxy in the format of <address>:<port>. 680 Examples are "123.456.789:123" or "my.proxy.com:123". 681 Do not prepend with "https://". 682 disable_verify_ssl: bool 683 Your networking setup may be behind a firewall which performs SSL 684 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 685 to point to the location of a custom certificate bundle, or set this 686 parameter to true to disable SSL verification as a workaround. 687 timeout: int = 600 688 Number of seconds before a timeout error should be triggered. 689 block: bool = True 690 Whether the python process should block until the dataset is fully 691 uploaded and processed. 692 693 Returns 694 ------- 695 None 696 """ 697 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 698 return client.add_dependent_data( 699 dataset_id, dataset, timeout=timeout, block=block, data_type=DataAddType.LIVE 700 ) 701 702 703def addLiveIndependentData( 704 apikey, 705 dataset_id, 706 dataset, 707 proxy=None, 708 disable_verify_ssl=False, 709 timeout: int = 600, 710 block: bool = True, 711): 712 """ 713 Adds live data to an existing independent dataset. 714 715 This uploads the data in ``dataset`` to an existing dataset. Existing 716 dates will be overwritten. 717 718 Parameters 719 ---------- 720 apikey: str 721 API key provided by Boosted. This key should be protected as a secret. 722 dataset_id: str 723 Dataset ID. Can be from the output of addIndependentDataset or be found 724 in your Custom Data listing in Boosted Insights. 725 dataset: pandas.DataFrame 726 Pandas DataFrame containing your data. The index must be 727 DatetimeIndex. 728 proxy: str 729 Your organization may require the use of a proxy for access. 730 The address of a HTTPS proxy in the format of <address>:<port>. 731 Examples are "123.456.789:123" or "my.proxy.com:123". 732 Do not prepend with "https://". 733 disable_verify_ssl: bool 734 Your networking setup may be behind a firewall which performs SSL 735 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 736 to point to the location of a custom certificate bundle, or set this 737 parameter to true to disable SSL verification as a workaround. 738 timeout: int = 600 739 Number of seconds before a timeout error should be triggered. 740 block: bool = True 741 Whether the python process should block until the dataset is fully 742 uploaded and processed. 743 744 Returns 745 ------- 746 None 747 """ 748 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 749 return client.add_independent_data( 750 dataset_id, dataset, timeout=timeout, block=block, data_type=DataAddType.LIVE 751 ) 752 753 754def addLiveGlobalData( 755 apikey, 756 dataset_id, 757 dataset, 758 proxy=None, 759 disable_verify_ssl=False, 760 timeout: int = 600, 761 block: bool = True, 762): 763 """ 764 Adds live data to an existing global dataset. 765 766 This uploads the data in ``dataset`` to an existing dataset. Existing 767 date/custom security identifier pairs will be overwritten. 768 769 Parameters 770 ---------- 771 apikey: str 772 API key provided by Boosted. This key should be protected as a secret. 773 dataset_id: str 774 Dataset ID. Can be from the output of addGlobalDataset or be found 775 in your Custom Data listing in Boosted Insights. 776 dataset: pandas.DataFrame 777 Pandas DataFrame containing your data. The index must be 778 DatetimeIndex. The first column must be custom security identifier 779 proxy: str 780 Your organization may require the use of a proxy for access. 781 The address of a HTTPS proxy in the format of <address>:<port>. 782 Examples are "123.456.789:123" or "my.proxy.com:123". 783 Do not prepend with "https://". 784 disable_verify_ssl: bool 785 Your networking setup may be behind a firewall which performs SSL 786 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 787 to point to the location of a custom certificate bundle, or set this 788 parameter to true to disable SSL verification as a workaround. 789 timeout: int = 600 790 Number of seconds before a timeout error should be triggered. 791 block: bool = True 792 Whether the python process should block until the dataset is fully 793 uploaded and processed. 794 795 Returns 796 ------- 797 None 798 """ 799 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 800 return client.add_global_data( 801 dataset_id, dataset, timeout=timeout, block=block, data_type=DataAddType.LIVE 802 ) 803 804 805def queryDataset(apikey, dataset_id, proxy=None, disable_verify_ssl=False): 806 """ 807 Queries the status, timerange of a dataset. 808 809 Returns meta-information about a dataset. This can be used to check the 810 dateranges covered and the current status. 811 812 Parameters 813 ---------- 814 apikey: str 815 API key provided by Boosted. This key should be protected as a secret. 816 dataset_id: str 817 Dataset ID. Can be from the output of addDependentDataset or be found 818 in your Custom Data listing in Boosted Insights. 819 proxy: str 820 Your organization may require the use of a proxy for access. 821 The address of a HTTPS proxy in the format of <address>:<port>. 822 Examples are "123.456.789:123" or "my.proxy.com:123". 823 Do not prepend with "https://". 824 disable_verify_ssl: bool 825 Your networking setup may be behind a firewall which performs SSL 826 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 827 to point to the location of a custom certificate bundle, or set this 828 parameter to true to disable SSL verification as a workaround. 829 830 Returns 831 ------- 832 dict: 833 Dictionary containing meta-data about the dataset. 834 835 'created': <creation date>, 836 'fileSize': <file size>, 837 'id': <dataset ID>, 838 'name': <dataset name>, 839 'ownerId': <owner ID>, 840 'region': <dataset region>, 841 'status': {AVAILABLE|UPDATING|CREATING|ERROR}, 842 'type': {STOCK|STRATEGY|GLOBAL}, 843 'universeId': <universe ID>, 844 'validFrom': [YYYY, MM, DD], 845 'validTo': [YYYY, MM, DD]} 846 847 """ 848 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 849 return client.query_dataset(dataset_id) 850 851 852def getUniverse(apikey, model_id, date=None, proxy=None, disable_verify_ssl=False): 853 """ 854 Returns the universe members of a model. 855 856 Returns the members of the universe of a model. If no date is provided, 857 effective date ranges will be returned. If a date is provided, only the 858 universe members of that date are returned. The results are returned in a 859 Pandas DataFrame. 860 861 For more information, see http://docs.insights.boosted.ai/universe-upload. 862 863 Parameters 864 ---------- 865 apikey: str 866 API key provided by Boosted. This key should be protected as a secret. 867 model_id: str 868 Model ID. Model IDs can be retrieved by clicking on the copy to clipboard 869 button next to your model's name in the Model Summary Page in Boosted 870 Insights. 871 date: datetime.date or YYYY-MM-DD string 872 Date of the universe to retrieve. 873 proxy: str 874 Your organization may require the use of a proxy for access. 875 The address of a HTTPS proxy in the format of <address>:<port>. 876 Examples are "123.456.789:123" or "my.proxy.com:123". 877 Do not prepend with "https://". 878 disable_verify_ssl: bool 879 Your networking setup may be behind a firewall which performs SSL 880 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 881 to point to the location of a custom certificate bundle, or set this 882 parameter to true to disable SSL verification as a workaround. 883 884 Returns 885 ------- 886 pandas.DataFrame 887 Pandas DataFrame containing the universe members. If a date was 888 provided, only ISIN, Country, and Currency are returned. If no date 889 was provided, returns From, To, ISIN, Country, Currency. 890 """ 891 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 892 return client.getUniverse(model_id, date) 893 894 895def updateUniverse( 896 apikey, 897 model_id, 898 universe_df, 899 date=datetime.date.today() + timedelta(1), 900 proxy=None, 901 disable_verify_ssl=False, 902): 903 """ 904 Sets the universe members of a model. 905 906 Sets the members of the universe of a model. Universe members may only be 907 set for future dates. 908 909 For more information, see http://docs.insights.boosted.ai/universe-upload. 910 911 Parameters 912 ---------- 913 apikey: str 914 API key provided by Boosted. This key should be protected as a secret. 915 model_id: str 916 Model ID. Model IDs can be retrieved by clicking on the copy to clipboard 917 button next to your model's name in the Model Summary Page in Boosted 918 Insights. 919 universe_df: Pandas.DataFrame 920 A Pandas.DataFrame with columns ISIN, Country, Currency. 921 date: datetime.date or YYYY-MM-DD string 922 Date of the universe to retrieve. 923 proxy: str 924 Your organization may require the use of a proxy for access. 925 The address of a HTTPS proxy in the format of <address>:<port>. 926 Examples are "123.456.789:123" or "my.proxy.com:123". 927 Do not prepend with "https://". 928 disable_verify_ssl: bool 929 Your networking setup may be behind a firewall which performs SSL 930 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 931 to point to the location of a custom certificate bundle, or set this 932 parameter to true to disable SSL verification as a workaround. 933 934 Returns 935 ------- 936 str 937 Any warnings, e.g. failure to map ISINs, are returned. 938 """ 939 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 940 return client.updateUniverse(model_id, universe_df, date) 941 942 943def createUniverse( 944 apikey: str, 945 universe: Union[pd.DataFrame, str], 946 name: str, 947 description: Optional[str] = None, 948 proxy=None, 949 disable_verify_ssl=False, 950) -> List[str]: 951 """ 952 Creates a new boosted security universe. 953 954 Columns in the universe (dataframe or csv file path) to identify the 955 universe are isin and/or symbol, from, to, country, currency. 956 957 Note that either isin or symbol are required columns. 958 959 Rules for the universe data are identical to those on the web universe 960 creation screen: 961 - Make sure your CSV does not contain empty columns. 962 - Date columns must be in YYYY-MM-DD format. 963 - The "from" and "to" fields represent the date range for which a 964 security will exist in the universe for. The keyword "PRESENT" can be used 965 in place of the "to_date" field. If you wish to create a Live model, ensure that 966 at least some securities have "PRESENT" as their "to_date" field. 967 - If the "to_date" column is ommitted, securites will exist in the universe 968 until "PRESENT" by default, if possible. 969 - "from" will default to "the beginning of time" if unspecified, and 970 "to" will default to "PRESENT" 971 972 - The keyword "ANY" can also be used in place of the country and currency 973 fields. 974 - Rows with "ANY" will select the optimal security based on other securities 975 in the portfolio For Country and Currency, the prefix "P_" (i.e. "P_USA") 976 means "preferred." The model will attempt to match the security to the 977 preferred specification. 978 - "country" and "currency" will default to "ANY" if the column was 979 omitted. 980 981 Parameters 982 ---------- 983 apikey: str 984 API key provided by Boosted. This key should be protected as a secret. 985 universe: Union[Pandas.DataFrame, str] 986 May be either a Pandas.DataFrame, or a path to a csv. 987 name: str 988 The name of the new universe. 989 description: str 990 Optional description of the new universe. 991 proxy: str 992 Your organization may require the use of a proxy for access. 993 The address of a HTTPS proxy in the format of <address>:<port>. 994 Examples are "123.456.789:123" or "my.proxy.com:123". 995 Do not prepend with "https://". 996 disable_verify_ssl: bool 997 Your networking setup may be behind a firewall which performs SSL 998 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 999 to point to the location of a custom certificate bundle, or set this 1000 parameter to true to disable SSL verification as a workaround. 1001 1002 Returns 1003 ------- 1004 List[str] 1005 List of any warnings, e.g. failure to map ISINs, are returned. Return 1006 empty list if no warnings are returned. 1007 """ 1008 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 1009 description = "" if description is None else description 1010 return client.create_universe(universe, name, description) 1011 1012 1013def getAllocationsForDate( 1014 apikey, 1015 portfolio_id, 1016 date=datetime.date.today(), 1017 rollback_to_last_available_date=False, 1018 proxy=None, 1019 disable_verify_ssl=False, 1020): 1021 """ 1022 Get the allocations for a portfolio on a date. 1023 1024 Parameters 1025 ---------- 1026 apikey: str 1027 API key provided by Boosted. This key should be protected as a secret. 1028 portfolio_id: str 1029 Portfolio ID. Portfolio IDs can be retrieved from portfolio's configuration page. 1030 date: datetime.date or YYYY-MM-DD string 1031 Date of the universe to retrieve. 1032 rollback_to_last_available_date: bool 1033 Whether or not to retrieve rankings for the most recent date if the current date 1034 is not a trade date. 1035 proxy: str 1036 Your organization may require the use of a proxy for access. 1037 The address of a HTTPS proxy in the format of <address>:<port>. 1038 Examples are "123.456.789:123" or "my.proxy.com:123". 1039 Do not prepend with "https://". 1040 disable_verify_ssl: bool 1041 Your networking setup may be behind a firewall which performs SSL 1042 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 1043 to point to the location of a custom certificate bundle, or set this 1044 parameter to true to disable SSL verification as a workaround. 1045 1046 Returns 1047 ------- 1048 dict: 1049 Dictionary containing allocation information: 1050 model_id: str 1051 - Model id from accompanying portfolio 1052 date: str 1053 - Date string in yyyy/mm/dd format of date of the allocation data 1054 allocations: List of dict 1055 - List of allocation information 1056 allocation: float 1057 - Allocation of security 1058 allocation_delta: float 1059 - Difference in allocation compared to previous trade 1060 company_name: str 1061 - Security name 1062 country: str 1063 - Security exchange region 1064 currency: str 1065 - Security currency 1066 has_trade_signal: bool 1067 - If trade was based on signal or outside reason 1068 isin: str 1069 - ISIN of security 1070 price: float 1071 - Price of security 1072 shares_owned: float 1073 - Current shares of the security 1074 shares_traded: float 1075 - Number of share traded of te security 1076 symbol: str 1077 - Symbol of the security 1078 """ 1079 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 1080 return client.getAllocationsForDate(portfolio_id, date, rollback_to_last_available_date) 1081 1082 1083def getAllocationsForDateV2( 1084 apikey, 1085 portfolio_id, 1086 date=datetime.date.today(), 1087 rollback_to_last_available_date=False, 1088 proxy=None, 1089 disable_verify_ssl=False, 1090): 1091 """ 1092 Get the allocations for a portfolio on a date. 1093 1094 Parameters 1095 ---------- 1096 apikey: str 1097 API key provided by Boosted. This key should be protected as a secret. 1098 portfolio_id: str 1099 Portfolio ID. Portfolio IDs can be retrieved from portfolio's configuration page. 1100 date: datetime.date or YYYY-MM-DD string 1101 Date of the universe to retrieve. 1102 rollback_to_last_available_date: bool 1103 Whether or not to retrieve rankings for the most recent date if the current date 1104 is not a trade date. 1105 proxy: str 1106 Your organization may require the use of a proxy for access. 1107 The address of a HTTPS proxy in the format of <address>:<port>. 1108 Examples are "123.456.789:123" or "my.proxy.com:123". 1109 Do not prepend with "https://". 1110 disable_verify_ssl: bool 1111 Your networking setup may be behind a firewall which performs SSL 1112 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 1113 to point to the location of a custom certificate bundle, or set this 1114 parameter to true to disable SSL verification as a workaround. 1115 1116 Returns 1117 ------- 1118 dict: 1119 Dictionary containing allocation information: 1120 model_id: str 1121 - Model id from accompanying portfolio 1122 date: str 1123 - Date string in yyyy/mm/dd format of date of the allocation data 1124 allocations: List of dict 1125 - List of allocation information 1126 allocation: float 1127 - Allocation of security 1128 allocation_delta: float 1129 - Difference in allocation compared to previous allocation 1130 company_name: str 1131 - Security name 1132 country: str 1133 - Security exchange region 1134 currency: str 1135 - Security currency 1136 has_trade_signal: bool 1137 - If trade was based on signal or outside reason 1138 isin: str 1139 - ISIN of security 1140 price: float 1141 - Price of security 1142 shares_owned: float 1143 - Current shares of the security 1144 shares_traded: float 1145 - Number of shares traded of te security 1146 symbol: str 1147 - Symbol of the security 1148 """ 1149 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 1150 return client.getAllocationsForDateV2(portfolio_id, date, rollback_to_last_available_date) 1151 1152 1153def getAllocationsForAllDates(apikey, portfolio_id, proxy=None, disable_verify_ssl=False): 1154 """ 1155 Get the allocations for a portfolio on all dates. 1156 1157 Parameters 1158 ---------- 1159 apikey: str 1160 API key provided by Boosted. This key should be protected as a secret. 1161 portfolio_id: str 1162 Portfolio ID. Portfolio IDs can be retrieved from portfolio's configuration page. 1163 proxy: str 1164 Your organization may require the use of a proxy for access. 1165 The address of a HTTPS proxy in the format of <address>:<port>. 1166 Examples are "123.456.789:123" or "my.proxy.com:123". 1167 Do not prepend with "https://". 1168 disable_verify_ssl: bool 1169 Your networking setup may be behind a firewall which performs SSL 1170 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 1171 to point to the location of a custom certificate bundle, or set this 1172 parameter to true to disable SSL verification as a workaround. 1173 1174 Returns 1175 ------- 1176 dict: 1177 Dictionary containing allocation information. 1178 model_id: str 1179 - Model id from accompanying portfolio 1180 allocations: dict 1181 keys: date of the allocations in the value 1182 value: list of dict 1183 - List of allocation information 1184 allocation: float 1185 - Allocation of security 1186 allocation_delta: float 1187 - Difference in allocation compared to previous trade 1188 company_name: str 1189 - Security name 1190 country: str 1191 - Security exchange region 1192 currency: str 1193 - Security currency 1194 has_trade_signal: bool 1195 - If trade was based on signal or outside reason 1196 isin: str 1197 - ISIN of security 1198 price: float 1199 - Price of security 1200 shares_owned: float 1201 - Current shares of the security 1202 shares_traded: float 1203 - Number of share traded of te security 1204 symbol: str 1205 - Symbol of the security 1206 """ 1207 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 1208 return client.getAllocationsByDates(portfolio_id) 1209 1210 1211def getSignalsForDate( 1212 apikey, 1213 portfolio_id, 1214 date=datetime.date.today(), 1215 rollback_to_last_available_date=False, 1216 proxy=None, 1217 disable_verify_ssl=False, 1218): 1219 """ 1220 Get the signals for a portfolio on a date. 1221 1222 Parameters 1223 ---------- 1224 apikey: str 1225 API key provided by Boosted. This key should be protected as a secret. 1226 portfolio_id: str 1227 Portfolio ID. Portfolio IDs can be retrieved from portfolio's configuration page. 1228 date: datetime.date or YYYY-MM-DD string 1229 Date of the universe to retrieve. 1230 rollback_to_last_available_date: bool 1231 Whether or not to retrieve rankings for the most recent date if the current date 1232 is not a trade date. 1233 proxy: str 1234 Your organization may require the use of a proxy for access. 1235 The address of a HTTPS proxy in the format of <address>:<port>. 1236 Examples are "123.456.789:123" or "my.proxy.com:123". 1237 Do not prepend with "https://". 1238 disable_verify_ssl: bool 1239 Your networking setup may be behind a firewall which performs SSL 1240 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 1241 to point to the location of a custom certificate bundle, or set this 1242 parameter to true to disable SSL verification as a workaround. 1243 1244 Returns 1245 ------- 1246 dict: 1247 Dictionary containing signals information: 1248 date: str 1249 - Date string in yyyy/mm/dd format of date of the signal data 1250 signals: List of dict 1251 - List of signal information per model 1252 model_id: str 1253 - Model id from accompanying portfolio 1254 signals_info: List of dict 1255 - Signal information for each security per model id 1256 company_name: str 1257 - Security name 1258 country: str 1259 - Security exchange region 1260 currency: str 1261 - Security currency 1262 isin: str 1263 - ISIN of security 1264 signal: float 1265 - Signal from model 1266 signal_delta: float 1267 - Change in signal compared to last trade 1268 symbol: str 1269 - Symbol of the security 1270 """ 1271 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 1272 return client.getSignalsForDate(portfolio_id, date, rollback_to_last_available_date) 1273 1274 1275def getSignalsForAllDates(apikey, portfolio_id, proxy=None, disable_verify_ssl=False): 1276 """ 1277 Get the signals for all dates in the portfolio. 1278 1279 Parameters 1280 ---------- 1281 apikey: str 1282 API key provided by Boosted. This key should be protected as a secret. 1283 portfolio_id: str 1284 Portfolio ID. Portfolio IDs can be retrieved from portfolio's configuration page. 1285 proxy: str 1286 Your organization may require the use of a proxy for access. 1287 The address of a HTTPS proxy in the format of <address>:<port>. 1288 Examples are "123.456.789:123" or "my.proxy.com:123". 1289 Do not prepend with "https://". 1290 disable_verify_ssl: bool 1291 Your networking setup may be behind a firewall which performs SSL 1292 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 1293 to point to the location of a custom certificate bundle, or set this 1294 parameter to true to disable SSL verification as a workaround. 1295 1296 Returns 1297 ------- 1298 dict: 1299 Dictionary containing signals information: 1300 model_id: str 1301 - Model id from accompanying portfolio 1302 signals: dict 1303 keys: date of the signals in the value 1304 value: list of dict 1305 - List of signal information per model 1306 signals_info: List of dict 1307 - Signal information for each security per model id 1308 company_name: str 1309 - Security name 1310 country: str 1311 - Security exchange region 1312 currency: str 1313 - Security currency 1314 date: str 1315 - Date string in yyyy/mm/dd format of date requested 1316 isin: str 1317 - ISIN of security 1318 signal: float 1319 - Signal from model 1320 signal_delta: float 1321 - Change in signal compared to last trade 1322 symbol: str 1323 - Symbol of the security 1324 """ 1325 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 1326 return client.getSignalsForAllDates(portfolio_id) 1327 1328 1329def getHistoricalTradeDates( 1330 apikey, portfolio_id, start_date=None, end_date=None, proxy=None, disable_verify_ssl=False 1331): 1332 """ 1333 Get the historical dates for which there exist trading data. 1334 1335 Parameters 1336 ---------- 1337 apikey: str 1338 API key provided by Boosted. This key should be protected as a secret. 1339 portfolio_id: str 1340 Portfolio ID. Portfolio IDs can be retrieved by clicking on the copy to clipboard 1341 button next to your portfolio's name in the Tear Sheet Page of a Model. 1342 start_date: datetime.date or YYYY-MM-DD string 1343 Starting date for the inclusive interval of dates to search. 1344 Defaults to 1 year prior to end date if unspecified. 1345 end_date: datetime.date or YYYY-MM-DD string 1346 Ending date for the inclusive interval of dates to search. 1347 Defaults to today if unspecified. 1348 proxy: str 1349 Your organization may require the use of a proxy for access. 1350 The address of a HTTPS proxy in the format of <address>:<port>. 1351 Examples are "123.456.789:123" or "my.proxy.com:123". 1352 Do not prepend with "https://". 1353 disable_verify_ssl: bool 1354 Your networking setup may be behind a firewall which performs SSL 1355 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 1356 to point to the location of a custom certificate bundle, or set this 1357 parameter to true to disable SSL verification as a workaround. 1358 1359 Returns 1360 ------- 1361 dict: 1362 Dictionary containing date information 1363 dates: List of str 1364 List of historical trade dates in YYYY-MM-DD format. 1365 """ 1366 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 1367 return client.getHistoricalTradeDates(portfolio_id, start_date, end_date) 1368 1369 1370def getRankingsForDate( 1371 apikey, 1372 portfolio_id, 1373 date=datetime.date.today(), 1374 rollback_to_last_available_date=False, 1375 proxy=None, 1376 disable_verify_ssl=False, 1377): 1378 """ 1379 Get the rankings data for a portfolio on a date. 1380 1381 Parameters 1382 ---------- 1383 apikey: str 1384 API key provided by Boosted. This key should be protected as a secret. 1385 portfolio_id: str 1386 Portfolio ID. Portfolio IDs can be retrieved from portfolio's configuration page. 1387 date: datetime.date or YYYY-MM-DD string 1388 Date of the universe to retrieve. 1389 rollback_to_last_available_date: bool 1390 Whether or not to retrieve rankings for the most recent date if the current date 1391 is not a trade date. 1392 proxy: str 1393 Your organization may require the use of a proxy for access. 1394 The address of a HTTPS proxy in the format of <address>:<port>. 1395 Examples are "123.456.789:123" or "my.proxy.com:123". 1396 Do not prepend with "https://". 1397 disable_verify_ssl: bool 1398 Your networking setup may be behind a firewall which performs SSL 1399 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 1400 to point to the location of a custom certificate bundle, or set this 1401 parameter to true to disable SSL verification as a workaround. 1402 1403 Returns 1404 ------- 1405 Dictionary containing rankings information: 1406 model_id: str 1407 - Model id that the portfolio belongs to 1408 date: str 1409 - Date string in yyyy/mm/dd format of date of the ranking data 1410 rankings: List of dict 1411 - Rankings info per security in the portfolio 1412 symbol: str 1413 - Symbol of the security 1414 isin: str 1415 - The International Securities Identification Number of the security 1416 country: str 1417 - Three character country code 1418 currency: str 1419 - The currency short length code 1420 rank: int 1421 - the ranking from 1 (top) 1422 companyName: str 1423 - The name of the company who owns the security 1424 delta: int 1425 - The change in ranking from the last data point, first will be null 1426 """ 1427 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 1428 return client.getRankingsForDate(portfolio_id, date, rollback_to_last_available_date) 1429 1430 1431def getRankingsForAllDates(apikey, portfolio_id, proxy=None, disable_verify_ssl=False): 1432 """ 1433 Get all rankings data for a portfolio. 1434 1435 Parameters 1436 ---------- 1437 apikey: str 1438 API key provided by Boosted. This key should be protected as a secret. 1439 portfolio_id: str 1440 Portfolio ID. Portfolio IDs can be retrieved from portfolio's configuration page. 1441 proxy: str 1442 Your organization may require the use of a proxy for access. 1443 The address of a HTTPS proxy in the format of <address>:<port>. 1444 Examples are "123.456.789:123" or "my.proxy.com:123". 1445 Do not prepend with "https://". 1446 disable_verify_ssl: bool 1447 Your networking setup may be behind a firewall which performs SSL 1448 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 1449 to point to the location of a custom certificate bundle, or set this 1450 parameter to true to disable SSL verification as a workaround. 1451 1452 Returns 1453 ------- 1454 Dictionary containing rankings information: 1455 model_id: str 1456 - Model id that the portfolio belongs to 1457 rankings: dict 1458 keys: dates requested in yyyy/mm/dd format, model_id 1459 value: list of dict 1460 - Rankings info per security in the portfolio 1461 symbol: str 1462 - Symbol of the security 1463 isin: str 1464 - The International Securities Identification Number of the security 1465 country: str 1466 - Three character country code 1467 currency: str 1468 - The currency short length code 1469 rank: int 1470 - the ranking from 1 (top) 1471 companyName: str 1472 - The name of the company who owns the security 1473 delta: int 1474 - The change in ranking from the last data point, first will be null 1475 """ 1476 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 1477 return client.getRankingsForAllDates(portfolio_id) 1478 1479 1480def createSignalsModel( 1481 apikey, upload_data, model_name="SignalsUploadModel", proxy=None, disable_verify_ssl=False 1482): 1483 """ 1484 Create a new model with uploaded signals. The model may take a while to 1485 process asynchronously after this method returns. 1486 1487 Parameters 1488 ---------- 1489 apikey: str 1490 API key provided by Boosted. This key should be protected as a secret. 1491 upload_data: pandas.DataFrame 1492 Pandas DataFrame containing your data. The index must be 1493 DatetimeIndex. The first columns must be ISIN, Country, Currency by 1494 default. The remaining column must be the weight. 1495 model_name: str 1496 Name for this model. 1497 proxy: str 1498 Your organization may require the use of a proxy for access. 1499 The address of a HTTPS proxy in the format of <address>:<port>. 1500 Examples are "123.456.789:123" or "my.proxy.com:123". 1501 Do not prepend with "https://". 1502 disable_verify_ssl: bool 1503 Your networking setup may be behind a firewall which performs SSL 1504 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 1505 to point to the location of a custom certificate bundle, or set this 1506 parameter to true to disable SSL verification as a workaround. 1507 1508 Returns 1509 ------- 1510 2-tuple 1511 str 1512 Model ID of the newly created model with uploaded signals. 1513 list of str 1514 Warnings incurred while uploading the allocations data. 1515 """ 1516 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 1517 return client.createSignalsModel(upload_data, model_name) 1518 1519 1520def addSignalsToUploadedModel( 1521 apikey, 1522 model_id, 1523 upload_data, 1524 proxy=None, 1525 disable_verify_ssl=False, 1526 recalc_all=False, 1527 recalc_portfolio_ids=None, 1528): 1529 """ 1530 Add allocations to a previously created uploaded model, then update the most recently accessed 1531 portfolio in the model, or update based on the recalc_all/recalc_portfolio_ids parameters. 1532 The model may take a while to process asynchronously after this method returns. 1533 1534 Parameters 1535 ---------- 1536 apikey: str 1537 API key provided by Boosted. This key should be protected as a secret. 1538 model_id: str 1539 Model ID. Model IDs can be retrieved by clicking on the copy to clipboard 1540 button next to your model's name in the Model Summary Page in Boosted 1541 Insights. 1542 upload_data: pandas.DataFrame 1543 Pandas DataFrame containing your data. The index must be 1544 DatetimeIndex. The first columns must be ISIN, Country, Currency by 1545 default. The remaining column must be the weight. 1546 proxy: str 1547 Your organization may require the use of a proxy for access. 1548 The address of a HTTPS proxy in the format of <address>:<port>. 1549 Examples are "123.456.789:123" or "my.proxy.com:123". 1550 Do not prepend with "https://". 1551 disable_verify_ssl: bool 1552 Your networking setup may be behind a firewall which performs SSL 1553 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 1554 to point to the location of a custom certificate bundle, or set this 1555 parameter to true to disable SSL verification as a workaround. 1556 recalc_all: bool 1557 Set to True to recalculate all portfolios under the model after uploading the allocations. 1558 Otherwise if not set to True, the most recently-accessed portfolio in the model is updated, 1559 or if provided, the list of portfolios provided in recalc_portfolio_ids will be updated. 1560 recalc_portfolio_ids: List[str] 1561 Specify a list of portfolio IDs to recalculate after uploading the allocations. 1562 Portfolio IDs can be retrieved from portfolio's configuration page. 1563 1564 Returns 1565 ------- 1566 list of str 1567 Warnings incurred while uploading the allocations data. 1568 """ 1569 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 1570 return client.addSignalsToUploadedModel( 1571 model_id, upload_data, recalc_all=recalc_all, recalc_portfolio_ids=recalc_portfolio_ids 1572 ) 1573 1574 1575def getSignalsFromUploadedModelForDate( 1576 apikey, model_id, date=datetime.date.today(), proxy=None, disable_verify_ssl=False 1577): 1578 """ 1579 Retrieve uploaded signal information for a uploaded model for one date. 1580 1581 Parameters 1582 ---------- 1583 apikey: str 1584 API key provided by Boosted. This key should be protected as a secret. 1585 model_id: str 1586 Model ID. Model IDs can be retrieved by clicking on the copy to clipboard 1587 button next to your model's name in the Model Summary Page in Boosted 1588 Insights. 1589 date: datetime.date or YYYY-MM-DD string 1590 Date of the universe to retrieve. 1591 proxy: str 1592 Your organization may require the use of a proxy for access. 1593 The address of a HTTPS proxy in the format of <address>:<port>. 1594 Examples are "123.456.789:123" or "my.proxy.com:123". 1595 Do not prepend with "https://". 1596 disable_verify_ssl: bool 1597 Your networking setup may be behind a firewall which performs SSL 1598 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 1599 to point to the location of a custom certificate bundle, or set this 1600 parameter to true to disable SSL verification as a workaround. 1601 1602 Returns 1603 ------- 1604 List of signal information 1605 date: str 1606 - Date string in yyyy/mm/dd format of date requested 1607 isin: str 1608 - The International Securities Identification Number of the security 1609 country: str 1610 - Three character country code 1611 currency: str 1612 - The currency short length code 1613 weight: float 1614 - signal value 1615 """ 1616 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 1617 return client.getSignalsFromUploadedModel(model_id, date) 1618 1619 1620def getSignalsFromUploadedModelForAllDates(apikey, model_id, proxy=None, disable_verify_ssl=False): 1621 """ 1622 Retrieve uploaded signal information for a uploaded model for all dates. 1623 1624 Parameters 1625 ---------- 1626 apikey: str 1627 API key provided by Boosted. This key should be protected as a secret. 1628 model_id: str 1629 Model ID. Model IDs can be retrieved by clicking on the copy to clipboard 1630 button next to your model's name in the Model Summary Page in Boosted 1631 Insights. 1632 proxy: str 1633 Your organization may require the use of a proxy for access. 1634 The address of a HTTPS proxy in the format of <address>:<port>. 1635 Examples are "123.456.789:123" or "my.proxy.com:123". 1636 Do not prepend with "https://". 1637 disable_verify_ssl: bool 1638 Your networking setup may be behind a firewall which performs SSL 1639 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 1640 to point to the location of a custom certificate bundle, or set this 1641 parameter to true to disable SSL verification as a workaround. 1642 1643 Returns 1644 ------- 1645 List of signal information 1646 date: str 1647 - Date string in yyyy/mm/dd format of date requested 1648 isin: str 1649 - The International Securities Identification Number of the security 1650 country: str 1651 - Three character country code 1652 currency: str 1653 - The currency short length code 1654 weight: float 1655 - signal value 1656 """ 1657 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 1658 return client.getSignalsFromUploadedModel(model_id) 1659 1660 1661def createPortfolioWithPortfolioSettings( 1662 apikey, 1663 model_id, 1664 portfolio_name, 1665 portfolio_description, 1666 portfolio_settings, 1667 proxy=None, 1668 disable_verify_ssl=False, 1669): 1670 """ 1671 Create a portfolio for a model, based on provided portfolio settings. 1672 Specific portfolio settings will fall back to defaults if not provided, and 1673 no two portfolios on the same model may have the exact same set of settings. 1674 Unspecified portfolio settings keys will be defaulted to their model default values. 1675 The portfolio will be asynchronously processed/recalculated and will be available within 1676 5-10 minutes. 1677 1678 Parameters 1679 ---------- 1680 apikey: str 1681 API key provided by Boosted. This key should be protected as a secret. 1682 model_id: str 1683 Model ID. Model IDs can be retrieved by clicking on the copy to clipboard 1684 button next to your model's name in the Model Summary Page in Boosted 1685 Insights. 1686 portfolio_name: str 1687 Name of the new portfolio. Must be <= 20 characters. 1688 portfolio_description: str 1689 Description for the new portfolio. Must be <= 100 characters. 1690 portfolio_settings: boosted.api.api_type.PortfolioSettings 1691 A pre-configured PortfolioSettings dict. 1692 proxy: str 1693 Your organization may require the use of a proxy for access. 1694 The address of a HTTPS proxy in the format of <address>:<port>. 1695 Examples are "123.456.789:123" or "my.proxy.com:123". 1696 Do not prepend with "https://". 1697 disable_verify_ssl: bool 1698 Your networking setup may be behind a firewall which performs SSL 1699 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 1700 to point to the location of a custom certificate bundle, or set this 1701 parameter to true to disable SSL verification as a workaround. 1702 1703 Returns 1704 ------- 1705 str 1706 Portfolio ID of the newly created portfolio. 1707 """ 1708 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 1709 return client.createPortfolioWithPortfolioSettings( 1710 model_id, portfolio_name, portfolio_description, portfolio_settings 1711 ) 1712 1713 1714def getPortfolioSettings(apikey, portfolio_id, proxy=None, disable_verify_ssl=False): 1715 """ 1716 Retrieve portfolio settings from an existing portfolio. The result can be modified and 1717 reused to create a new portfolio. The set of returned portfolio settings are limited 1718 to a view of ones editable as documented in `boosted.api.api_type.PortfolioSettings` only. 1719 1720 Parameters 1721 ---------- 1722 apikey: str 1723 API key provided by Boosted. This key should be protected as a secret. 1724 portfolio_id: str 1725 Portfolio ID. Portfolio IDs can be retrieved from portfolio's configuration page. 1726 proxy: str 1727 Your organization may require the use of a proxy for access. 1728 The address of a HTTPS proxy in the format of <address>:<port>. 1729 Examples are "123.456.789:123" or "my.proxy.com:123". 1730 Do not prepend with "https://". 1731 disable_verify_ssl: bool 1732 Your networking setup may be behind a firewall which performs SSL 1733 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 1734 to point to the location of a custom certificate bundle, or set this 1735 parameter to true to disable SSL verification as a workaround. 1736 1737 Returns 1738 ------- 1739 boosted.api.api_type.PortfolioSettings 1740 A PortfolioSettings can be used to create a new portfolio. 1741 """ 1742 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 1743 return client.getPortfolioSettings(portfolio_id) 1744 1745 1746def getGbiIdFromIsinCountryCurrencyDate( 1747 apikey, isin_country_currency_dates, proxy=None, disable_verify_ssl=False 1748): 1749 """ 1750 Get the gbi securities from a isin, country, currency, date combinations 1751 1752 Parameters 1753 ---------- 1754 apikey: str 1755 API key provided by Boosted. This key should be protected as a secret. 1756 isin_country_currency_dates: list of IsinCountryCurrencyDate 1757 An array of IsinCountryCurrencyDate 1758 proxy: str 1759 Your organization may require the use of a proxy for access. 1760 The address of a HTTPS proxy in the format of <address>:<port>. 1761 Examples are "123.456.789:123" or "my.proxy.com:123". 1762 Do not prepend with "https://". 1763 disable_verify_ssl: bool 1764 Your networking setup may be behind a firewall which performs SSL 1765 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 1766 to point to the location of a custom certificate bundle, or set this 1767 parameter to true to disable SSL verification as a workaround. 1768 1769 Returns 1770 ------- 1771 list of GbiIdSecurity 1772 The corresponding gbi id securities 1773 """ 1774 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 1775 return client.getGbiIdFromIsinCountryCurrencyDate(isin_country_currency_dates) 1776 1777 1778def getDatasetDates(apikey, dataset_id, proxy=None, disable_verify_ssl=False): 1779 """ 1780 Gets the valid to and valid from dates of the given dataset id 1781 1782 Parameters 1783 ---------- 1784 apikey: str 1785 API key provided by Boosted. This key should be protected as a secret. 1786 dataset_id: str 1787 Dataset ID. Can be from the output of addDependentDataset or be found 1788 in your Custom Data listing in Boosted Insights. 1789 proxy: str 1790 Your organization may require the use of a proxy for access. 1791 The address of a HTTPS proxy in the format of <address>:<port>. 1792 Examples are "123.456.789:123" or "my.proxy.com:123". 1793 Do not prepend with "https://". 1794 disable_verify_ssl: bool 1795 Your networking setup may be behind a firewall which performs SSL 1796 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 1797 to point to the location of a custom certificate bundle, or set this 1798 parameter to true to disable SSL verification as a workaround. 1799 1800 Returns 1801 ------- 1802 dict: 1803 Dictionary containing the valid to and from dates of the dataset 1804 { 1805 'validFrom': datetime.date, 1806 'validTo': datetime.date 1807 } 1808 ___ 1809 """ 1810 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 1811 return client.getDatasetDates(dataset_id) 1812 1813 1814def getRankingAnalysis(apikey, model_id, date, proxy=None, disable_verify_ssl=False): 1815 """ 1816 Gets the ranking 2.0 analysis data for the given model on the given date 1817 1818 Parameters 1819 ---------- 1820 apikey: str 1821 API key provided by Boosted. This key should be protected as a secret. 1822 model_id: str 1823 Model ID. Model IDs can be retrieved by clicking on the copy to clipboard 1824 button next to your model's name in the Model Summary Page in Boosted 1825 Insights. 1826 date: datetime.date or YYYY-MM-DD string 1827 Date of the data to retrieve. 1828 proxy: str 1829 Your organization may require the use of a proxy for access. 1830 The address of a HTTPS proxy in the format of <address>:<port>. 1831 Examples are "123.456.789:123" or "my.proxy.com:123". 1832 Do not prepend with "https://". 1833 disable_verify_ssl: bool 1834 Your networking setup may be behind a firewall which performs SSL 1835 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 1836 to point to the location of a custom certificate bundle, or set this 1837 parameter to true to disable SSL verification as a workaround. 1838 1839 Returns 1840 ------- 1841 pandas.DataFrame 1842 Pandas DataFrame containing your data indexed by data buckets and feature names. 1843 ___ 1844 """ 1845 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 1846 return client.getRankingAnalysis(model_id, date) 1847 1848 1849def getRankingExplain( 1850 apikey, model_id, date, proxy=None, disable_verify_ssl=False, index_by_symbol: bool = False 1851): 1852 """ 1853 Gets the ranking 2.0 explain data for the given model on the given date 1854 1855 Parameters 1856 ---------- 1857 apikey: str 1858 API key provided by Boosted. This key should be protected as a secret. 1859 model_id: str 1860 Model ID. Model IDs can be retrieved by clicking on the copy to clipboard 1861 button next to your model's name in the Model Summary Page in Boosted 1862 Insights. 1863 date: datetime.date or YYYY-MM-DD string 1864 Date of the data to retrieve. 1865 proxy: str 1866 Your organization may require the use of a proxy for access. 1867 The address of a HTTPS proxy in the format of <address>:<port>. 1868 Examples are "123.456.789:123" or "my.proxy.com:123". 1869 Do not prepend with "https://". 1870 disable_verify_ssl: bool 1871 Your networking setup may be behind a firewall which performs SSL 1872 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 1873 to point to the location of a custom certificate bundle, or set this 1874 parameter to true to disable SSL verification as a workaround. 1875 index_by_symbol: bool 1876 If true, index by stock symbol instead of ISIN. 1877 1878 Returns 1879 ------- 1880 pandas.DataFrame 1881 Pandas DataFrame containing your data indexed by ISINs/Symbol and feature names. 1882 ___ 1883 """ 1884 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 1885 return client.getRankingExplain(model_id, date, index_by_symbol=index_by_symbol) 1886 1887 1888def getDenseSignals( 1889 apikey, 1890 model_id, 1891 portfolio_id, 1892 file_name=None, 1893 location="./", 1894 proxy=None, 1895 disable_verify_ssl=False, 1896): 1897 """ 1898 Downloads the dense signal csv for the provided portfolio and model 1899 1900 Parameters 1901 ---------- 1902 apikey: str 1903 API key provided by Boosted. This key should be protected as a secret. 1904 model_id: str 1905 Model ID. Model IDs can be retrieved by clicking on the copy to clipboard 1906 button next to your model's name in the Model Summary Page in Boosted 1907 Insights. 1908 portfolio_id: str 1909 Portfolio ID. Portfolio IDs can be retrieved from portfolio's configuration page. 1910 file_name: str 1911 File name of the dense signals file to save as. 1912 If no file name is given the file name will be "<model_id>-<portfolio_id>_dense_signals.csv" 1913 location: str 1914 The location to save the file to. 1915 If no location is given then it will be saved to the current directory. 1916 proxy: str 1917 Your organization may require the use of a proxy for access. 1918 The address of a HTTPS proxy in the format of <address>:<port>. 1919 Examples are "123.456.789:123" or "my.proxy.com:123". 1920 Do not prepend with "https://". 1921 disable_verify_ssl: bool 1922 Your networking setup may be behind a firewall which performs SSL 1923 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 1924 to point to the location of a custom certificate bundle, or set this 1925 parameter to true to disable SSL verification as a workaround. 1926 1927 Returns 1928 ------- 1929 None 1930 ___ 1931 """ 1932 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 1933 return client.getDenseSignals(model_id, portfolio_id, file_name, location) 1934 1935 1936def getRanking2DateAnalysisFile( 1937 apikey, 1938 model_id, 1939 portfolio_id, 1940 date, 1941 file_name=None, 1942 location="./", 1943 proxy=None, 1944 disable_verify_ssl=False, 1945): 1946 """ 1947 Downloads the ranking analysis file for the provied portfolio and model. 1948 If no file exist then it will send a request to generate the file and continuously 1949 poll the server every 5 seconds to try and download the file until the file is downloaded. 1950 1951 Parameters 1952 ---------- 1953 apikey: str 1954 API key provided by Boosted. This key should be protected as a secret. 1955 model_id: str 1956 Model ID. Model IDs can be retrieved by clicking on the copy to clipboard 1957 button next to your model's name in the Model Summary Page in Boosted 1958 Insights. 1959 portfolio_id: str 1960 Portfolio ID. Portfolio IDs can be retrieved from portfolio's configuration page. 1961 date: datetime.date or YYYY-MM-DD string 1962 Date of the data to retrieve. 1963 file_name: str 1964 File name of the dense signals file to save as. 1965 If no file name is given the file name will be 1966 "<model_id>-<portfolio_id>_statistical_analysis_<date>.xlsx" 1967 location: str 1968 The location to save the file to. 1969 If no location is given then it will be saved to the current directory. 1970 proxy: str 1971 Your organization may require the use of a proxy for access. 1972 The address of a HTTPS proxy in the format of <address>:<port>. 1973 Examples are "123.456.789:123" or "my.proxy.com:123". 1974 Do not prepend with "https://". 1975 disable_verify_ssl: bool 1976 Your networking setup may be behind a firewall which performs SSL 1977 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 1978 to point to the location of a custom certificate bundle, or set this 1979 parameter to true to disable SSL verification as a workaround. 1980 1981 Returns 1982 ------- 1983 None 1984 ___ 1985 """ 1986 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 1987 return client.getRanking2DateAnalysisFile(model_id, portfolio_id, date, file_name, location) 1988 1989 1990def getRanking2DateExplainFile( 1991 apikey, 1992 model_id, 1993 portfolio_id, 1994 date, 1995 file_name=None, 1996 location="./", 1997 proxy=None, 1998 disable_verify_ssl=False, 1999 overwrite: bool = False, 2000): 2001 """ 2002 Downloads the ranking explain file for the provied portfolio and model. 2003 If no file exist then it will send a request to generate the file and continuously 2004 poll the server every 5 seconds to try and download the file until the file is downloaded. 2005 2006 Parameters 2007 ---------- 2008 apikey: str 2009 API key provided by Boosted. This key should be protected as a secret. 2010 model_id: str 2011 Model ID. Model IDs can be retrieved by clicking on the copy to clipboard 2012 button next to your model's name in the Model Summary Page in Boosted 2013 Insights. 2014 portfolio_id: str 2015 Portfolio ID. Portfolio IDs can be retrieved from portfolio's configuration page. 2016 date: datetime.date or YYYY-MM-DD string 2017 Date of the data to retrieve. 2018 file_name: str 2019 File name of the dense signals file to save as. 2020 If no file name is given the file name will be 2021 "<model_id>-<portfolio_id>_explain_data_<date>.xlsx" 2022 location: str 2023 The location to save the file to. 2024 If no location is given then it will be saved to the current directory. 2025 proxy: str 2026 Your organization may require the use of a proxy for access. 2027 The address of a HTTPS proxy in the format of <address>:<port>. 2028 Examples are "123.456.789:123" or "my.proxy.com:123". 2029 Do not prepend with "https://". 2030 disable_verify_ssl: bool 2031 Your networking setup may be behind a firewall which performs SSL 2032 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 2033 to point to the location of a custom certificate bundle, or set this 2034 parameter to true to disable SSL verification as a workaround. 2035 overwrite: bool 2036 Defaults to False, set to True to regenerate the file. 2037 2038 Returns 2039 ------- 2040 None 2041 ___ 2042 """ 2043 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 2044 return client.getRanking2DateExplainFile( 2045 model_id, portfolio_id, date, file_name, location, overwrite 2046 ) 2047 2048 2049def getRanking2DateExplain( 2050 apikey: str, 2051 model_id: str, 2052 portfolio_id: str, 2053 date: BoostedDate, 2054 overwrite: bool = False, 2055 proxy: Optional[str] = None, 2056 disable_verify_ssl: bool = False, 2057) -> Dict[str, pd.DataFrame]: 2058 """ 2059 Downloads the ranking explain file for the provied portfolio and model and 2060 loads it into a dict of pandas dataframes. If no file exists then it will 2061 send a request to generate the file and continuously poll the server every 5 2062 seconds to try and download the file until the file is downlodded. 2063 2064 Parameters 2065 ---------- 2066 apikey: str 2067 API key provided by Boosted. This key should be protected as a secret. 2068 model_id: str 2069 Model ID. Model IDs can be retrieved by clicking on the copy to clipboard 2070 button next to your model's name in the Model Summary Page in Boosted 2071 Insights. 2072 portfolio_id: str 2073 Portfolio ID. Portfolio IDs can be retrieved from portfolio's configuration page. 2074 date: datetime.date or YYYY-MM-DD string 2075 Date of the data to retrieve. 2076 overwrite: bool 2077 Defaults to False, set to True to regenerate the file. 2078 proxy: str 2079 Your organization may require the use of a proxy for access. 2080 The address of a HTTPS proxy in the format of <address>:<port>. 2081 Examples are "123.456.789:123" or "my.proxy.com:123". 2082 Do not prepend with "https://". 2083 disable_verify_ssl: bool 2084 Your networking setup may be behind a firewall which performs SSL 2085 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 2086 to point to the location of a custom certificate bundle, or set this 2087 parameter to true to disable SSL verification as a workaround. 2088 2089 Returns 2090 ------- 2091 A dict with excel sheet names as keys, and Pandas dataframe, indexed by 2092 symbol, as values. 2093 ___ 2094 """ 2095 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 2096 return client.getRanking2DateExplain(model_id, portfolio_id, convert_date(date), overwrite) 2097 2098 2099def getTearSheet( 2100 apikey, 2101 model_id, 2102 portfolio_id, 2103 proxy=None, 2104 disable_verify_ssl=False, 2105 start_date=None, 2106 end_date=None, 2107 block=False, 2108): 2109 """ 2110 Gets the model and portfolio's tear sheet and returns it as a list of tear sheet groups 2111 2112 Parameters 2113 ---------- 2114 apikey: str 2115 API key provided by Boosted. This key should be protected as a secret. 2116 model_id: str 2117 Model ID. Model IDs can be retrieved by clicking on the copy to clipboard 2118 button next to your model's name in the Model Summary Page in Boosted 2119 Insights. 2120 portfolio_id: str 2121 Portfolio ID. Portfolio IDs can be retrieved from portfolio's configuration page. 2122 start_date: str or None 2123 Start date for the range of data represented by the tear sheet (YYYY-MM-DD) 2124 end_date: str or None 2125 End date for the range of data represented by the tear sheet (YYYY-MM-DD) 2126 Must be None if and only if start_date is None 2127 block: bool 2128 Whether or not to wait for the data to be ready. No effect if dates are not 2129 provided 2130 Returns 2131 ------- 2132 List 2133 Each element in the list represents a group in the tearsheet. i.e Risk Adjusted Returns 2134 Each dictionary is made of member which is a list of dicts representing a tearsheet 2135 value and a group name which is the name of the group shown on screen. Each dict in 2136 the member array has value which is a floating point number, type which is either 2137 "number" or "precent" to determine if value is a raw number or a percentage value, 2138 and finally "name" which is the name shown on screen. 2139 [ 2140 { 2141 members: [ 2142 { 2143 "value": float, 2144 "type": str, 2145 "name": str 2146 }, 2147 ], 2148 group_name: str 2149 }, 2150 ] 2151 ___ 2152 """ 2153 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 2154 return client.getTearSheet( 2155 model_id, portfolio_id, start_date=start_date, end_date=end_date, block=block 2156 ) 2157 2158 2159def getPortfolioStatus( 2160 apikey, 2161 model_id, 2162 portfolio_id, 2163 job_date, 2164 proxy=None, 2165 disable_verify_ssl=False, 2166): 2167 """ 2168 Gets the update status of a portfolio 2169 2170 Parameters 2171 ---------- 2172 model_id: str 2173 The id of the model the portfolio belongs to 2174 portfolio_id: str 2175 The id of the portfolio 2176 job_date: str 2177 The date in question, in YYYY-MM-DD format 2178 Returns 2179 ------- 2180 dict with properties 2181 is_complete: bool 2182 True if the calculation for the date has been completed 2183 last_update: str 2184 The most recent date with a completed calculation 2185 next_update: str 2186 The earliest date (in the future) with an incomplete calculation 2187 ___ 2188 """ 2189 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 2190 return client.getPortfolioStatus(model_id, portfolio_id, job_date) 2191 2192 2193def getBlacklist( 2194 apikey, 2195 blacklist_id, 2196 proxy=None, 2197 disable_verify_ssl=False, 2198): 2199 """ 2200 Gets blacklist with provided id. You must have access to the blacklist. 2201 2202 Parameters 2203 ---------- 2204 blacklist_id: int 2205 Blacklist ID. Blacklist ID can be found by running getBlacklists, or 2206 when you create a blacklist the ID of the created blacklist will be shown. 2207 2208 Returns 2209 ------- 2210 Blacklist 2211 ___ 2212 """ 2213 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 2214 return client.getBlacklist(blacklist_id) 2215 2216 2217def getBlacklists( 2218 apikey, 2219 model_id=None, 2220 company_id=None, 2221 last_N=None, 2222 proxy=None, 2223 disable_verify_ssl=False, 2224): 2225 """ 2226 Gets the list of blacklists with provided company_id or model_id. If last_N is provided, 2227 the list will return N most recently created blacklists. If no parameter is provided, 2228 the list of user company's blacklists will be returned. 2229 Note that when company_id is provided, blacklists will be returned if you have access 2230 to their model, if they are model specified. 2231 company_id and model_id cannot both be provided. 2232 2233 Parameters 2234 ---------- 2235 model_id: str 2236 Model ID. Model IDs can be retrieved by clicking on the copy to clipboard 2237 button next to your model's name in the Model Summary Page in Boosted 2238 Insights. You must have access to the model. 2239 company_id: str 2240 Company ID. Used by administrators to access blacklists from the given company. 2241 last_N: int 2242 N most recently created blacklists to return 2243 2244 Returns 2245 ------- 2246 list of Blacklists 2247 ___ 2248 """ 2249 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 2250 return client.getBlacklists(model_id=model_id, company_id=company_id, last_N=last_N) 2251 2252 2253def createBlacklist( 2254 apikey, 2255 isin, 2256 long_short=2, 2257 start_date=datetime.date.today(), 2258 end_date="4000-01-01", 2259 model_id=None, 2260 proxy=None, 2261 disable_verify_ssl=False, 2262): 2263 """ 2264 Creates a blacklist with ISIN, long_short, start_date and end_date. If model_id is given, 2265 the blacklist will be set for the given model. long_short will default to 2, 2266 start_date will default to today, and end_date will default to 4000-01-01, 2267 unless they are provided. 2268 2269 Parameters 2270 ---------- 2271 isin: string 2272 ISIN of the blacklist to be created 2273 long_short: int 2274 -1: short blacklist only 1: long blacklist only 2: both 2275 start_date: string 2276 The created blacklist will take effect from start_date. 2277 end_date: string 2278 The created blacklist will take effect until end_date. 2279 model_id: str 2280 Model ID. Model IDs can be retrieved by clicking on the copy to clipboard 2281 button next to your model's name in the Model Summary Page in Boosted 2282 Insights. You must have access to the model. 2283 2284 Returns 2285 ------- 2286 Blacklist 2287 ___ 2288 """ 2289 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 2290 return client.createBlacklist( 2291 isin, long_short=long_short, start_date=start_date, end_date=end_date, model_id=model_id 2292 ) 2293 2294 2295def createBlacklistsFromCSV(apikey, csv_name, proxy=None, disable_verify_ssl=False): 2296 """ 2297 Creates blacklists from a csv. CSV must have the following header: 2298 ModelID, ISIN, LongShort, StartDate, EndDate 2299 where StartDate and EndDate are in the form of YYYY-MM-DD 2300 For more information and default behaviours, please refer to createBlacklist. 2301 2302 Parameters 2303 ---------- 2304 csv_name: string 2305 Name of the csv containing blacklists. Csv must be located in the same directory. 2306 2307 Returns 2308 ------- 2309 Blacklists 2310 ___ 2311 """ 2312 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 2313 return client.createBlacklistsFromCSV(csv_name) 2314 2315 2316def updateBlacklist( 2317 apikey, 2318 blacklist_id, 2319 long_short=None, 2320 start_date=None, 2321 end_date=None, 2322 proxy=None, 2323 disable_verify_ssl=False, 2324): 2325 """ 2326 Updates the blacklist with given id. You must have access to the blacklist. 2327 long_short, start_date and end_date are all optional. 2328 2329 Parameters 2330 ---------- 2331 blacklist_id: int 2332 Blacklist ID. Blacklist ID can be found by running getBlacklists, 2333 or when you create a blacklist the ID of the created blacklist will be shown. 2334 long_short: int 2335 -1: short blacklist only 1: long blacklist only 2: both 2336 start_date: string 2337 The created blacklist will take effect from start_date. 2338 end_date: string 2339 The created blacklist will take effect until end_date. 2340 2341 Returns 2342 ------- 2343 Blacklist 2344 ___ 2345 """ 2346 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 2347 return client.updateBlacklist( 2348 blacklist_id, long_short=long_short, start_date=start_date, end_date=end_date 2349 ) 2350 2351 2352def deleteBlacklist( 2353 apikey, 2354 blacklist_id, 2355 proxy=None, 2356 disable_verify_ssl=False, 2357): 2358 """ 2359 Deletes the blacklist with given id. You must have access to the blacklist. 2360 2361 Parameters 2362 ---------- 2363 blacklist_id: int 2364 Blacklist ID. Blacklist ID can be found by running getBlacklists, 2365 or when you create a blacklist the ID of the created blacklist will be shown. 2366 2367 Returns 2368 ------- 2369 Boolean, denoting the success of deletion 2370 ___ 2371 """ 2372 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 2373 return client.deleteBlacklist(blacklist_id) 2374 2375 2376def getFeatureImportance(apikey, model_id, date, N=None, proxy=None, disable_verify_ssl=False): 2377 """ 2378 Gets the top N features for the given model sorted in descending order of importance 2379 2380 Parameters 2381 ---------- 2382 apikey: str 2383 API key provided by Boosted. This key should be protected as a secret. 2384 model_id: str 2385 Model ID. Model IDs can be retrieved by clicking on the copy to clipboard 2386 button next to your model's name in the Model Summary Page in Boosted 2387 Insights. 2388 date: datetime.date or YYYY-MM-DD string 2389 Date for the period for which features should be fetched. The resulting features 2390 are fetched for the period the date falls into. E.g. if the date is 2021-11-21 for the 2391 annual model, the features will be provided for the period of 2021-01-01 - 2021-12-31. 2392 N: int 2393 Limit for the number of top features to be returned. If not provided, the entire list 2394 of features will be returned. 2395 proxy: str 2396 Your organization may require the use of a proxy for access. 2397 The address of a HTTPS proxy in the format of <address>:<port>. 2398 Examples are "123.456.789:123" or "my.proxy.com:123". 2399 Do not prepend with "https://". 2400 disable_verify_ssl: bool 2401 Your networking setup may be behind a firewall which performs SSL 2402 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 2403 to point to the location of a custom certificate bundle, or set this 2404 parameter to true to disable SSL verification as a workaround. 2405 Returns 2406 ------- 2407 pandas.DataFrame 2408 Pandas DataFrame containing features and their importance 2409 ___ 2410 """ 2411 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 2412 return client.getFeatureImportance(model_id, date, N) 2413 2414 2415def getAllModelNames( 2416 apikey: str, proxy: Optional[str] = None, disable_verify_ssl: bool = False 2417) -> Dict[str, str]: 2418 """ 2419 Gets the model names for all models the user has access to. 2420 Parameters 2421 ---------- 2422 apikey: str 2423 API key provided by Boosted. This key should be protected as a secret. 2424 proxy: Optional[str] 2425 Your organization may require the use of a proxy for access. 2426 The address of a HTTPS proxy in the format of <address>:<port>. 2427 Examples are "123.456.789:123" or "my.proxy.com:123". 2428 Do not prepend with "https://". 2429 disable_verify_ssl: bool = False 2430 Your networking setup may be behind a firewall which performs SSL 2431 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 2432 to point to the location of a custom certificate bundle, or set this 2433 parameter to true to disable SSL verification as a workaround. 2434 Returns 2435 ------- 2436 dict: 2437 Dictionary mapping model id to model name. 2438 """ 2439 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 2440 return client.getAllModelNames() 2441 2442 2443def getAllModelDetails( 2444 apikey: str, proxy: Optional[str] = None, disable_verify_ssl: bool = False 2445) -> Dict[str, Dict[str, Any]]: 2446 """ 2447 Gets the model name, model id, last update time, and associated portfolio 2448 ids for all models the user has access to. 2449 Parameters 2450 ---------- 2451 apikey: str 2452 API key provided by Boosted. This key should be protected as a secret. 2453 proxy: Optional[str] 2454 Your organization may require the use of a proxy for access. 2455 The address of a HTTPS proxy in the format of <address>:<port>. 2456 Examples are "123.456.789:123" or "my.proxy.com:123". 2457 Do not prepend with "https://". 2458 disable_verify_ssl: bool = False 2459 Your networking setup may be behind a firewall which performs SSL 2460 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 2461 to point to the location of a custom certificate bundle, or set this 2462 parameter to true to disable SSL verification as a workaround. 2463 Returns 2464 ------- 2465 Dictionary keyed by model id mapping to nested dictionary with the following values: 2466 portfolios: List[Dict[str, str]] 2467 List of portfolio associated with the model. Each portfolio is a dict 2468 with keys "id" and "name". 2469 name: str 2470 Model name. 2471 last_updated: datetime 2472 Last updated time of the model. 2473 """ 2474 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 2475 return client.getAllModelDetails() 2476 2477 2478def getEquityAccuracy( 2479 apikey: str, 2480 model_id: str, 2481 portfolio_id: str, 2482 tickers: List[str], 2483 start_date: Optional[BoostedDate] = None, 2484 end_date: Optional[BoostedDate] = None, 2485 proxy: Optional[str] = None, 2486 disable_verify_ssl: bool = False, 2487) -> Dict[str, Dict[str, Any]]: 2488 """ 2489 Retrieves accuracy data for a given portfolio and list of tickers. 2490 Parameters 2491 ---------- 2492 apikey: str 2493 API key provided by Boosted. This key should be protected as a secret. 2494 model_id: str 2495 Model ID. Model IDs can be retrieved by clicking on the copy to clipboard 2496 button next to your model's name in the Model Summary Page in Boosted 2497 Insights. 2498 portfolio_id: str 2499 Portfolio ID. Portfolio IDs can be retrieved from portfolio's configuration page. 2500 tickers: List[str] 2501 List of tickers to get accuracy information with. 2502 start_date: Optional[datetime | string]: 2503 Optional start date for data. If not specified, will default to the 2504 start date of the portfolio. 2505 end_date: Optional[datetime | string]: 2506 Optional end date for data. If not specified, will default to the 2507 end date of the portfolio. 2508 proxy: Optional[str] 2509 Your organization may require the use of a proxy for access. 2510 The address of a HTTPS proxy in the format of <address>:<port>. 2511 Examples are "123.456.789:123" or "my.proxy.com:123". 2512 Do not prepend with "https://". 2513 disable_verify_ssl: bool = False 2514 Your networking setup may be behind a firewall which performs SSL 2515 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 2516 to point to the location of a custom certificate bundle, or set this 2517 parameter to true to disable SSL verification as a workaround. 2518 Returns 2519 ------- 2520 Nested dictionary: 2521 { 2522 "ticker1": { 2523 "hit_rate_mean": pd.DataFrame, 2524 "hit_rate_median": pd.DataFrame, 2525 "excess_return_mean": pd.DataFrame, 2526 "excess_return_median": pd.DataFrame, 2527 "return": "Recalculate the portfolio to get raw returns", 2528 "excess_return": pd.DataFrame, 2529 }, 2530 "ticker2": { 2531 "hit_rate_mean": pd.DataFrame, 2532 "hit_rate_median": pd.DataFrame, 2533 "excess_return_mean": pd.DataFrame, 2534 "excess_return_median": pd.DataFrame, 2535 "return": pd.DataFrame, 2536 "excess_return": pd.DataFrame, 2537 }, 2538 ... 2539 } 2540 Each dataframe above has columns: 2541 1D, 5D, 1M, 3M, 6M, 1Y, 2Y 2542 And row indexes: 2543 Q1, Q2, Q3, Q4, Q5 2544 2545 Note that the value for 'return' may be a string instead of a dataframe in 2546 cases where the data is not currently available in the specified portfolio. 2547 """ 2548 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 2549 return client.getEquityAccuracy(model_id, portfolio_id, tickers, start_date, end_date) 2550 2551 2552def getHedgeExperiments( 2553 apikey: str, proxy: Optional[str] = None, disable_verify_ssl: bool = False 2554) -> List[HedgeExperiment]: 2555 """ 2556 Get a list of all hedge experiments. 2557 Parameters 2558 ---------- 2559 apikey: str 2560 API key provided by Boosted. This key should be protected as a secret. 2561 proxy: str 2562 Your organization may require the use of a proxy for access. 2563 The address of a HTTPS proxy in the format of <address>:<port>. 2564 Examples are "123.456.789:123" or "my.proxy.com:123". 2565 Do not prepend with "https://". 2566 disable_verify_ssl: bool 2567 Your networking setup may be behind a firewall which performs SSL 2568 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 2569 to point to the location of a custom certificate bundle, or set this 2570 parameter to true to disable SSL verification as a workaround. 2571 Returns 2572 ------- 2573 HedgeExperiment object 2574 Results of the hedge experiment. 2575 """ 2576 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 2577 return client.get_hedge_experiments() 2578 2579 2580def getHedgeExperimentDetails( 2581 apikey: str, 2582 experiment_id: str, 2583 proxy: Optional[str] = None, 2584 disable_verify_ssl: bool = False, 2585) -> HedgeExperimentDetails: 2586 """ 2587 Get the details of a specific hedge experiment, as a HedgeExperiement object 2588 Parameters 2589 ---------- 2590 apikey: str 2591 API key provided by Boosted. This key should be protected as a secret. 2592 experiment_id: str 2593 UUID corresponding to the hedge experiment in question. 2594 proxy: str 2595 Your organization may require the use of a proxy for access. 2596 The address of a HTTPS proxy in the format of <address>:<port>. 2597 Examples are "123.456.789:123" or "my.proxy.com:123". 2598 Do not prepend with "https://". 2599 disable_verify_ssl: bool 2600 Your networking setup may be behind a firewall which performs SSL 2601 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 2602 to point to the location of a custom certificate bundle, or set this 2603 parameter to true to disable SSL verification as a workaround. 2604 Returns 2605 ------- 2606 HedgeExperiment object 2607 Results of the hedge experiment. 2608 """ 2609 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 2610 return client.get_hedge_experiment_details(experiment_id) 2611 2612 2613def getPortfolioPerformance( 2614 apikey: str, 2615 portfolio_id: str, 2616 proxy: Optional[str] = None, 2617 disable_verify_ssl: bool = False, 2618) -> pd.DataFrame: 2619 """ 2620 Get performance data for a portfolio. 2621 2622 Parameters 2623 ---------- 2624 apikey: str 2625 API key provided by Boosted. This key should be protected as a secret. 2626 portfolio_id: str 2627 UUID corresponding to the portfolio in question. 2628 proxy: str 2629 Your organization may require the use of a proxy for access. 2630 The address of a HTTPS proxy in the format of <address>:<port>. 2631 Examples are "123.456.789:123" or "my.proxy.com:123". 2632 Do not prepend with "https://". 2633 disable_verify_ssl: bool 2634 Your networking setup may be behind a firewall which performs SSL 2635 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 2636 to point to the location of a custom certificate bundle, or set this 2637 parameter to true to disable SSL verification as a workaround. 2638 2639 Returns 2640 ------- 2641 pd.DataFrame object 2642 Portfolio and benchmark performance. 2643 -index: 2644 "date": pd.DatetimeIndex 2645 -columns: 2646 "benchmark": benchmark performance, % return 2647 "portfolio": portfolio performance, % return 2648 """ 2649 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 2650 return client.get_portfolio_performance(portfolio_id) 2651 2652 2653def getPortfolioFactors( 2654 apikey: str, 2655 model_id: str, 2656 portfolio_id: str, 2657 proxy: Optional[str] = None, 2658 disable_verify_ssl: bool = False, 2659) -> pd.DataFrame: 2660 """ 2661 Get factor data concerning a hedge experiment portfolio 2662 2663 Parameters 2664 ---------- 2665 apikey: str 2666 API key provided by Boosted. This key should be protected as a secret. 2667 model_id: str 2668 UUID corresponding to the model in question. 2669 portfolio_id: str 2670 UUID corresponding to the portfolio in question. 2671 proxy: str 2672 Your organization may require the use of a proxy for access. 2673 The address of a HTTPS proxy in the format of <address>:<port>. 2674 Examples are "123.456.789:123" or "my.proxy.com:123". 2675 Do not prepend with "https://". 2676 disable_verify_ssl: bool 2677 Your networking setup may be behind a firewall which performs SSL 2678 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 2679 to point to the location of a custom certificate bundle, or set this 2680 parameter to true to disable SSL verification as a workaround. 2681 2682 Returns 2683 ------- 2684 pd.DataFrame object 2685 - index: 2686 "date": pd.DatetimeIndex 2687 - columns: 2688 The following are factor weights corresponding to the named column. 2689 "size", 2690 "momentum", 2691 "dividend_yield", 2692 "volatility", 2693 "trading_activity", 2694 "value", 2695 "earnings_variability", 2696 "profitability", 2697 "growth", 2698 "leverage", 2699 "income_statement", 2700 "balance_sheet", 2701 "cash_flow", 2702 "environment", 2703 "social", 2704 "governance", 2705 "machine_1", 2706 "machine_2", 2707 "machine_3", 2708 "machine_4", 2709 "machine_5", 2710 "machine_6", 2711 "machine_7", 2712 "machine_8", 2713 "machine_9", 2714 "machine_10" 2715 """ 2716 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 2717 return client.get_portfolio_factors(model_id, portfolio_id) 2718 2719 2720def getPortfolioVolatility( 2721 apikey: str, 2722 model_id: str, 2723 portfolio_id: str, 2724 proxy: Optional[str] = None, 2725 disable_verify_ssl: bool = False, 2726) -> pd.DataFrame: 2727 """ 2728 Get volatility data concerning a hedge experiment portfolio 2729 2730 Parameters 2731 ---------- 2732 apikey: str 2733 API key provided by Boosted. This key should be protected as a secret. 2734 model_id: str 2735 UUID corresponding to the model in question. 2736 portfolio_id: str 2737 UUID corresponding to the portfolio in question. 2738 proxy: str 2739 Your organization may require the use of a proxy for access. 2740 The address of a HTTPS proxy in the format of <address>:<port>. 2741 Examples are "123.456.789:123" or "my.proxy.com:123". 2742 Do not prepend with "https://". 2743 disable_verify_ssl: bool 2744 Your networking setup may be behind a firewall which performs SSL 2745 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 2746 to point to the location of a custom certificate bundle, or set this 2747 parameter to true to disable SSL verification as a workaround. 2748 2749 Returns 2750 ------- 2751 pd.DataFrame object 2752 - index: 2753 "date": pd.DatetimeIndex 2754 - columns: 2755 "avg_5d", 2756 "avg_10d", 2757 "avg_21d", 2758 "avg_63d", 2759 "avg_126d", 2760 "avg_189d", 2761 "avg_252d", 2762 "avg_315d", 2763 "avg_378d", 2764 "avg_441d", 2765 "avg_504d" 2766 """ 2767 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 2768 return client.get_portfolio_volatility(model_id, portfolio_id) 2769 2770 2771def getPortfolioHoldings( 2772 apikey: str, 2773 model_id: str, 2774 portfolio_id: str, 2775 proxy: Optional[str] = None, 2776 disable_verify_ssl: bool = False, 2777) -> pd.DataFrame: 2778 """ 2779 Get holdings concerning a hedge experiment portfolio 2780 2781 Parameters 2782 ---------- 2783 apikey: str 2784 API key provided by Boosted. This key should be protected as a secret. 2785 model_id: str 2786 UUID corresponding to the model in question. 2787 portfolio_id: str 2788 UUID corresponding to the portfolio in question. 2789 proxy: str 2790 Your organization may require the use of a proxy for access. 2791 The address of a HTTPS proxy in the format of <address>:<port>. 2792 Examples are "123.456.789:123" or "my.proxy.com:123". 2793 Do not prepend with "https://". 2794 disable_verify_ssl: bool 2795 Your networking setup may be behind a firewall which performs SSL 2796 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 2797 to point to the location of a custom certificate bundle, or set this 2798 parameter to true to disable SSL verification as a workaround. 2799 2800 Returns 2801 ------- 2802 pd.DataFrame object 2803 - index: 2804 "date": pd.DatetimeIndex 2805 - columns: 2806 "ticker", 2807 "isin", 2808 "region", 2809 "currency", 2810 "allocation" 2811 """ 2812 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 2813 return client.get_portfolio_holdings(model_id, portfolio_id) 2814 2815 2816def getStockDataTableForDate( 2817 apikey: str, 2818 model_id: str, 2819 portfolio_id: str, 2820 date: BoostedDate = datetime.date.today(), 2821 proxy: Optional[str] = None, 2822 disable_verify_ssl: bool = False, 2823) -> pd.DataFrame: 2824 """ 2825 Returns stock pricing and factors data for a given date. 2826 2827 Parameters 2828 ---------- 2829 apikey: str 2830 API key provided by Boosted. This key should be protected as a secret. 2831 model_id: str 2832 Model ID. Model IDs can be retrieved by clicking on the copy to clipboard 2833 button next to your model's name in the Model Summary Page in Boosted 2834 Insights. 2835 portfolio_id: str 2836 Portfolio ID. Portfolio IDs can be retrieved from portfolio's configuration page. 2837 date: datetime.date | str 2838 Date for which to fetch stock data table. Defaults to today. 2839 proxy: str 2840 Your organization may require the use of a proxy for access. 2841 The address of a HTTPS proxy in the format of <address>:<port>. 2842 Examples are "123.456.789:123" or "my.proxy.com:123". 2843 Do not prepend with "https://". 2844 disable_verify_ssl: bool 2845 Your networking setup may be behind a firewall which performs SSL 2846 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 2847 to point to the location of a custom certificate bundle, or set this 2848 parameter to true to disable SSL verification as a workaround. 2849 2850 Returns 2851 ------- 2852 Stock data table as a dataframe indexed by ticker. 2853 """ 2854 date = convert_date(date) 2855 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 2856 return client.getStockDataTableForDate(model_id, portfolio_id, date) 2857 2858 2859def addHedgeExperimentScenario( 2860 apikey: str, 2861 experiment_id: str, 2862 scenario_name: str, 2863 scenario_settings: PortfolioSettings, 2864 run_scenario_immediately: bool = True, 2865 proxy: Optional[str] = None, 2866 disable_verify_ssl: bool = False, 2867) -> HedgeExperimentScenario: 2868 """ 2869 Create a hedge experiment scenario the Boosted platform. 2870 2871 Parameters 2872 ---------- 2873 apikey: str 2874 API key provided by Boosted. This key should be protected as a secret. 2875 experiment: HedgeExperiment 2876 An instance of the HedgeExperiment class that specifies 2877 your experiment configuration and metadata. 2878 run_scenario_immediately: Optional[bool] (default True) 2879 Flag that indicates whether to run the scenario upon submission or wait 2880 for a independent call to start the scenario at a later time. 2881 proxy: str 2882 Your organization may require the use of a proxy for access. 2883 The address of a HTTPS proxy in the format of <address>:<port>. 2884 Examples are "123.456.789:123" or "my.proxy.com:123". 2885 Do not prepend with "https://". 2886 disable_verify_ssl: bool 2887 Your networking setup may be behind a firewall which performs SSL 2888 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 2889 to point to the location of a custom certificate bundle, or set this 2890 parameter to true to disable SSL verification as a workaround. 2891 2892 Returns 2893 ------- 2894 HedgeExperimentScenario 2895 - A scenario instance with associated metadata 2896 """ 2897 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 2898 return client.add_hedge_experiment_scenario( 2899 experiment_id, scenario_name, scenario_settings, run_scenario_immediately 2900 ) 2901 2902 2903def createHedgeExperiment( 2904 apikey: str, 2905 experiment_name: str, 2906 experiment_description: str, 2907 experiment_type: hedge_experiment_type, 2908 target_securities: Union[Dict[GbiIdSecurity, float], str], 2909 proxy: Optional[str] = None, 2910 disable_verify_ssl: bool = False, 2911) -> HedgeExperiment: 2912 """ 2913 Creates a hedge experiment on the Boosted platform, returning an object 2914 representation of it. Note that currently this does NOT start the experiment; 2915 as created, the experiment is in an incomplete, draft state 2916 2917 Parameters 2918 ---------- 2919 apikey: str 2920 API key provided by Boosted. This key should be protected as a secret. 2921 experiment_name: str 2922 Name of the experiment 2923 experiment_description: str 2924 Your description of the experiment. 2925 experiment_type: str 2926 "HEDGE" - hedge out the risk of target securities 2927 "MIMIC" - mimic the target securities 2928 target_securities: Dict[GbiIdSecurity, float] | str 2929 Specification of securities to hedge or mimic as a weighted basket. This parameter 2930 can take the form of: 2931 {GbiIdSecurity: weight} - to manually specify securities and weights, OR 2932 portfolio_id - to use the most recent holdings/allocations of the passed 2933 portfolio as the securities and weights 2934 proxy: str 2935 Your organization may require the use of a proxy for access. 2936 The address of a HTTPS proxy in the format of <address>:<port>. 2937 Examples are "123.456.789:123" or "my.proxy.com:123". 2938 Do not prepend with "https://". 2939 disable_verify_ssl: bool 2940 Your networking setup may be behind a firewall which performs SSL 2941 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 2942 to point to the location of a custom certificate bundle, or set this 2943 parameter to true to disable SSL verification as a workaround. 2944 Returns 2945 ------- 2946 HedgeExperiment 2947 """ 2948 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 2949 return client.create_hedge_experiment( 2950 experiment_name, 2951 experiment_description, 2952 experiment_type, 2953 target_securities=target_securities, 2954 ) 2955 2956 2957def modifyHedgeExperiment( 2958 apikey: str, 2959 experiment_id: str, 2960 experiment_name: Optional[str] = None, 2961 experiment_description: Optional[str] = None, 2962 experiment_type: Optional[hedge_experiment_type] = None, 2963 target_securities: Union[Dict[GbiIdSecurity, float], str, None] = None, 2964 model_ids: Optional[List[str]] = None, 2965 stock_universe_ids: Optional[List[str]] = None, 2966 create_default_scenario: bool = True, 2967 baseline_model_id: Optional[str] = None, 2968 baseline_stock_universe_id: Optional[str] = None, 2969 baseline_portfolio_settings: Optional[str] = None, 2970 proxy: Optional[str] = None, 2971 disable_verify_ssl: bool = False, 2972) -> HedgeExperiment: 2973 """ 2974 Modifies an existing hedge experiment on the Boosted platform, returning an object 2975 representation of it. Note that currently this does NOT start the experiment; 2976 a modified experiment is still in a draft state. 2977 2978 Parameters 2979 ---------- 2980 apikey: str 2981 API key provided by Boosted. This key should be protected as a secret. 2982 experiment_name: str 2983 Name of the experiment 2984 experiment_description: str 2985 Your description of the experiment. 2986 experiment_type: str 2987 "HEDGE" - hedge out the risk of target securities 2988 "MIMIC" - mimic the target securities 2989 target_securities: Dict[GbiIdSecurity, float] | str | None (default) 2990 Specification of securities to hedge or mimic as a weighted basket. This parameter 2991 can take the form of: 2992 {GbiIdSecurity: weight} - to manually specify securities and weights, OR 2993 portfolio_id - to use the most recent holdings/allocations of the passed 2994 portfolio as the securities and weights 2995 model_ids: List[str] 2996 A list of model ids that will be used for constructing scenario portfolios 2997 stock_universe_ids: List[str] 2998 A list of stock universe ids that will be used for constructing scenario portfolios 2999 create_default_scenario: bool 3000 Whether to create a "default/inferred" scenario 3001 baseline_model_id: str 3002 Model id to (optionally) use for the baseline portfolio 3003 baseline_stock_universe_id: str 3004 Universe id to use for the baseline portfolio 3005 baseline_portfolio_settings: str 3006 A valid json-string specifying settings for the baseline portfolio 3007 proxy: str 3008 Your organization may require the use of a proxy for access. 3009 The address of a HTTPS proxy in the format of <address>:<port>. 3010 Examples are "123.456.789:123" or "my.proxy.com:123". 3011 Do not prepend with "https://". 3012 disable_verify_ssl: bool 3013 Your networking setup may be behind a firewall which performs SSL 3014 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 3015 to point to the location of a custom certificate bundle, or set this 3016 parameter to true to disable SSL verification as a workaround. 3017 3018 Returns 3019 ------- 3020 HedgeExperiment 3021 """ 3022 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 3023 return client.modify_hedge_experiment( 3024 experiment_id, 3025 name=experiment_name, 3026 description=experiment_description, 3027 experiment_type=experiment_type, 3028 target_securities=target_securities, 3029 model_ids=model_ids, 3030 stock_universe_ids=stock_universe_ids, 3031 create_default_scenario=create_default_scenario, 3032 baseline_model_id=baseline_model_id, 3033 baseline_stock_universe_id=baseline_stock_universe_id, 3034 baseline_portfolio_settings=baseline_portfolio_settings, 3035 ) 3036 3037 3038def startHedgeExperiment( 3039 apikey: str, 3040 experiment_id: str, 3041 *scenario_ids: str, 3042 proxy: Optional[str] = None, 3043 disable_verify_ssl: bool = False, 3044) -> HedgeExperiment: 3045 """ 3046 Starts an existing hedge experiment on the Boosted platform, returning an object 3047 representation of it. This function also starts the indicated scenarios. 3048 3049 Parameters 3050 ---------- 3051 apikey: str 3052 API key provided by Boosted. This key should be protected as a secret. 3053 experiment_name: str 3054 Name of the experiment 3055 scenario_ids: str 3056 Var-args corresponding to scenario ids that you would like to start. 3057 proxy: str 3058 Your organization may require the use of a proxy for access. 3059 The address of a HTTPS proxy in the format of <address>:<port>. 3060 Examples are "123.456.789:123" or "my.proxy.com:123". 3061 Do not prepend with "https://". 3062 disable_verify_ssl: bool 3063 Your networking setup may be behind a firewall which performs SSL 3064 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 3065 to point to the location of a custom certificate bundle, or set this 3066 parameter to true to disable SSL verification as a workaround. 3067 3068 Returns 3069 ------- 3070 HedgeExperiment 3071 """ 3072 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 3073 return client.start_hedge_experiment(experiment_id, *scenario_ids) 3074 3075 3076def deleteHedgeExperiment( 3077 apikey: str, experiment_id: str, proxy: Optional[str] = None, disable_verify_ssl: bool = False 3078) -> bool: 3079 """ 3080 Deletes a hedge experiment and all associated scenarios. This is a permanent, 3081 irreversible action! 3082 3083 Parameters 3084 ---------- 3085 apikey: str 3086 API key provided by Boosted. This key should be protected as a secret. 3087 experiment_name: str 3088 Name of the experiment 3089 proxy: str 3090 Your organization may require the use of a proxy for access. 3091 The address of a HTTPS proxy in the format of <address>:<port>. 3092 Examples are "123.456.789:123" or "my.proxy.com:123". 3093 Do not prepend with "https://". 3094 disable_verify_ssl: bool 3095 Your networking setup may be behind a firewall which performs SSL 3096 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 3097 to point to the location of a custom certificate bundle, or set this 3098 parameter to true to disable SSL verification as a workaround. 3099 3100 Returns 3101 ------- 3102 None 3103 """ 3104 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 3105 return client.delete_hedge_experiment(experiment_id) 3106 3107 3108def getPortfolioAccuracy( 3109 apikey: str, 3110 model_id: str, 3111 portfolio_id: str, 3112 proxy: Optional[str] = None, 3113 disable_verify_ssl: bool = False, 3114 start_date: Optional[BoostedDate] = None, 3115 end_date: Optional[BoostedDate] = None, 3116) -> dict: 3117 """ 3118 Get the accuracy (hit rate & excess return) information of a given portfolio. 3119 Parameters 3120 ---------- 3121 apikey: str 3122 API key provided by Boosted. This key should be protected as a secret. 3123 model_id: str 3124 Model ID of the portfolio to fetch data for. 3125 portfolio_id: str 3126 ID of the portfolio to fetch data for. 3127 proxy: str 3128 Your organization may require the use of a proxy for access. 3129 The address of a HTTPS proxy in the format of <address>:<port>. 3130 Examples are "123.456.789:123" or "my.proxy.com:123". 3131 Do not prepend with "https://". 3132 disable_verify_ssl: bool 3133 Your networking setup may be behind a firewall which performs SSL 3134 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 3135 to point to the location of a custom certificate bundle, or set this 3136 parameter to true to disable SSL verification as a workaround. 3137 start_date: Optional[datetime.date | str] 3138 Start date for portfolio accuracy date range. If this or end_date is 3139 omitted, full history will be returned. 3140 end_date: Optional[datetime.date | str] 3141 End date for portfolio accuracy date range. If this or start_date is 3142 omitted, full history will be returned. 3143 3144 Returns 3145 ------- 3146 accuracy: dict 3147 Dictionary containing accuracy information by Quantile, Decile and Ventile. 3148 """ 3149 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 3150 return client.get_portfolio_accuracy( 3151 model_id, portfolio_id, start_date=start_date, end_date=end_date 3152 ) 3153 3154 3155def createWatchlist( 3156 apikey: str, 3157 name: str, 3158 proxy: Optional[str] = None, 3159 disable_verify_ssl: bool = False, 3160) -> str: 3161 """ 3162 Create a watchlist and get back the watchlist_id for it 3163 3164 Parameters 3165 ---------- 3166 apikey: str 3167 API key provided by Boosted. This key should be protected as a secret. 3168 name: str 3169 Name to associate with the watchlist 3170 proxy: str 3171 Your organization may require the use of a proxy for access. 3172 The address of a HTTPS proxy in the format of <address>:<port>. 3173 Examples are "123.456.789:123" or "my.proxy.com:123". 3174 Do not prepend with "https://". 3175 disable_verify_ssl: bool 3176 Your networking setup may be behind a firewall which performs SSL 3177 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 3178 to point to the location of a custom certificate bundle, or set this 3179 parameter to true to disable SSL verification as a workaround. 3180 Returns 3181 ------- 3182 watchlist_id: str 3183 UUID to uniquely identify the newly created watchlist 3184 """ 3185 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 3186 return client.create_watchlist(name) 3187 3188 3189def createWatchlistFromFile( 3190 apikey: str, 3191 name: str, 3192 filepath: str, 3193 proxy: Optional[str] = None, 3194 disable_verify_ssl: bool = False, 3195) -> str: 3196 """ 3197 Create a watchlist and get back the watchlist_id for it 3198 3199 Parameters 3200 ---------- 3201 apikey: str 3202 API key provided by Boosted. This key should be protected as a secret. 3203 name: str 3204 Name to associate with the watchlist 3205 filepath: str 3206 path to file to upload, 3207 proxy: str 3208 Your organization may require the use of a proxy for access. 3209 The address of a HTTPS proxy in the format of <address>:<port>. 3210 Examples are "123.456.789:123" or "my.proxy.com:123". 3211 Do not prepend with "https://". 3212 disable_verify_ssl: bool 3213 Your networking setup may be behind a firewall which performs SSL 3214 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 3215 to point to the location of a custom certificate bundle, or set this 3216 parameter to true to disable SSL verification as a workaround. 3217 Returns 3218 ------- 3219 watchlist_id: str 3220 UUID to uniquely identify the newly created watchlist 3221 """ 3222 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 3223 return client.create_watchlist_from_file(name, filepath) 3224 3225 3226def getWatchlists( 3227 apikey: str, 3228 proxy: Optional[str] = None, 3229 disable_verify_ssl: bool = False, 3230) -> List[Dict]: 3231 """ 3232 Get the list of watchlists 3233 3234 Parameters 3235 ---------- 3236 apikey: str 3237 API key provided by Boosted. This key should be protected as a secret. 3238 proxy: str 3239 Your organization may require the use of a proxy for access. 3240 The address of a HTTPS proxy in the format of <address>:<port>. 3241 Examples are "123.456.789:123" or "my.proxy.com:123". 3242 Do not prepend with "https://". 3243 disable_verify_ssl: bool 3244 Your networking setup may be behind a firewall which performs SSL 3245 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 3246 to point to the location of a custom certificate bundle, or set this 3247 parameter to true to disable SSL verification as a workaround. 3248 Returns 3249 ------- 3250 watchlists: List[Dict] 3251 List of dictionaries with watchlist_id and name 3252 """ 3253 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 3254 return client.get_watchlists() 3255 3256 3257def getWatchlistContents( 3258 apikey: str, 3259 watchlist_id: str, 3260 proxy: Optional[str] = None, 3261 disable_verify_ssl: bool = False, 3262) -> Dict: 3263 """ 3264 Add a list of ISINs to a watchlist 3265 Parameters 3266 ---------- 3267 apikey: str 3268 API key provided by Boosted. This key should be protected as a secret. 3269 watchlist_id: str 3270 The UUID for an existing watchlist that the user has read access to 3271 proxy: str 3272 Your organization may require the use of a proxy for access. 3273 The address of a HTTPS proxy in the format of <address>:<port>. 3274 Examples are "123.456.789:123" or "my.proxy.com:123". 3275 Do not prepend with "https://". 3276 disable_verify_ssl: bool 3277 Your networking setup may be behind a firewall which performs SSL 3278 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 3279 to point to the location of a custom certificate bundle, or set this 3280 parameter to true to disable SSL verification as a workaround. 3281 Returns 3282 ------- 3283 Information suitable to recreate the watchlist 3284 Dict { 3285 "watchlist_id": str 3286 "contents": List[Dict] 3287 Keys: 'ISIN' 'TICKER', 'COUNTRY', 'CURRENCY', 'CATEGORY' 3288 } 3289 3290 """ 3291 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 3292 return client.get_watchlist_contents(watchlist_id) 3293 3294 3295def getWatchlistContentsAsCsv( 3296 apikey: str, 3297 watchlist_id: str, 3298 filepath: str, 3299 proxy: Optional[str] = None, 3300 disable_verify_ssl: bool = False, 3301) -> None: 3302 """ 3303 Get Watchlist securities in csv format 3304 Parameters 3305 ---------- 3306 apikey: str 3307 API key provided by Boosted. This key should be protected as a secret. 3308 watchlist_id: str 3309 The UUID for an existing watchlist that the user has read access to 3310 filepath: str 3311 Destination for csv file to be written to 3312 proxy: str 3313 Your organization may require the use of a proxy for access. 3314 The address of a HTTPS proxy in the format of <address>:<port>. 3315 Examples are "123.456.789:123" or "my.proxy.com:123". 3316 Do not prepend with "https://". 3317 disable_verify_ssl: bool 3318 Your networking setup may be behind a firewall which performs SSL 3319 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 3320 to point to the location of a custom certificate bundle, or set this 3321 parameter to true to disable SSL verification as a workaround. 3322 Returns 3323 ------- 3324 None 3325 """ 3326 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 3327 return client.get_watchlist_contents_as_csv(watchlist_id, filepath) 3328 3329 3330def getCoverageInfo( 3331 apikey: str, 3332 watchlist_id: str, 3333 portfolio_group_id: str, 3334 proxy: Optional[str] = None, 3335 disable_verify_ssl: bool = False, 3336) -> pd.DataFrame: 3337 """ 3338 Get Coverage info for a given watchlist and portfolio group 3339 Parameters 3340 ---------- 3341 apikey: str 3342 API key provided by Boosted. This key should be protected as a secret. 3343 watchlist_id: str 3344 The UUID for an existing watchlist that the user has read access to 3345 portfolio_group_id: str 3346 The UUID for an existing portfolio group that the user has read access to 3347 proxy: str 3348 Your organization may require the use of a proxy for access. 3349 The address of a HTTPS proxy in the format of <address>:<port>. 3350 Examples are "123.456.789:123" or "my.proxy.com:123". 3351 Do not prepend with "https://". 3352 disable_verify_ssl: bool 3353 Your networking setup may be behind a firewall which performs SSL 3354 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 3355 to point to the location of a custom certificate bundle, or set this 3356 parameter to true to disable SSL verification as a workaround. 3357 Returns 3358 ------- 3359 pd.DataFrame 3360 """ 3361 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 3362 return client.get_coverage_info(watchlist_id, portfolio_group_id) 3363 3364 3365def getCoverageCsv( 3366 apikey: str, 3367 watchlist_id: str, 3368 portfolio_group_id: str, 3369 filepath: Optional[str], 3370 proxy: Optional[str] = None, 3371 disable_verify_ssl: bool = False, 3372) -> Optional[str]: 3373 """ 3374 Get Coverage info for a given watchlist and portfolio group 3375 Parameters 3376 ---------- 3377 apikey: str 3378 API key provided by Boosted. This key should be protected as a secret. 3379 watchlist_id: str 3380 The UUID for an existing watchlist that the user has read access to 3381 portfolio_group_id: str 3382 The UUID for an existing portfolio group that the user has read access to 3383 filepath: Optional[str] = None 3384 The location to write csv file to 3385 proxy: str 3386 Your organization may require the use of a proxy for access. 3387 The address of a HTTPS proxy in the format of <address>:<port>. 3388 Examples are "123.456.789:123" or "my.proxy.com:123". 3389 Do not prepend with "https://". 3390 disable_verify_ssl: bool 3391 Your networking setup may be behind a firewall which performs SSL 3392 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 3393 to point to the location of a custom certificate bundle, or set this 3394 parameter to true to disable SSL verification as a workaround. 3395 Returns 3396 ------- 3397 None if filepath is provided, else a string with a csv's contents is returned 3398 """ 3399 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 3400 return client.get_coverage_csv(watchlist_id, portfolio_group_id, filepath) 3401 3402 3403def addSecuritiesToWatchlist( 3404 apikey: str, 3405 watchlist_id: str, 3406 identifiers: List[str], 3407 identifier_type: Literal["TICKER", "ISIN"], 3408 proxy: Optional[str] = None, 3409 disable_verify_ssl: bool = False, 3410) -> Dict: 3411 """ 3412 Add a list of ISINs to a watchlist 3413 Parameters 3414 ---------- 3415 apikey: str 3416 API key provided by Boosted. This key should be protected as a secret. 3417 watchlist_id: str 3418 The UUID for an existing watchlist that the user has write access to 3419 identifiers: List[str] 3420 The list of identifiers to be added to the watchlist. These identifiers can 3421 be tickers or ISINs. See identifier_type. 3422 identifier_type: Literal["TICKER", "ISIN"] 3423 Specifier for the type of identifier. 3424 proxy: str 3425 Your organization may require the use of a proxy for access. 3426 The address of a HTTPS proxy in the format of <address>:<port>. 3427 Examples are "123.456.789:123" or "my.proxy.com:123". 3428 Do not prepend with "https://". 3429 disable_verify_ssl: bool 3430 Your networking setup may be behind a firewall which performs SSL 3431 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 3432 to point to the location of a custom certificate bundle, or set this 3433 parameter to true to disable SSL verification as a workaround. 3434 Returns 3435 ------- 3436 status: Dict #FIXME - im not sure what we want to return here 3437 Information about what was modified to in the watchlist 3438 """ 3439 if identifier_type not in ["TICKER", "ISIN"]: 3440 raise ValueError( 3441 f"Got unexpected value for arg {identifier_type=}; expected 'TICKER' or 'ISIN'" 3442 ) 3443 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 3444 return client.add_securities_to_watchlist(watchlist_id, identifiers, identifier_type) 3445 3446 3447def removeSecuritiesFromWatchlist( 3448 apikey: str, 3449 watchlist_id: str, 3450 identifiers: List[str], 3451 identifier_type: Literal["TICKER", "ISIN"], 3452 proxy: Optional[str] = None, 3453 disable_verify_ssl: bool = False, 3454) -> Dict: 3455 """ 3456 Add a list of ISINs to a watchlist 3457 Parameters 3458 ---------- 3459 apikey: str 3460 API key provided by Boosted. This key should be protected as a secret. 3461 watchlist_id: str 3462 The UUID for an existing watchlist that the user has write access to 3463 identifiers: List[str] 3464 The list of identifiers to be added to the watchlist. These identifiers can 3465 be tickers or ISINs. See identifier_type. 3466 identifier_type: Literal["TICKER", "ISIN"] 3467 Specifier for the type of identifier. 3468 proxy: str 3469 Your organization may require the use of a proxy for access. 3470 The address of a HTTPS proxy in the format of <address>:<port>. 3471 Examples are "123.456.789:123" or "my.proxy.com:123". 3472 Do not prepend with "https://". 3473 disable_verify_ssl: bool 3474 Your networking setup may be behind a firewall which performs SSL 3475 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 3476 to point to the location of a custom certificate bundle, or set this 3477 parameter to true to disable SSL verification as a workaround. 3478 Returns 3479 ------- 3480 status: Dict #FIXME - im not sure what we want to return here 3481 Information about what was modified to in the watchlist 3482 """ 3483 if identifier_type not in ["TICKER", "ISIN"]: 3484 raise ValueError( 3485 f"Got unexpected value for arg {identifier_type=}; expected 'TICKER' or 'ISIN'" 3486 ) 3487 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 3488 return client.remove_securities_from_watchlist(watchlist_id, identifiers, identifier_type) 3489 3490 3491def setPortfolioGroupForWatchlist( 3492 apikey: str, 3493 portfolio_group_id: str, 3494 watchlist_id: str, 3495 proxy: Optional[str] = None, 3496 disable_verify_ssl: bool = False, 3497) -> Dict: 3498 """ 3499 Set portfolio group for watchlist. 3500 3501 Parameters 3502 ---------- 3503 apikey: str 3504 API key provided by Boosted. This key should be protected as a secret. 3505 portfolio_group_id: str, 3506 UUID str identifying a portfolio group 3507 watchlist_id: str, 3508 UUID str identifying a watchlist 3509 proxy: str 3510 Your organization may require the use of a proxy for access. 3511 The address of a HTTPS proxy in the format of <address>:<port>. 3512 Examples are "123.456.789:123" or "my.proxy.com:123". 3513 Do not prepend with "https://". 3514 disable_verify_ssl: bool 3515 Your networking setup may be behind a firewall which performs SSL 3516 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 3517 to point to the location of a custom certificate bundle, or set this 3518 parameter to true to disable SSL verification as a workaround. 3519 Returns 3520 ------- 3521 Dict: with a list of all portfolio groups for the user 3522 """ 3523 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 3524 return client.set_portfolio_group_for_watchlist(portfolio_group_id, watchlist_id) 3525 3526 3527def setStickyPortfolioGroup( 3528 apikey: str, 3529 portfolio_group_id: str, 3530 proxy: Optional[str] = None, 3531 disable_verify_ssl: bool = False, 3532) -> Dict: 3533 """ 3534 Set sticky portfolio group for the user. 3535 3536 Parameters 3537 ---------- 3538 apikey: str 3539 API key provided by Boosted. This key should be protected as a secret. 3540 portfolio_group_id: str, 3541 UUID str identifying a portfolio group 3542 proxy: str 3543 Your organization may require the use of a proxy for access. 3544 The address of a HTTPS proxy in the format of <address>:<port>. 3545 Examples are "123.456.789:123" or "my.proxy.com:123". 3546 Do not prepend with "https://". 3547 disable_verify_ssl: bool 3548 Your networking setup may be behind a firewall which performs SSL 3549 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 3550 to point to the location of a custom certificate bundle, or set this 3551 parameter to true to disable SSL verification as a workaround. 3552 Returns 3553 ------- 3554 Dict: with a list of all portfolio groups for the user 3555 """ 3556 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 3557 return client.set_sticky_portfolio_group(portfolio_group_id) 3558 3559 3560def getStickyPortfolioGroup( 3561 apikey: str, 3562 proxy: Optional[str] = None, 3563 disable_verify_ssl: bool = False, 3564) -> Dict: 3565 """ 3566 Get sticky portfolio group for the user. 3567 3568 Parameters 3569 ---------- 3570 apikey: str 3571 API key provided by Boosted. This key should be protected as a secret. 3572 proxy: str 3573 Your organization may require the use of a proxy for access. 3574 The address of a HTTPS proxy in the format of <address>:<port>. 3575 Examples are "123.456.789:123" or "my.proxy.com:123". 3576 Do not prepend with "https://". 3577 disable_verify_ssl: bool 3578 Your networking setup may be behind a firewall which performs SSL 3579 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 3580 to point to the location of a custom certificate bundle, or set this 3581 parameter to true to disable SSL verification as a workaround. 3582 Returns 3583 ------- 3584 Dict { 3585 group_id: str 3586 group_name: str 3587 portfolios: List[PortfolioInGroup(Dict)] 3588 PortfolioInGroup(Dict): 3589 portfolio_id: str 3590 rank_in_group: Optional[int] = None 3591 portfolio_name: Optional[str] = None 3592 } 3593 """ 3594 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 3595 return client.get_sticky_portfolio_group() 3596 3597 3598def getPortfolioGroup( 3599 apikey: str, 3600 portfolio_group_id: str, 3601 proxy: Optional[str] = None, 3602 disable_verify_ssl: bool = False, 3603) -> Dict: 3604 """ 3605 Get a single portfolio group. 3606 3607 Parameters 3608 ---------- 3609 apikey: str 3610 API key provided by Boosted. This key should be protected as a secret. 3611 portfolio_group_id: str, 3612 UUID str identifying a portfolio group 3613 proxy: str 3614 Your organization may require the use of a proxy for access. 3615 The address of a HTTPS proxy in the format of <address>:<port>. 3616 Examples are "123.456.789:123" or "my.proxy.com:123". 3617 Do not prepend with "https://". 3618 disable_verify_ssl: bool 3619 Your networking setup may be behind a firewall which performs SSL 3620 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 3621 to point to the location of a custom certificate bundle, or set this 3622 parameter to true to disable SSL verification as a workaround. 3623 Returns 3624 ------- 3625 PortfolioGroup: Dict: { 3626 group_id: str 3627 group_name: str 3628 portfolios: List[PortfolioInGroup] 3629 } 3630 where PortfolioInGroup is defined as = Dict { 3631 portfolio_id: str 3632 portfolio_name: str 3633 rank_in_group: Optional[int] 3634 } 3635 """ 3636 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 3637 return client.get_portfolio_group(portfolio_group_id) 3638 3639 3640def getPortfolioGroups( 3641 apikey: str, 3642 proxy: Optional[str] = None, 3643 disable_verify_ssl: bool = False, 3644) -> Dict: 3645 """ 3646 Get a list of all portfolio groups for the user 3647 3648 Parameters 3649 ---------- 3650 apikey: str 3651 API key provided by Boosted. This key should be protected as a secret. 3652 proxy: str 3653 Your organization may require the use of a proxy for access. 3654 The address of a HTTPS proxy in the format of <address>:<port>. 3655 Examples are "123.456.789:123" or "my.proxy.com:123". 3656 Do not prepend with "https://". 3657 disable_verify_ssl: bool 3658 Your networking setup may be behind a firewall which performs SSL 3659 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 3660 to point to the location of a custom certificate bundle, or set this 3661 parameter to true to disable SSL verification as a workaround. 3662 Returns 3663 ------- 3664 Dict: with a list of all portfolio groups for the user 3665 """ 3666 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 3667 return client.get_portfolio_groups() 3668 3669 3670def createPortfolioGroup( 3671 apikey: str, 3672 group_name: str, 3673 portfolios: Optional[List[Dict]] = None, 3674 proxy: Optional[str] = None, 3675 disable_verify_ssl: bool = False, 3676) -> Dict: 3677 """ 3678 Create a new portfolio group 3679 3680 Parameters 3681 ---------- 3682 apikey: str 3683 API key provided by Boosted. This key should be protected as a secret. 3684 3685 group_name: str 3686 name of the new group 3687 3688 portfolios: List of Dict [: 3689 3690 portfolio_id: str 3691 rank_in_group: Optional[int] = None 3692 ] 3693 3694 proxy: str 3695 Your organization may require the use of a proxy for access. 3696 The address of a HTTPS proxy in the format of <address>:<port>. 3697 Examples are "123.456.789:123" or "my.proxy.com:123". 3698 Do not prepend with "https://". 3699 disable_verify_ssl: bool 3700 Your networking setup may be behind a firewall which performs SSL 3701 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 3702 to point to the location of a custom certificate bundle, or set this 3703 parameter to true to disable SSL verification as a workaround. 3704 3705 3706 Returns: 3707 ---------- 3708 3709 Dict: { 3710 group_id: str 3711 UUID identifier for the portfolio group 3712 3713 created: int 3714 num groups created, 1 == success 3715 3716 added: int 3717 num portfolios added to the group, should match the length of 'portfolios' argument 3718 } 3719 3720 """ 3721 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 3722 return client.create_portfolio_group(group_name, portfolios) 3723 3724 3725def renamePortfolioGroup( 3726 apikey: str, 3727 group_id: str, 3728 group_name: str, 3729 proxy: Optional[str] = None, 3730 disable_verify_ssl: bool = False, 3731) -> Dict: 3732 """ 3733 Rename a portfolio group 3734 3735 Parameters 3736 ---------- 3737 apikey: str 3738 API key provided by Boosted. This key should be protected as a secret. 3739 3740 group_id: str, 3741 UUID str identifying a portfolio group 3742 3743 group_name: str, 3744 The new name for the porfolio 3745 3746 proxy: str 3747 Your organization may require the use of a proxy for access. 3748 The address of a HTTPS proxy in the format of <address>:<port>. 3749 Examples are "123.456.789:123" or "my.proxy.com:123". 3750 Do not prepend with "https://". 3751 disable_verify_ssl: bool 3752 Your networking setup may be behind a firewall which performs SSL 3753 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 3754 to point to the location of a custom certificate bundle, or set this 3755 parameter to true to disable SSL verification as a workaround. 3756 3757 Returns: 3758 ------- 3759 Dict { 3760 changed: int - 1 == success 3761 } 3762 """ 3763 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 3764 return client.rename_portfolio_group(group_id, group_name) 3765 3766 3767def addToPortfolioGroup( 3768 apikey: str, 3769 group_id: str, 3770 portfolios: List[Dict], 3771 proxy: Optional[str] = None, 3772 disable_verify_ssl: bool = False, 3773) -> Dict: 3774 """ 3775 Add portfolios to a group 3776 3777 Parameters 3778 ---------- 3779 apikey: str 3780 API key provided by Boosted. This key should be protected as a secret. 3781 3782 group_id: str, 3783 UUID str identifying a portfolio group 3784 3785 portfolios: List of Dict [: 3786 portfolio_id: str 3787 rank_in_group: Optional[int] = None 3788 ] 3789 3790 3791 proxy: str 3792 Your organization may require the use of a proxy for access. 3793 The address of a HTTPS proxy in the format of <address>:<port>. 3794 Examples are "123.456.789:123" or "my.proxy.com:123". 3795 Do not prepend with "https://". 3796 disable_verify_ssl: bool 3797 Your networking setup may be behind a firewall which performs SSL 3798 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 3799 to point to the location of a custom certificate bundle, or set this 3800 parameter to true to disable SSL verification as a workaround. 3801 3802 3803 Returns: 3804 ------- 3805 Dict { 3806 added: int 3807 number of successful changes 3808 } 3809 """ 3810 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 3811 return client.add_to_portfolio_group(group_id, portfolios) 3812 3813 3814def removeFromPortfolioGroup( 3815 apikey: str, 3816 group_id: str, 3817 portfolios: List[str], 3818 proxy: Optional[str] = None, 3819 disable_verify_ssl: bool = False, 3820) -> Dict: 3821 """ 3822 Remove portfolios from a group 3823 3824 Parameters 3825 ---------- 3826 apikey: str 3827 API key provided by Boosted. This key should be protected as a secret. 3828 3829 group_id: str, 3830 UUID str identifying a portfolio group 3831 3832 portfolios: List of str 3833 3834 3835 proxy: str 3836 Your organization may require the use of a proxy for access. 3837 The address of a HTTPS proxy in the format of <address>:<port>. 3838 Examples are "123.456.789:123" or "my.proxy.com:123". 3839 Do not prepend with "https://". 3840 disable_verify_ssl: bool 3841 Your networking setup may be behind a firewall which performs SSL 3842 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 3843 to point to the location of a custom certificate bundle, or set this 3844 parameter to true to disable SSL verification as a workaround. 3845 3846 3847 Returns: 3848 ------- 3849 Dict { 3850 removed: int 3851 number of successful changes 3852 } 3853 """ 3854 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 3855 return client.remove_from_portfolio_group(group_id, portfolios) 3856 3857 3858def deletePortfolioGroup( 3859 apikey: str, 3860 group_id: str, 3861 proxy: Optional[str] = None, 3862 disable_verify_ssl: bool = False, 3863) -> Dict: 3864 """ 3865 Delete a portfolio group 3866 3867 Parameters 3868 ---------- 3869 3870 apikey: str 3871 API key provided by Boosted. This key should be protected as a secret. 3872 3873 group_id: str, 3874 UUID str identifying a portfolio group 3875 3876 proxy: str 3877 Your organization may require the use of a proxy for access. 3878 The address of a HTTPS proxy in the format of <address>:<port>. 3879 Examples are "123.456.789:123" or "my.proxy.com:123". 3880 Do not prepend with "https://". 3881 disable_verify_ssl: bool 3882 Your networking setup may be behind a firewall which performs SSL 3883 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 3884 to point to the location of a custom certificate bundle, or set this 3885 parameter to true to disable SSL verification as a workaround. 3886 3887 Returns 3888 ------- 3889 3890 Dict { 3891 removed_groups: int 3892 number of successful changes 3893 3894 removed_portfolios: int 3895 number of successful changes 3896 } 3897 3898 """ 3899 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 3900 return client.delete_portfolio_group(group_id) 3901 3902 3903def getRiskGroups( 3904 apikey: str, 3905 model_id: str, 3906 portfolio_id: str, 3907 date: BoostedDate = datetime.date.today(), 3908 proxy: Optional[str] = None, 3909 disable_verify_ssl: bool = False, 3910 use_v2: bool = False, 3911) -> List[Dict[str, Any]]: 3912 """ 3913 Given a model and portfolio, returns the calculated semantic risk groups. 3914 3915 Parameters 3916 ---------- 3917 apikey: str 3918 API key provided by Boosted. This key should be protected as a secret. 3919 model_id: str 3920 Model ID. Model IDs can be retrieved by clicking on the copy to clipboard 3921 button next to your model's name in the Model Summary Page in Boosted 3922 Insights. 3923 portfolio_id: str 3924 Portfolio ID. Portfolio IDs can be retrieved from portfolio's configuration page. 3925 date: datetime.date | str 3926 Date for which to fetch data. Defaults to "today". 3927 use_v2: bool 3928 Whether to use the "V2" version of risk factors data. 3929 proxy: str 3930 Your organization may require the use of a proxy for access. 3931 The address of a HTTPS proxy in the format of <address>:<port>. 3932 Examples are "123.456.789:123" or "my.proxy.com:123". 3933 Do not prepend with "https://". 3934 disable_verify_ssl: bool 3935 Your networking setup may be behind a firewall which performs SSL 3936 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 3937 to point to the location of a custom certificate bundle, or set this 3938 parameter to true to disable SSL verification as a workaround. 3939 3940 Returns 3941 ------- 3942 A list of dictionaries. Each dictionary has the following keys: 3943 machine: int 3944 E.g. 1 for "machine_1", 2 for "machine_2", etc. 3945 risk_group_a: List[str] 3946 List of stock descriptors risk group a (e.g. Cruises, Airlines, etc.) 3947 risk_group_b: List[str] 3948 List of stock descriptors risk group b (e.g. Cruises, Airlines, etc.) 3949 volatility_explained: float 3950 Decimal between 0.0 and 1.0 that represents the percent of stock 3951 universe volatility explained by these groups. 3952 """ 3953 date = convert_date(date) 3954 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 3955 return client.get_risk_groups(model_id, portfolio_id, date, use_v2) 3956 3957 3958def getRiskFactorsDiscoveredDescriptors( 3959 apikey: str, 3960 model_id: str, 3961 portfolio_id: str, 3962 date: BoostedDate = datetime.date.today(), 3963 proxy: Optional[str] = None, 3964 disable_verify_ssl: bool = False, 3965 use_v2: bool = False, 3966) -> pd.DataFrame: 3967 """ 3968 Given a model and portfolio, returns the calculated semantic risk discovered 3969 descriptors. 3970 3971 Parameters 3972 ---------- 3973 apikey: str 3974 API key provided by Boosted. This key should be protected as a secret. 3975 model_id: str 3976 Model ID. Model IDs can be retrieved by clicking on the copy to clipboard 3977 button next to your model's name in the Model Summary Page in Boosted 3978 Insights. 3979 portfolio_id: str 3980 Portfolio ID. Portfolio IDs can be retrieved from portfolio's configuration page. 3981 date: datetime.date | str 3982 Date for which to fetch data. Defaults to "today". 3983 use_v2: bool 3984 Whether to use the "V2" version of risk factors data. 3985 proxy: str 3986 Your organization may require the use of a proxy for access. 3987 The address of a HTTPS proxy in the format of <address>:<port>. 3988 Examples are "123.456.789:123" or "my.proxy.com:123". 3989 Do not prepend with "https://". 3990 disable_verify_ssl: bool 3991 Your networking setup may be behind a firewall which performs SSL 3992 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 3993 to point to the location of a custom certificate bundle, or set this 3994 parameter to true to disable SSL verification as a workaround. 3995 3996 Returns 3997 ------- 3998 A dataframe with the following columns: 3999 4000 level: int 4001 An integer indicating the depth/level of that row (0 for sectors, 1 for 4002 securities). 4003 identifier: str 4004 Sector/security identifier. 4005 stock_count: int 4006 Total number of stocks in the sector/industry. For security rows, will 4007 be 1. 4008 volatility: float 4009 exposure: float 4010 rating: float 4011 rating_delta: float 4012 """ 4013 date = convert_date(date) 4014 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 4015 return client.get_risk_factors_discovered_descriptors(model_id, portfolio_id, date, use_v2) 4016 4017 4018def getRiskFactorsSectors( 4019 apikey: str, 4020 model_id: str, 4021 portfolio_id: str, 4022 date: BoostedDate = datetime.date.today(), 4023 proxy: Optional[str] = None, 4024 disable_verify_ssl: bool = False, 4025 use_v2: bool = False, 4026) -> pd.DataFrame: 4027 """ 4028 Given a model and portfolio, returns the calculated semantic risk sectors. 4029 4030 Parameters 4031 ---------- 4032 apikey: str 4033 API key provided by Boosted. This key should be protected as a secret. 4034 model_id: str 4035 Model ID. Model IDs can be retrieved by clicking on the copy to clipboard 4036 button next to your model's name in the Model Summary Page in Boosted 4037 Insights. 4038 portfolio_id: str 4039 Portfolio ID. Portfolio IDs can be retrieved from portfolio's configuration page. 4040 date: datetime.date | str 4041 Date for which to fetch data. Defaults to "today". 4042 use_v2: bool 4043 Whether to use the "V2" version of risk factors data. 4044 proxy: str 4045 Your organization may require the use of a proxy for access. 4046 The address of a HTTPS proxy in the format of <address>:<port>. 4047 Examples are "123.456.789:123" or "my.proxy.com:123". 4048 Do not prepend with "https://". 4049 disable_verify_ssl: bool 4050 Your networking setup may be behind a firewall which performs SSL 4051 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 4052 to point to the location of a custom certificate bundle, or set this 4053 parameter to true to disable SSL verification as a workaround. 4054 4055 Returns 4056 ------- 4057 A dataframe with the following columns: 4058 4059 level: int 4060 An integer indicating the depth/level of that row (0 for sectors, 1 for 4061 industry groups, 2 for industries). 4062 identifier: str 4063 Sector/Industry group/Industry identifier. 4064 stock_count: int 4065 Total number of stocks in the sector/industry. 4066 volatility: float 4067 exposure: float 4068 rating: float 4069 rating_delta: float 4070 """ 4071 date = convert_date(date) 4072 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 4073 return client.get_risk_factors_sectors(model_id, portfolio_id, date, use_v2) 4074 4075 4076def downloadCompletePortfolioData( 4077 apikey: str, 4078 model_id: str, 4079 portfolio_id: str, 4080 download_filepath: Optional[str] = None, 4081 proxy: Optional[str] = None, 4082 disable_verify_ssl: bool = False, 4083): 4084 """ 4085 Given a model and portfolio, downloads the complete portfolio data as an 4086 excel file to the specified download path. 4087 4088 Parameters 4089 ---------- 4090 apikey: str 4091 API key provided by Boosted. This key should be protected as a secret. 4092 model_id: str 4093 Model ID. Model IDs can be retrieved by clicking on the copy to clipboard 4094 button next to your model's name in the Model Summary Page in Boosted 4095 Insights. 4096 portfolio_id: str 4097 Portfolio ID. Portfolio IDs can be retrieved from portfolio's configuration page. 4098 download_filepath: Optional[str] 4099 File path to download model data file to. If not present, will default 4100 to a file named after the model_id in the current directory. 4101 proxy: str 4102 Your organization may require the use of a proxy for access. 4103 The address of a HTTPS proxy in the format of <address>:<port>. 4104 Examples are "123.456.789:123" or "my.proxy.com:123". 4105 Do not prepend with "https://". 4106 disable_verify_ssl: bool 4107 Your networking setup may be behind a firewall which performs SSL 4108 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 4109 to point to the location of a custom certificate bundle, or set this 4110 parameter to true to disable SSL verification as a workaround. 4111 """ 4112 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 4113 if download_filepath is None: 4114 download_filepath = f"{model_id}.xlsx" 4115 client.download_complete_portfolio_data(model_id, portfolio_id, download_filepath) 4116 4117 4118def diffHedgeExperimentPortfolioData( 4119 apikey: str, 4120 experiment_id: str, 4121 comparison_portfolios: List[str], 4122 categories: Optional[List[str]] = None, 4123 proxy: Optional[str] = None, 4124 disable_verify_ssl: bool = False, 4125) -> Dict: 4126 """ 4127 Differences portfolios, returning data relative to the baseline. 4128 4129 This function supports differencing multiple portfolios against the 4130 baseline, such that diff_i = cmp_pf_i - baseline. Differences are 4131 calculated element-wise on a per-category basis. 4132 4133 Currently, this function only works for hedge experiment portfolios. 4134 4135 Parameters 4136 ---------- 4137 apikey: str 4138 API key provided by Boosted. This key should be protected as a secret. 4139 experiment_id: str 4140 Hedge experiment id 4141 comparison_portfolios: List[str] 4142 List of portfolios to be diffed against the current baseline. 4143 categories: List[str] 4144 Specifier of what data to difference. Passing a smaller, desired 4145 subset can improve performance. Options include: 4146 ["performanceGrid", "performance", "factors", "volatility"] 4147 proxy: str 4148 Your organization may require the use of a proxy for access. 4149 The address of a HTTPS proxy in the format of <address>:<port>. 4150 Examples are "123.456.789:123" or "my.proxy.com:123". 4151 Do not prepend with "https://". 4152 disable_verify_ssl: bool 4153 Your networking setup may be behind a firewall which performs SSL 4154 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 4155 to point to the location of a custom certificate bundle, or set this 4156 parameter to true to disable SSL verification as a workaround. 4157 4158 Returns 4159 ------- 4160 Dictionary: 4161 { 4162 "factors": Optional[pd.DataFrame], 4163 "volatility":Optional[pd.DataFrame], 4164 "performance": Optional[pd.DataFrame], 4165 "performanceGrid": Optional[pd.DataFrame] 4166 } 4167 """ 4168 4169 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 4170 DIFF_CATEGORIES = ["performance", "performanceGrid", "volatility", "factors"] 4171 if categories is None: 4172 categories = DIFF_CATEGORIES 4173 else: 4174 for cat in categories: 4175 if cat not in DIFF_CATEGORIES: 4176 raise ValueError(f"Unexpected category {cat}") 4177 diff = client.diff_hedge_experiment_portfolio_data( 4178 experiment_id, comparison_portfolios, categories 4179 ) 4180 return diff 4181 4182 4183def getSignalStrength( 4184 apikey: str, 4185 model_id: str, 4186 portfolio_id: str, 4187 proxy: Optional[str] = None, 4188 disable_verify_ssl: bool = False, 4189) -> pd.DataFrame: 4190 """ 4191 Retrieves portfolio signals data and returns as a pandas dataframe. 4192 4193 Parameters 4194 ---------- 4195 apikey: str 4196 API key provided by Boosted. This key should be protected as a secret. 4197 model_id: str 4198 UUID of a Boosted model. 4199 portfolio_id: str 4200 UUID of a Boosted portfolio in the given model. 4201 proxy: str 4202 Your organization may require the use of a proxy for access. 4203 The address of a HTTPS proxy in the format of <address>:<port>. 4204 Examples are "123.456.789:123" or "my.proxy.com:123". 4205 Do not prepend with "https://". 4206 disable_verify_ssl: bool 4207 Your networking setup may be behind a firewall which performs SSL 4208 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 4209 to point to the location of a custom certificate bundle, or set this 4210 parameter to true to disable SSL verification as a workaround. 4211 4212 Returns 4213 ------- 4214 Pandas Dataframe indexed by date with columns: 4215 5D, 10D, 21D, 63D, 126D, 189D, 252D, 315D, 378D, 441D, 504D, TimeHorizon 4216 """ 4217 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 4218 return client.get_signal_strength(model_id, portfolio_id) 4219 4220 4221def getRollingSignalStrength( 4222 apikey: str, 4223 model_id: str, 4224 portfolio_id: str, 4225 proxy: Optional[str] = None, 4226 disable_verify_ssl: bool = False, 4227): 4228 """ 4229 Retrieves portfolio rolling signals data and returns as a pandas dataframe. 4230 4231 Parameters 4232 ---------- 4233 apikey: str 4234 API key provided by Boosted. This key should be protected as a secret. 4235 model_id: str 4236 UUID of a Boosted model. 4237 portfolio_id: str 4238 UUID of a Boosted portfolio in the given model. 4239 proxy: str 4240 Your organization may require the use of a proxy for access. 4241 The address of a HTTPS proxy in the format of <address>:<port>. 4242 Examples are "123.456.789:123" or "my.proxy.com:123". 4243 Do not prepend with "https://". 4244 disable_verify_ssl: bool 4245 Your networking setup may be behind a firewall which performs SSL 4246 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 4247 to point to the location of a custom certificate bundle, or set this 4248 parameter to true to disable SSL verification as a workaround. 4249 4250 Returns 4251 ------- 4252 Pandas Dataframe indexed by date with columns: 4253 Avg5D 4254 Avg10D 4255 Avg21D 4256 Avg63D 4257 Avg126D 4258 Avg189D 4259 Avg252D 4260 Avg315D 4261 Avg378D 4262 Avg441D 4263 Avg504D 4264 Avgtime Horizon 4265 """ 4266 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 4267 return client.get_rolling_signal_strength(model_id, portfolio_id) 4268 4269 4270def getPortfolioQuantiles( 4271 apikey: str, 4272 model_id: str, 4273 portfolio_id: str, 4274 id_type: Literal["TICKER", "ISIN"] = "TICKER", 4275 proxy: Optional[str] = None, 4276 disable_verify_ssl: bool = False, 4277): 4278 """ 4279 Get quantile data for a portfolio. 4280 4281 Parameters 4282 ---------- 4283 apikey: str 4284 API key provided by Boosted. This key should be protected as a secret. 4285 model_id: str 4286 UUID of a Boosted model. 4287 portfolio_id: str 4288 UUID of a Boosted portfolio in the given model. 4289 id_type: Literal["TICKER", "ISIN"] = "TICKER", 4290 Whether the column names are ISIN's or tickers in the output dataframe. 4291 proxy: str 4292 Your organization may require the use of a proxy for access. 4293 The address of a HTTPS proxy in the format of <address>:<port>. 4294 Examples are "123.456.789:123" or "my.proxy.com:123". 4295 Do not prepend with "https://". 4296 disable_verify_ssl: bool 4297 Your networking setup may be behind a firewall which performs SSL 4298 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 4299 to point to the location of a custom certificate bundle, or set this 4300 parameter to true to disable SSL verification as a workaround. 4301 4302 Returns 4303 ------- 4304 Pandas Dataframe indexed by date with each one security per column. 4305 """ 4306 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 4307 return client.get_portfolio_quantiles( 4308 model_id=model_id, 4309 portfolio_id=portfolio_id, 4310 id_type=id_type, 4311 ) 4312 4313 4314def getSimilarStocks( 4315 apikey: str, 4316 model_id: str, 4317 portfolio_id: str, 4318 identifiers: List[str], 4319 date: BoostedDate, 4320 identifier_type: Literal["TICKER", "ISIN"] = "TICKER", 4321 proxy: Optional[str] = None, 4322 disable_verify_ssl: bool = False, 4323) -> pd.DataFrame: 4324 """ 4325 Get the stock similarity data for a basket of stocks. 4326 4327 Parameters 4328 ---------- 4329 apikey: str 4330 API key provided by Boosted. This key should be protected as a secret. 4331 model_id: str 4332 UUID of a Boosted model. 4333 portfolio_id: str 4334 UUID of a Boosted portfolio in the given model. 4335 identifiers: List[str] 4336 List of identifiers that represent the input basket of stocks, can be 4337 either ISIN's or Tickers. 4338 date: Optional[datetime.date | str] 4339 Date for which similarity data should be fetched. 4340 identifier_type: Literal["TICKER", "ISIN"] = "TICKER", 4341 Should be set to whatever identifier type is input. Defaults to TICKER. 4342 proxy: str 4343 Your organization may require the use of a proxy for access. 4344 The address of a HTTPS proxy in the format of <address>:<port>. 4345 Examples are "123.456.789:123" or "my.proxy.com:123". 4346 Do not prepend with "https://". 4347 disable_verify_ssl: bool 4348 Your networking setup may be behind a firewall which performs SSL 4349 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 4350 to point to the location of a custom certificate bundle, or set this 4351 parameter to true to disable SSL verification as a workaround. 4352 4353 Returns 4354 ------- 4355 Pandas Dataframe indexed by identifier with a row for every security in the 4356 portfolio (except for those in the input basket). DataFrame will contain 4357 columns: 4358 - overallSimilarityScore: float 4359 - priceSimilarityScore: float 4360 - factorSimilarityScore: float 4361 - correlation: float 4362 """ 4363 4364 if identifier_type not in ["TICKER", "ISIN"]: 4365 raise ValueError( 4366 f"Got unexpected value for arg {identifier_type=}; expected 'TICKER' or 'ISIN'" 4367 ) 4368 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 4369 return client.get_similar_stocks( 4370 model_id=model_id, 4371 portfolio_id=portfolio_id, 4372 symbol_list=identifiers, 4373 date=date, 4374 identifier_type=identifier_type, 4375 ) 4376 4377 4378def getPortfolioTrades( 4379 apikey: str, 4380 model_id: str, 4381 portfolio_id: str, 4382 start_date: Optional[BoostedDate] = None, 4383 end_date: Optional[BoostedDate] = None, 4384 proxy: Optional[str] = None, 4385 disable_verify_ssl: bool = False, 4386) -> pd.DataFrame: 4387 """ 4388 Get the list of trades for a portfolio. NOTE: The max date range is 7 years, 4389 any larger will return an error. 4390 4391 Parameters 4392 ---------- 4393 apikey: str 4394 API key provided by Boosted. This key should be protected as a secret. 4395 model_id: str 4396 UUID of a Boosted model. 4397 portfolio_id: str 4398 UUID of a Boosted portfolio in the given model. 4399 start_date: Optional[datetime.date | str] 4400 Starting date for which trades should be fetched. 4401 end_date: Optional[datetime.date | str] 4402 Ending date for which trades should be fetched. 4403 proxy: str 4404 Your organization may require the use of a proxy for access. 4405 The address of a HTTPS proxy in the format of <address>:<port>. 4406 Examples are "123.456.789:123" or "my.proxy.com:123". 4407 Do not prepend with "https://". 4408 disable_verify_ssl: bool 4409 Your networking setup may be behind a firewall which performs SSL 4410 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 4411 to point to the location of a custom certificate bundle, or set this 4412 parameter to true to disable SSL verification as a workaround. 4413 4414 Returns 4415 ------- 4416 Pandas Dataframe, each row containing data for a security + date. 4417 Columns are: 4418 - isin: str 4419 - ticker: str 4420 - date: datetime.date 4421 - price: float 4422 - shares_owned: float 4423 - shares_traded: float 4424 """ 4425 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 4426 return client.get_portfolio_trades( 4427 model_id=model_id, 4428 portfolio_id=portfolio_id, 4429 start_date=start_date, 4430 end_date=end_date, 4431 ) 4432 4433 4434def getIdeas( 4435 apikey: str, 4436 model_id: str, 4437 portfolio_id: str, 4438 investment_horizon: Literal["1M", "3M", "1Y"] = "1M", 4439 delta_horizon: Literal["1M", "3M", "6M", "9M", "1Y"] = "1M", 4440 proxy: Optional[str] = None, 4441 disable_verify_ssl: bool = False, 4442) -> pd.DataFrame: 4443 """ 4444 Given a model ID, portfolio ID, and a time horizon, return a dataframe of 4445 stock ideas. 4446 4447 Parameters 4448 ---------- 4449 apikey: str 4450 API key provided by Boosted. This key should be protected as a secret. 4451 model_id: str 4452 UUID of a Boosted model. 4453 portfolio_id: str 4454 UUID of a Boosted portfolio in the given model. 4455 investment_horizon: str 4456 Investment time horizon for the ideas. Can be "1M", "3M", "1Y". 4457 delta_horizon: str 4458 Time period over which to compute deltas. Can be "1M", "3M", "6M", "9M", "1Y". 4459 proxy: str 4460 Your organization may require the use of a proxy for access. 4461 The address of a HTTPS proxy in the format of <address>:<port>. 4462 Examples are "123.456.789:123" or "my.proxy.com:123". 4463 Do not prepend with "https://". 4464 disable_verify_ssl: bool 4465 Your networking setup may be behind a firewall which performs SSL 4466 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 4467 to point to the location of a custom certificate bundle, or set this 4468 parameter to true to disable SSL verification as a workaround. 4469 4470 Returns 4471 ------- 4472 Pandas Dataframe, each row containing data for a security. The dataframe is 4473 indexed by ticker. 4474 Columns are: 4475 - recommendation: str 4476 - rating: float 4477 - rating_delta: float 4478 - dividend_yield: float 4479 - predicted_excess_return_1m: float 4480 - predicted_excess_return_3m: float 4481 - predicted_excess_return_1y: float 4482 - risk: str 4483 - reward: str 4484 - reason: str 4485 """ 4486 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 4487 return client.get_ideas( 4488 model_id=model_id, 4489 portfolio_id=portfolio_id, 4490 investment_horizon=investment_horizon, 4491 delta_horizon=delta_horizon, 4492 ) 4493 4494 4495def getStockRecommendationReasons( 4496 apikey: str, 4497 model_id: str, 4498 portfolio_id: str, 4499 investment_horizon: Literal["1M", "3M", "1Y"] = "1M", 4500 symbols: Optional[List[str]] = None, 4501 proxy: Optional[str] = None, 4502 disable_verify_ssl: bool = False, 4503) -> Dict[str, Optional[List[str]]]: 4504 """ 4505 Given a model ID, portfolio ID, symbols, and a time horizon, return a dictionary 4506 of symbols to stock recommendations. 4507 4508 Parameters 4509 ---------- 4510 apikey: str 4511 API key provided by Boosted. This key should be protected as a secret. 4512 model_id: str 4513 UUID of a Boosted model. 4514 portfolio_id: str 4515 UUID of a Boosted portfolio in the given model. 4516 symbols: List[str] 4517 Optional list of symbols for which to fetch reasons. If None, all symbols 4518 for the given portfolio are fetched. 4519 investment_horizon: str 4520 Investment time horizon for the ideas. Can be "1M", "3M", "1Y". 4521 proxy: str 4522 Your organization may require the use of a proxy for access. 4523 The address of a HTTPS proxy in the format of <address>:<port>. 4524 Examples are "123.456.789:123" or "my.proxy.com:123". 4525 Do not prepend with "https://". 4526 disable_verify_ssl: bool 4527 Your networking setup may be behind a firewall which performs SSL 4528 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 4529 to point to the location of a custom certificate bundle, or set this 4530 parameter to true to disable SSL verification as a workaround. 4531 4532 Returns 4533 ------- 4534 Dictionary: 4535 { 4536 <symbol_0>: [reason_0, reason_1, ...], 4537 <symbol_1>: [reason_0, reason_1, ...] 4538 } 4539 Note that for a passed symbol that has no reasons, the symbol will be present 4540 in the dictionary but will not have any elements in its list, i.e. 4541 >>> print(result["SOME_SYMBOL_WITH_NO_REASONS"]) 4542 [] 4543 Additionally, if a passed symbol is not found as a portfolio holding, the symbol 4544 will be present in the dictionary but will be valued None, i.e. 4545 >>> print(result["SOME_SYMBOL_NOT_FOUND"]) 4546 None 4547 """ 4548 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 4549 return client.get_stock_recommendation_reasons( 4550 model_id=model_id, 4551 portfolio_id=portfolio_id, 4552 investment_horizon=investment_horizon, 4553 symbols=symbols, 4554 )
30def inferDependentDataSetSchema(name, df, infer_from_column_names=False): 31 """ 32 Creates a dependent dataset schema by inferring the contents from a Pandas DataFrame. 33 34 Parameters 35 ---------- 36 datasetName: str 37 Name for this dataset. 38 df: pandas.DataFrame 39 Pandas DataFrame containing your data. The index must be 40 DatetimeIndex. The first columns must be ISIN, Country, Currency by default. 41 infer_from_column_names: bool 42 Allows creation of dataset schemas with more flexible identifier columns. 43 Identifier column names must be specified equal to (case and whitespace insensitive) 44 one of the values in boosted.api.api_type.ColumnSubRole. These columns must be grouped 45 together as a block in the first N columns of your dataset, where N is the number of 46 identifiers. 47 48 Returns 49 ------- 50 DatasetConfig 51 A DatasetConfig can be used to create a new dataset. 52 """ 53 return infer_dataset_schema( 54 name, df, DataSetType.STOCK, infer_from_column_names=infer_from_column_names 55 )
Creates a dependent dataset schema by inferring the contents from a Pandas DataFrame.
Parameters
datasetName: str Name for this dataset. df: pandas.DataFrame Pandas DataFrame containing your data. The index must be DatetimeIndex. The first columns must be ISIN, Country, Currency by default. infer_from_column_names: bool Allows creation of dataset schemas with more flexible identifier columns. Identifier column names must be specified equal to (case and whitespace insensitive) one of the values in boosted.api.api_type.ColumnSubRole. These columns must be grouped together as a block in the first N columns of your dataset, where N is the number of identifiers.
Returns
DatasetConfig A DatasetConfig can be used to create a new dataset.
58def inferDependentHistoricalQuarterlyDataSetSchema( 59 name, df, infer_dataset_report_period=True, infer_from_column_names=False 60): 61 """ 62 Creates a dependent dataset schema by inferring the contents from a Pandas DataFrame. 63 64 Parameters 65 ---------- 66 datasetName: str 67 Name for this dataset. 68 df: pandas.DataFrame 69 Pandas DataFrame containing your data. The index must be 70 DatetimeIndex. The first columns must be ISIN, Country, Currency by default. 71 infer_from_column_names: bool 72 Allows creation of dataset schemas with more flexible identifier columns. 73 Identifier column names must be specified equal to (case and whitespace insensitive) 74 one of the values in boosted.api.api_type.ColumnSubRole. These columns must be grouped 75 together as a block in the first N columns of your dataset, where N is the number of 76 identifiers. 77 infer_dataset_report_period: bool 78 Allow the report period to be inferred based on the report date 79 80 Returns 81 ------- 82 DatasetConfig 83 A DatasetConfig can be used to create a new dataset. 84 """ 85 return infer_dataset_schema( 86 name, 87 df, 88 DataSetType.STOCK, 89 dataset_subtype=DataSetSubType.SPARSE_HIST, 90 dataset_frequency=DataSetFrequency.QUARTERLY, 91 infer_dataset_report_period=infer_dataset_report_period, 92 infer_from_column_names=infer_from_column_names, 93 )
Creates a dependent dataset schema by inferring the contents from a Pandas DataFrame.
Parameters
datasetName: str Name for this dataset. df: pandas.DataFrame Pandas DataFrame containing your data. The index must be DatetimeIndex. The first columns must be ISIN, Country, Currency by default. infer_from_column_names: bool Allows creation of dataset schemas with more flexible identifier columns. Identifier column names must be specified equal to (case and whitespace insensitive) one of the values in boosted.api.api_type.ColumnSubRole. These columns must be grouped together as a block in the first N columns of your dataset, where N is the number of identifiers. infer_dataset_report_period: bool Allow the report period to be inferred based on the report date
Returns
DatasetConfig A DatasetConfig can be used to create a new dataset.
96def inferDependentForwardQuarterlyDataSetSchema( 97 name, df, infer_dataset_report_period=True, infer_from_column_names=False 98): 99 """ 100 Creates a dependent dataset schema by inferring the contents from a Pandas DataFrame. 101 102 Parameters 103 ---------- 104 datasetName: str 105 Name for this dataset. 106 df: pandas.DataFrame 107 Pandas DataFrame containing your data. The index must be 108 DatetimeIndex. The first columns must be ISIN, Country, Currency by default. 109 infer_from_column_names: bool 110 Allows creation of dataset schemas with more flexible identifier columns. 111 Identifier column names must be specified equal to (case and whitespace insensitive) 112 one of the values in boosted.api.api_type.ColumnSubRole. These columns must be grouped 113 together as a block in the first N columns of your dataset, where N is the number of 114 identifiers. 115 infer_dataset_report_period: bool 116 Allow the report period to be inferred based on the report date 117 118 Returns 119 ------- 120 DatasetConfig 121 A DatasetConfig can be used to create a new dataset. 122 """ 123 return infer_dataset_schema( 124 name, 125 df, 126 DataSetType.STOCK, 127 dataset_subtype=DataSetSubType.SPARSE_FWD, 128 dataset_frequency=DataSetFrequency.QUARTERLY, 129 infer_dataset_report_period=infer_dataset_report_period, 130 infer_from_column_names=infer_from_column_names, 131 )
Creates a dependent dataset schema by inferring the contents from a Pandas DataFrame.
Parameters
datasetName: str Name for this dataset. df: pandas.DataFrame Pandas DataFrame containing your data. The index must be DatetimeIndex. The first columns must be ISIN, Country, Currency by default. infer_from_column_names: bool Allows creation of dataset schemas with more flexible identifier columns. Identifier column names must be specified equal to (case and whitespace insensitive) one of the values in boosted.api.api_type.ColumnSubRole. These columns must be grouped together as a block in the first N columns of your dataset, where N is the number of identifiers. infer_dataset_report_period: bool Allow the report period to be inferred based on the report date
Returns
DatasetConfig A DatasetConfig can be used to create a new dataset.
134def inferIndependentDataSetSchema(name, df): 135 """ 136 Creates a independent dataset schema by inferring the contents from a Pandas DataFrame. 137 138 Parameters 139 ---------- 140 datasetName: str 141 Name for this dataset. 142 df: pandas.DataFrame 143 Pandas DataFrame containing your data. The index must be 144 DatetimeIndex. The first column must be a unique custom security identifier 145 146 Returns 147 ------- 148 DatasetConfig 149 A DatasetConfig can be used to create a new dataset. 150 """ 151 return infer_dataset_schema(name, df, DataSetType.STRATEGY, infer_from_column_names=False)
Creates a independent dataset schema by inferring the contents from a Pandas DataFrame.
Parameters
datasetName: str Name for this dataset. df: pandas.DataFrame Pandas DataFrame containing your data. The index must be DatetimeIndex. The first column must be a unique custom security identifier
Returns
DatasetConfig A DatasetConfig can be used to create a new dataset.
154def inferGlobalDataSetSchema(name, df): 155 """ 156 Creates a independent dataset schema by inferring the contents from a Pandas DataFrame. 157 158 Parameters 159 ---------- 160 datasetName: str 161 Name for this dataset. 162 df: pandas.DataFrame 163 Pandas DataFrame containing your data. The index must be 164 DatetimeIndex. 165 166 Returns 167 ------- 168 DatasetConfig 169 A DatasetConfig can be used to create a new dataset. 170 """ 171 return infer_dataset_schema(name, df, DataSetType.GLOBAL, infer_from_column_names=False)
Creates a independent dataset schema by inferring the contents from a Pandas DataFrame.
Parameters
datasetName: str Name for this dataset. df: pandas.DataFrame Pandas DataFrame containing your data. The index must be DatetimeIndex.
Returns
DatasetConfig A DatasetConfig can be used to create a new dataset.
174def getDataSetSchema(apikey, dataset_id, proxy=None, disable_verify_ssl=False): 175 """ 176 Retrieves a DataSetConfig representing the schema of an existing dataset. 177 178 Parameters 179 ---------- 180 apikey: str 181 API key provided by Boosted. This key should be protected as a secret. 182 dataset_id: str 183 Dataset ID. Can be from the output of addIndependentDataset or be found 184 in your Custom Data listing in Boosted Insights. 185 proxy: str 186 Your organization may require the use of a proxy for access. 187 The address of a HTTPS proxy in the format of <address>:<port>. 188 Examples are "123.456.789:123" or "my.proxy.com:123". 189 Do not prepend with "https://". 190 disable_verify_ssl: bool 191 Your networking setup may be behind a firewall which performs SSL 192 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 193 to point to the location of a custom certificate bundle, or set this 194 parameter to true to disable SSL verification as a workaround. 195 196 Returns 197 ------- 198 DataSetConfig 199 A DataSetConfig can be used to create a new dataset. 200 """ 201 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 202 return client.get_dataset_schema(dataset_id)
Retrieves a DataSetConfig representing the schema of an existing dataset.
Parameters
apikey: str API key provided by Boosted. This key should be protected as a secret. dataset_id: str Dataset ID. Can be from the output of addIndependentDataset or be found in your Custom Data listing in Boosted Insights. proxy: str Your organization may require the use of a proxy for access. The address of a HTTPS proxy in the format of
:Returns
DataSetConfig A DataSetConfig can be used to create a new dataset.
205def addDependentDataset( 206 apikey, 207 dataset, 208 datasetName="DependentDataset", 209 datasetConfig=None, 210 proxy=None, 211 disable_verify_ssl=False, 212 timeout: int = 600, 213 block: bool = True, 214): 215 """ 216 Creates a new dependent dataset. 217 218 Creates a new dataset by inferring a schema from your dataset. This will 219 also upload the dataset. 220 221 See http://docs.insights.boosted.ai/integrated-data for more information 222 on formatting. 223 224 Parameters 225 ---------- 226 apikey: str 227 API key provided by Boosted. This key should be protected as a secret. 228 dataset: pandas.DataFrame 229 Pandas DataFrame containing your data. The index must be 230 DatetimeIndex. The first columns must be ISIN, Country, Currency, 231 or comprise all identifier columns in the dataset schema if a schema was 232 specified 233 datasetName: str 234 Name for this dataset. 235 datasetConfig: DatasetConfig 236 A pre-configured dataset schema 237 proxy: str 238 Your organization may require the use of a proxy for access. 239 The address of a HTTPS proxy in the format of <address>:<port>. 240 Examples are "123.456.789:123" or "my.proxy.com:123". 241 Do not prepend with "https://". 242 disable_verify_ssl: bool 243 Your networking setup may be behind a firewall which performs SSL 244 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 245 to point to the location of a custom certificate bundle, or set this 246 parameter to true to disable SSL verification as a workaround. 247 timeout: int = 600 248 Number of seconds before a timeout error should be triggered. 249 block: bool = True 250 Whether the python process should block until the dataset is fully 251 uploaded and processed. 252 253 Returns 254 ------- 255 str 256 Dataset ID of the newly created dataset. 257 """ 258 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 259 return client.add_dependent_dataset( 260 dataset, datasetName, datasetConfig, timeout=timeout, block=block 261 )
Creates a new dependent dataset.
Creates a new dataset by inferring a schema from your dataset. This will also upload the dataset.
See http://docs.insights.boosted.ai/integrated-data for more information on formatting.
Parameters
apikey: str API key provided by Boosted. This key should be protected as a secret. dataset: pandas.DataFrame Pandas DataFrame containing your data. The index must be DatetimeIndex. The first columns must be ISIN, Country, Currency, or comprise all identifier columns in the dataset schema if a schema was specified datasetName: str Name for this dataset. datasetConfig: DatasetConfig A pre-configured dataset schema proxy: str Your organization may require the use of a proxy for access. The address of a HTTPS proxy in the format of
:Returns
str Dataset ID of the newly created dataset.
264def addIndependentDataset( 265 apikey, 266 dataset, 267 datasetName="IndependentDataset", 268 datasetConfig=None, 269 proxy=None, 270 disable_verify_ssl=False, 271 timeout: int = 600, 272 block: bool = True, 273): 274 """ 275 Creates a new independent dataset. 276 277 Creates a new dataset by inferring a schema from your dataset. This will 278 also upload the dataset. 279 280 See http://docs.insights.boosted.ai/independent-data for more information 281 on formatting. 282 283 Parameters 284 ---------- 285 apikey: str 286 API key provided by Boosted. This key should be protected as a secret. 287 dataset: pandas.DataFrame 288 Pandas DataFrame containing your data. The index must be 289 DatetimeIndex. The first column must be a unique custom security identifier 290 datasetName: str 291 Name for this dataset. 292 datasetConfig: DatasetConfig 293 A pre-configured dataset schema 294 proxy: str 295 Your organization may require the use of a proxy for access. 296 The address of a HTTPS proxy in the format of <address>:<port>. 297 Examples are "123.456.789:123" or "my.proxy.com:123". 298 Do not prepend with "https://". 299 disable_verify_ssl: bool 300 Your networking setup may be behind a firewall which performs SSL 301 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 302 to point to the location of a custom certificate bundle, or set this 303 parameter to true to disable SSL verification as a workaround. 304 timeout: int = 600 305 Number of seconds before a timeout error should be triggered. 306 block: bool = True 307 Whether the python process should block until the dataset is fully 308 uploaded and processed. 309 310 Returns 311 ------- 312 str 313 Dataset ID of the newly created dataset. 314 """ 315 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 316 return client.add_independent_dataset( 317 dataset, datasetName, datasetConfig, timeout=timeout, block=block 318 )
Creates a new independent dataset.
Creates a new dataset by inferring a schema from your dataset. This will also upload the dataset.
See http://docs.insights.boosted.ai/independent-data for more information on formatting.
Parameters
apikey: str API key provided by Boosted. This key should be protected as a secret. dataset: pandas.DataFrame Pandas DataFrame containing your data. The index must be DatetimeIndex. The first column must be a unique custom security identifier datasetName: str Name for this dataset. datasetConfig: DatasetConfig A pre-configured dataset schema proxy: str Your organization may require the use of a proxy for access. The address of a HTTPS proxy in the format of
:Returns
str Dataset ID of the newly created dataset.
321def addGlobalDataset( 322 apikey, 323 dataset, 324 datasetName="GlobalDataset", 325 datasetConfig=None, 326 proxy=None, 327 disable_verify_ssl=False, 328 timeout: int = 600, 329 block: bool = True, 330): 331 """ 332 Creates a new global dataset. 333 334 Creates a new dataset by inferring a schema from your dataset. This will 335 also upload the dataset. 336 337 See http://docs.insights.boosted.ai/global-data for more information 338 on formatting. 339 340 Parameters 341 ---------- 342 apikey: str 343 API key provided by Boosted. This key should be protected as a secret. 344 dataset: pandas.DataFrame 345 Pandas DataFrame containing your data. The index must be 346 DatetimeIndex. 347 datasetName: str 348 Name for this dataset. 349 datasetConfig: DatasetConfig 350 A pre-configured dataset schema 351 proxy: str 352 Your organization may require the use of a proxy for access. 353 The address of a HTTPS proxy in the format of <address>:<port>. 354 Examples are "123.456.789:123" or "my.proxy.com:123". 355 Do not prepend with "https://". 356 disable_verify_ssl: bool 357 Your networking setup may be behind a firewall which performs SSL 358 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 359 to point to the location of a custom certificate bundle, or set this 360 parameter to true to disable SSL verification as a workaround. 361 timeout: int = 600 362 Number of seconds before a timeout error should be triggered. 363 block: bool = True 364 Whether the python process should block until the dataset is fully 365 uploaded and processed. 366 367 Returns 368 ------- 369 str 370 Dataset ID of the newly created dataset. 371 """ 372 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 373 return client.add_global_dataset( 374 dataset, datasetName, datasetConfig, timeout=timeout, block=block 375 )
Creates a new global dataset.
Creates a new dataset by inferring a schema from your dataset. This will also upload the dataset.
See http://docs.insights.boosted.ai/global-data for more information on formatting.
Parameters
apikey: str API key provided by Boosted. This key should be protected as a secret. dataset: pandas.DataFrame Pandas DataFrame containing your data. The index must be DatetimeIndex. datasetName: str Name for this dataset. datasetConfig: DatasetConfig A pre-configured dataset schema proxy: str Your organization may require the use of a proxy for access. The address of a HTTPS proxy in the format of
:Returns
str Dataset ID of the newly created dataset.
378def exportDependentDataset( 379 apikey, dataset_id, proxy=None, disable_verify_ssl=False, timeout: int = 600 380): 381 """ 382 Exports an existing dependent dataset. 383 384 Exports an existing dataset identified by a dataset ID. Returns the data 385 as a Pandas DataFrame. 386 387 Parameters 388 ---------- 389 apikey: str 390 API key provided by Boosted. This key should be protected as a secret. 391 dataset_id: str 392 Dataset ID. Can be from the output of addDependentDataset or be found 393 in your Custom Data listing in Boosted Insights. 394 proxy: str 395 Your organization may require the use of a proxy for access. 396 The address of a HTTPS proxy in the format of <address>:<port>. 397 Examples are "123.456.789:123" or "my.proxy.com:123". 398 Do not prepend with "https://". 399 disable_verify_ssl: bool 400 Your networking setup may be behind a firewall which performs SSL 401 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 402 to point to the location of a custom certificate bundle, or set this 403 parameter to true to disable SSL verification as a workaround. 404 timeout: int = 600 405 Number of seconds before a timeout error should be triggered. 406 407 Returns 408 ------- 409 pandas.DataFrame 410 Pandas DataFrame containing your data that will be indexed by the date. 411 The DataFrame schema is identical to the one used to upload a dataset. 412 """ 413 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 414 return client.export_dependent_data(dataset_id, timeout=timeout)
Exports an existing dependent dataset.
Exports an existing dataset identified by a dataset ID. Returns the data as a Pandas DataFrame.
Parameters
apikey: str API key provided by Boosted. This key should be protected as a secret. dataset_id: str Dataset ID. Can be from the output of addDependentDataset or be found in your Custom Data listing in Boosted Insights. proxy: str Your organization may require the use of a proxy for access. The address of a HTTPS proxy in the format of
:Returns
pandas.DataFrame Pandas DataFrame containing your data that will be indexed by the date. The DataFrame schema is identical to the one used to upload a dataset.
417def exportIndependentDataset( 418 apikey, 419 dataset_id, 420 proxy=None, 421 disable_verify_ssl=False, 422 timeout: int = 600, 423): 424 """ 425 Exports an existing independent dataset. 426 427 Exports an existing dataset identified by a dataset ID. Returns the data 428 as a Pandas DataFrame. 429 430 Parameters 431 ---------- 432 apikey: str 433 API key provided by Boosted. This key should be protected as a secret. 434 dataset_id: str 435 Dataset ID. Can be from the output of addIndependentDataset or be found 436 in your Custom Data listing in Boosted Insights. 437 proxy: str 438 Your organization may require the use of a proxy for access. 439 The address of a HTTPS proxy in the format of <address>:<port>. 440 Examples are "123.456.789:123" or "my.proxy.com:123". 441 Do not prepend with "https://". 442 disable_verify_ssl: bool 443 Your networking setup may be behind a firewall which performs SSL 444 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 445 to point to the location of a custom certificate bundle, or set this 446 parameter to true to disable SSL verification as a workaround. 447 timeout: int = 600 448 Number of seconds before a timeout error should be triggered. 449 450 Returns 451 ------- 452 pandas.DataFrame 453 Pandas DataFrame containing your data that will be indexed by the date. 454 The DataFrame schema is identical to the one used to upload a dataset. 455 """ 456 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 457 return client.export_independent_data(dataset_id, timeout=timeout)
Exports an existing independent dataset.
Exports an existing dataset identified by a dataset ID. Returns the data as a Pandas DataFrame.
Parameters
apikey: str API key provided by Boosted. This key should be protected as a secret. dataset_id: str Dataset ID. Can be from the output of addIndependentDataset or be found in your Custom Data listing in Boosted Insights. proxy: str Your organization may require the use of a proxy for access. The address of a HTTPS proxy in the format of
:Returns
pandas.DataFrame Pandas DataFrame containing your data that will be indexed by the date. The DataFrame schema is identical to the one used to upload a dataset.
460def exportGlobalDataset( 461 apikey, dataset_id, proxy=None, disable_verify_ssl=False, timeout: int = 600 462): 463 """ 464 Exports an existing global dataset. 465 466 Exports an existing dataset identified by a dataset ID. Returns the data 467 as a Pandas DataFrame. 468 469 Parameters 470 ---------- 471 apikey: str 472 API key provided by Boosted. This key should be protected as a secret. 473 dataset_id: str 474 Dataset ID. Can be from the output of addGlobalDataset or be found 475 in your Custom Data listing in Boosted Insights. 476 proxy: str 477 Your organization may require the use of a proxy for access. 478 The address of a HTTPS proxy in the format of <address>:<port>. 479 Examples are "123.456.789:123" or "my.proxy.com:123". 480 Do not prepend with "https://". 481 disable_verify_ssl: bool 482 Your networking setup may be behind a firewall which performs SSL 483 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 484 to point to the location of a custom certificate bundle, or set this 485 parameter to true to disable SSL verification as a workaround. 486 timeout: int = 600 487 Number of seconds before a timeout error should be triggered. 488 489 Returns 490 ------- 491 pandas.DataFrame 492 Pandas DataFrame containing your data that will be indexed by the date. 493 The DataFrame schema is identical to the one used to upload a dataset. 494 """ 495 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 496 return client.export_global_data(dataset_id, timeout=timeout)
Exports an existing global dataset.
Exports an existing dataset identified by a dataset ID. Returns the data as a Pandas DataFrame.
Parameters
apikey: str API key provided by Boosted. This key should be protected as a secret. dataset_id: str Dataset ID. Can be from the output of addGlobalDataset or be found in your Custom Data listing in Boosted Insights. proxy: str Your organization may require the use of a proxy for access. The address of a HTTPS proxy in the format of
:Returns
pandas.DataFrame Pandas DataFrame containing your data that will be indexed by the date. The DataFrame schema is identical to the one used to upload a dataset.
499def addDependentData( 500 apikey, 501 dataset_id, 502 dataset, 503 proxy=None, 504 disable_verify_ssl=False, 505 timeout: int = 600, 506 block: bool = True, 507): 508 """ 509 Adds data to an existing dependent dataset. 510 511 This uploads the data in ``dataset`` to an existing dataset. Existing 512 date/ISIN pairs will be overwritten. 513 514 Parameters 515 ---------- 516 apikey: str 517 API key provided by Boosted. This key should be protected as a secret. 518 dataset_id: str 519 Dataset ID. Can be from the output of addDependentDataset or be found 520 in your Custom Data listing in Boosted Insights. 521 dataset: pandas.DataFrame 522 Pandas DataFrame containing your data. The index must be 523 DatetimeIndex. The first columns must comprise all identifier columns in the 524 dataset schema. 525 proxy: str 526 Your organization may require the use of a proxy for access. 527 The address of a HTTPS proxy in the format of <address>:<port>. 528 Examples are "123.456.789:123" or "my.proxy.com:123". 529 Do not prepend with "https://". 530 disable_verify_ssl: bool 531 Your networking setup may be behind a firewall which performs SSL 532 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 533 to point to the location of a custom certificate bundle, or set this 534 parameter to true to disable SSL verification as a workaround. 535 timeout: int = 600 536 Number of seconds before a timeout error should be triggered. 537 block: bool = True 538 Whether the python process should block until the dataset is fully 539 uploaded and processed. 540 541 Returns 542 ------- 543 None 544 """ 545 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 546 return client.add_dependent_data( 547 dataset_id, dataset, timeout=timeout, block=block, data_type=DataAddType.HISTORICAL 548 )
Adds data to an existing dependent dataset.
This uploads the data in dataset
to an existing dataset. Existing
date/ISIN pairs will be overwritten.
Parameters
apikey: str API key provided by Boosted. This key should be protected as a secret. dataset_id: str Dataset ID. Can be from the output of addDependentDataset or be found in your Custom Data listing in Boosted Insights. dataset: pandas.DataFrame Pandas DataFrame containing your data. The index must be DatetimeIndex. The first columns must comprise all identifier columns in the dataset schema. proxy: str Your organization may require the use of a proxy for access. The address of a HTTPS proxy in the format of
:Returns
None
551def addIndependentData( 552 apikey, 553 dataset_id, 554 dataset, 555 proxy=None, 556 disable_verify_ssl=False, 557 timeout: int = 600, 558 block: bool = True, 559): 560 """ 561 Adds data to an existing independent dataset. 562 563 This uploads the data in ``dataset`` to an existing dataset. Existing 564 dates will be overwritten. 565 566 Parameters 567 ---------- 568 apikey: str 569 API key provided by Boosted. This key should be protected as a secret. 570 dataset_id: str 571 Dataset ID. Can be from the output of addIndependentDataset or be found 572 in your Custom Data listing in Boosted Insights. 573 dataset: pandas.DataFrame 574 Pandas DataFrame containing your data. The index must be 575 DatetimeIndex. 576 proxy: str 577 Your organization may require the use of a proxy for access. 578 The address of a HTTPS proxy in the format of <address>:<port>. 579 Examples are "123.456.789:123" or "my.proxy.com:123". 580 Do not prepend with "https://". 581 disable_verify_ssl: bool 582 Your networking setup may be behind a firewall which performs SSL 583 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 584 to point to the location of a custom certificate bundle, or set this 585 parameter to true to disable SSL verification as a workaround. 586 timeout: int = 600 587 Number of seconds before a timeout error should be triggered. 588 block: bool = True 589 Whether the python process should block until the dataset is fully 590 uploaded and processed. 591 592 Returns 593 ------- 594 None 595 """ 596 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 597 return client.add_independent_data( 598 dataset_id, dataset, timeout=timeout, block=block, data_type=DataAddType.HISTORICAL 599 )
Adds data to an existing independent dataset.
This uploads the data in dataset
to an existing dataset. Existing
dates will be overwritten.
Parameters
apikey: str API key provided by Boosted. This key should be protected as a secret. dataset_id: str Dataset ID. Can be from the output of addIndependentDataset or be found in your Custom Data listing in Boosted Insights. dataset: pandas.DataFrame Pandas DataFrame containing your data. The index must be DatetimeIndex. proxy: str Your organization may require the use of a proxy for access. The address of a HTTPS proxy in the format of
:Returns
None
602def addGlobalData( 603 apikey, 604 dataset_id, 605 dataset, 606 proxy=None, 607 disable_verify_ssl=False, 608 timeout: int = 600, 609 block: bool = True, 610): 611 """ 612 Adds data to an existing global dataset. 613 614 This uploads the data in ``dataset`` to an existing dataset. Existing 615 date/custom security identifier pairs will be overwritten. 616 617 Parameters 618 ---------- 619 apikey: str 620 API key provided by Boosted. This key should be protected as a secret. 621 dataset_id: str 622 Dataset ID. Can be from the output of addGlobalDataset or be found 623 in your Custom Data listing in Boosted Insights. 624 dataset: pandas.DataFrame 625 Pandas DataFrame containing your data. The index must be 626 DatetimeIndex. The first column must be custom security identifier 627 proxy: str 628 Your organization may require the use of a proxy for access. 629 The address of a HTTPS proxy in the format of <address>:<port>. 630 Examples are "123.456.789:123" or "my.proxy.com:123". 631 Do not prepend with "https://". 632 disable_verify_ssl: bool 633 Your networking setup may be behind a firewall which performs SSL 634 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 635 to point to the location of a custom certificate bundle, or set this 636 parameter to true to disable SSL verification as a workaround. 637 timeout: int = 600 638 Number of seconds before a timeout error should be triggered. 639 block: bool = True 640 Whether the python process should block until the dataset is fully 641 uploaded and processed. 642 643 Returns 644 ------- 645 None 646 """ 647 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 648 return client.add_global_data( 649 dataset_id, dataset, timeout=timeout, block=block, data_type=DataAddType.HISTORICAL 650 )
Adds data to an existing global dataset.
This uploads the data in dataset
to an existing dataset. Existing
date/custom security identifier pairs will be overwritten.
Parameters
apikey: str API key provided by Boosted. This key should be protected as a secret. dataset_id: str Dataset ID. Can be from the output of addGlobalDataset or be found in your Custom Data listing in Boosted Insights. dataset: pandas.DataFrame Pandas DataFrame containing your data. The index must be DatetimeIndex. The first column must be custom security identifier proxy: str Your organization may require the use of a proxy for access. The address of a HTTPS proxy in the format of
:Returns
None
653def addLiveDependentData( 654 apikey, 655 dataset_id, 656 dataset, 657 proxy=None, 658 disable_verify_ssl=False, 659 timeout: int = 600, 660 block: bool = True, 661): 662 """ 663 Adds live data to an existing dependent dataset. 664 665 This uploads the data in ``dataset`` to an existing dataset. Existing 666 date/ISIN pairs will be overwritten. 667 668 Parameters 669 ---------- 670 apikey: str 671 API key provided by Boosted. This key should be protected as a secret. 672 dataset_id: str 673 Dataset ID. Can be from the output of addDependentDataset or be found 674 in your Custom Data listing in Boosted Insights. 675 dataset: pandas.DataFrame 676 Pandas DataFrame containing your data. The index must be 677 DatetimeIndex. The first columns must be ISIN, Country, Currency. 678 proxy: str 679 Your organization may require the use of a proxy for access. 680 The address of a HTTPS proxy in the format of <address>:<port>. 681 Examples are "123.456.789:123" or "my.proxy.com:123". 682 Do not prepend with "https://". 683 disable_verify_ssl: bool 684 Your networking setup may be behind a firewall which performs SSL 685 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 686 to point to the location of a custom certificate bundle, or set this 687 parameter to true to disable SSL verification as a workaround. 688 timeout: int = 600 689 Number of seconds before a timeout error should be triggered. 690 block: bool = True 691 Whether the python process should block until the dataset is fully 692 uploaded and processed. 693 694 Returns 695 ------- 696 None 697 """ 698 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 699 return client.add_dependent_data( 700 dataset_id, dataset, timeout=timeout, block=block, data_type=DataAddType.LIVE 701 )
Adds live data to an existing dependent dataset.
This uploads the data in dataset
to an existing dataset. Existing
date/ISIN pairs will be overwritten.
Parameters
apikey: str API key provided by Boosted. This key should be protected as a secret. dataset_id: str Dataset ID. Can be from the output of addDependentDataset or be found in your Custom Data listing in Boosted Insights. dataset: pandas.DataFrame Pandas DataFrame containing your data. The index must be DatetimeIndex. The first columns must be ISIN, Country, Currency. proxy: str Your organization may require the use of a proxy for access. The address of a HTTPS proxy in the format of
:Returns
None
704def addLiveIndependentData( 705 apikey, 706 dataset_id, 707 dataset, 708 proxy=None, 709 disable_verify_ssl=False, 710 timeout: int = 600, 711 block: bool = True, 712): 713 """ 714 Adds live data to an existing independent dataset. 715 716 This uploads the data in ``dataset`` to an existing dataset. Existing 717 dates will be overwritten. 718 719 Parameters 720 ---------- 721 apikey: str 722 API key provided by Boosted. This key should be protected as a secret. 723 dataset_id: str 724 Dataset ID. Can be from the output of addIndependentDataset or be found 725 in your Custom Data listing in Boosted Insights. 726 dataset: pandas.DataFrame 727 Pandas DataFrame containing your data. The index must be 728 DatetimeIndex. 729 proxy: str 730 Your organization may require the use of a proxy for access. 731 The address of a HTTPS proxy in the format of <address>:<port>. 732 Examples are "123.456.789:123" or "my.proxy.com:123". 733 Do not prepend with "https://". 734 disable_verify_ssl: bool 735 Your networking setup may be behind a firewall which performs SSL 736 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 737 to point to the location of a custom certificate bundle, or set this 738 parameter to true to disable SSL verification as a workaround. 739 timeout: int = 600 740 Number of seconds before a timeout error should be triggered. 741 block: bool = True 742 Whether the python process should block until the dataset is fully 743 uploaded and processed. 744 745 Returns 746 ------- 747 None 748 """ 749 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 750 return client.add_independent_data( 751 dataset_id, dataset, timeout=timeout, block=block, data_type=DataAddType.LIVE 752 )
Adds live data to an existing independent dataset.
This uploads the data in dataset
to an existing dataset. Existing
dates will be overwritten.
Parameters
apikey: str API key provided by Boosted. This key should be protected as a secret. dataset_id: str Dataset ID. Can be from the output of addIndependentDataset or be found in your Custom Data listing in Boosted Insights. dataset: pandas.DataFrame Pandas DataFrame containing your data. The index must be DatetimeIndex. proxy: str Your organization may require the use of a proxy for access. The address of a HTTPS proxy in the format of
:Returns
None
755def addLiveGlobalData( 756 apikey, 757 dataset_id, 758 dataset, 759 proxy=None, 760 disable_verify_ssl=False, 761 timeout: int = 600, 762 block: bool = True, 763): 764 """ 765 Adds live data to an existing global dataset. 766 767 This uploads the data in ``dataset`` to an existing dataset. Existing 768 date/custom security identifier pairs will be overwritten. 769 770 Parameters 771 ---------- 772 apikey: str 773 API key provided by Boosted. This key should be protected as a secret. 774 dataset_id: str 775 Dataset ID. Can be from the output of addGlobalDataset or be found 776 in your Custom Data listing in Boosted Insights. 777 dataset: pandas.DataFrame 778 Pandas DataFrame containing your data. The index must be 779 DatetimeIndex. The first column must be custom security identifier 780 proxy: str 781 Your organization may require the use of a proxy for access. 782 The address of a HTTPS proxy in the format of <address>:<port>. 783 Examples are "123.456.789:123" or "my.proxy.com:123". 784 Do not prepend with "https://". 785 disable_verify_ssl: bool 786 Your networking setup may be behind a firewall which performs SSL 787 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 788 to point to the location of a custom certificate bundle, or set this 789 parameter to true to disable SSL verification as a workaround. 790 timeout: int = 600 791 Number of seconds before a timeout error should be triggered. 792 block: bool = True 793 Whether the python process should block until the dataset is fully 794 uploaded and processed. 795 796 Returns 797 ------- 798 None 799 """ 800 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 801 return client.add_global_data( 802 dataset_id, dataset, timeout=timeout, block=block, data_type=DataAddType.LIVE 803 )
Adds live data to an existing global dataset.
This uploads the data in dataset
to an existing dataset. Existing
date/custom security identifier pairs will be overwritten.
Parameters
apikey: str API key provided by Boosted. This key should be protected as a secret. dataset_id: str Dataset ID. Can be from the output of addGlobalDataset or be found in your Custom Data listing in Boosted Insights. dataset: pandas.DataFrame Pandas DataFrame containing your data. The index must be DatetimeIndex. The first column must be custom security identifier proxy: str Your organization may require the use of a proxy for access. The address of a HTTPS proxy in the format of
:Returns
None
806def queryDataset(apikey, dataset_id, proxy=None, disable_verify_ssl=False): 807 """ 808 Queries the status, timerange of a dataset. 809 810 Returns meta-information about a dataset. This can be used to check the 811 dateranges covered and the current status. 812 813 Parameters 814 ---------- 815 apikey: str 816 API key provided by Boosted. This key should be protected as a secret. 817 dataset_id: str 818 Dataset ID. Can be from the output of addDependentDataset or be found 819 in your Custom Data listing in Boosted Insights. 820 proxy: str 821 Your organization may require the use of a proxy for access. 822 The address of a HTTPS proxy in the format of <address>:<port>. 823 Examples are "123.456.789:123" or "my.proxy.com:123". 824 Do not prepend with "https://". 825 disable_verify_ssl: bool 826 Your networking setup may be behind a firewall which performs SSL 827 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 828 to point to the location of a custom certificate bundle, or set this 829 parameter to true to disable SSL verification as a workaround. 830 831 Returns 832 ------- 833 dict: 834 Dictionary containing meta-data about the dataset. 835 836 'created': <creation date>, 837 'fileSize': <file size>, 838 'id': <dataset ID>, 839 'name': <dataset name>, 840 'ownerId': <owner ID>, 841 'region': <dataset region>, 842 'status': {AVAILABLE|UPDATING|CREATING|ERROR}, 843 'type': {STOCK|STRATEGY|GLOBAL}, 844 'universeId': <universe ID>, 845 'validFrom': [YYYY, MM, DD], 846 'validTo': [YYYY, MM, DD]} 847 848 """ 849 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 850 return client.query_dataset(dataset_id)
Queries the status, timerange of a dataset.
Returns meta-information about a dataset. This can be used to check the dateranges covered and the current status.
Parameters
apikey: str API key provided by Boosted. This key should be protected as a secret. dataset_id: str Dataset ID. Can be from the output of addDependentDataset or be found in your Custom Data listing in Boosted Insights. proxy: str Your organization may require the use of a proxy for access. The address of a HTTPS proxy in the format of
:Returns
dict: Dictionary containing meta-data about the dataset.
'created': <creation date>,
'fileSize': <file size>,
'id': <dataset ID>,
'name': <dataset name>,
'ownerId': <owner ID>,
'region': <dataset region>,
'status': {AVAILABLE|UPDATING|CREATING|ERROR},
'type': {STOCK|STRATEGY|GLOBAL},
'universeId': <universe ID>,
'validFrom': [YYYY, MM, DD],
'validTo': [YYYY, MM, DD]}
853def getUniverse(apikey, model_id, date=None, proxy=None, disable_verify_ssl=False): 854 """ 855 Returns the universe members of a model. 856 857 Returns the members of the universe of a model. If no date is provided, 858 effective date ranges will be returned. If a date is provided, only the 859 universe members of that date are returned. The results are returned in a 860 Pandas DataFrame. 861 862 For more information, see http://docs.insights.boosted.ai/universe-upload. 863 864 Parameters 865 ---------- 866 apikey: str 867 API key provided by Boosted. This key should be protected as a secret. 868 model_id: str 869 Model ID. Model IDs can be retrieved by clicking on the copy to clipboard 870 button next to your model's name in the Model Summary Page in Boosted 871 Insights. 872 date: datetime.date or YYYY-MM-DD string 873 Date of the universe to retrieve. 874 proxy: str 875 Your organization may require the use of a proxy for access. 876 The address of a HTTPS proxy in the format of <address>:<port>. 877 Examples are "123.456.789:123" or "my.proxy.com:123". 878 Do not prepend with "https://". 879 disable_verify_ssl: bool 880 Your networking setup may be behind a firewall which performs SSL 881 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 882 to point to the location of a custom certificate bundle, or set this 883 parameter to true to disable SSL verification as a workaround. 884 885 Returns 886 ------- 887 pandas.DataFrame 888 Pandas DataFrame containing the universe members. If a date was 889 provided, only ISIN, Country, and Currency are returned. If no date 890 was provided, returns From, To, ISIN, Country, Currency. 891 """ 892 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 893 return client.getUniverse(model_id, date)
Returns the universe members of a model.
Returns the members of the universe of a model. If no date is provided, effective date ranges will be returned. If a date is provided, only the universe members of that date are returned. The results are returned in a Pandas DataFrame.
For more information, see http://docs.insights.boosted.ai/universe-upload.
Parameters
apikey: str API key provided by Boosted. This key should be protected as a secret. model_id: str Model ID. Model IDs can be retrieved by clicking on the copy to clipboard button next to your model's name in the Model Summary Page in Boosted Insights. date: datetime.date or YYYY-MM-DD string Date of the universe to retrieve. proxy: str Your organization may require the use of a proxy for access. The address of a HTTPS proxy in the format of
:Returns
pandas.DataFrame Pandas DataFrame containing the universe members. If a date was provided, only ISIN, Country, and Currency are returned. If no date was provided, returns From, To, ISIN, Country, Currency.
896def updateUniverse( 897 apikey, 898 model_id, 899 universe_df, 900 date=datetime.date.today() + timedelta(1), 901 proxy=None, 902 disable_verify_ssl=False, 903): 904 """ 905 Sets the universe members of a model. 906 907 Sets the members of the universe of a model. Universe members may only be 908 set for future dates. 909 910 For more information, see http://docs.insights.boosted.ai/universe-upload. 911 912 Parameters 913 ---------- 914 apikey: str 915 API key provided by Boosted. This key should be protected as a secret. 916 model_id: str 917 Model ID. Model IDs can be retrieved by clicking on the copy to clipboard 918 button next to your model's name in the Model Summary Page in Boosted 919 Insights. 920 universe_df: Pandas.DataFrame 921 A Pandas.DataFrame with columns ISIN, Country, Currency. 922 date: datetime.date or YYYY-MM-DD string 923 Date of the universe to retrieve. 924 proxy: str 925 Your organization may require the use of a proxy for access. 926 The address of a HTTPS proxy in the format of <address>:<port>. 927 Examples are "123.456.789:123" or "my.proxy.com:123". 928 Do not prepend with "https://". 929 disable_verify_ssl: bool 930 Your networking setup may be behind a firewall which performs SSL 931 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 932 to point to the location of a custom certificate bundle, or set this 933 parameter to true to disable SSL verification as a workaround. 934 935 Returns 936 ------- 937 str 938 Any warnings, e.g. failure to map ISINs, are returned. 939 """ 940 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 941 return client.updateUniverse(model_id, universe_df, date)
Sets the universe members of a model.
Sets the members of the universe of a model. Universe members may only be set for future dates.
For more information, see http://docs.insights.boosted.ai/universe-upload.
Parameters
apikey: str API key provided by Boosted. This key should be protected as a secret. model_id: str Model ID. Model IDs can be retrieved by clicking on the copy to clipboard button next to your model's name in the Model Summary Page in Boosted Insights. universe_df: Pandas.DataFrame A Pandas.DataFrame with columns ISIN, Country, Currency. date: datetime.date or YYYY-MM-DD string Date of the universe to retrieve. proxy: str Your organization may require the use of a proxy for access. The address of a HTTPS proxy in the format of
:Returns
str Any warnings, e.g. failure to map ISINs, are returned.
944def createUniverse( 945 apikey: str, 946 universe: Union[pd.DataFrame, str], 947 name: str, 948 description: Optional[str] = None, 949 proxy=None, 950 disable_verify_ssl=False, 951) -> List[str]: 952 """ 953 Creates a new boosted security universe. 954 955 Columns in the universe (dataframe or csv file path) to identify the 956 universe are isin and/or symbol, from, to, country, currency. 957 958 Note that either isin or symbol are required columns. 959 960 Rules for the universe data are identical to those on the web universe 961 creation screen: 962 - Make sure your CSV does not contain empty columns. 963 - Date columns must be in YYYY-MM-DD format. 964 - The "from" and "to" fields represent the date range for which a 965 security will exist in the universe for. The keyword "PRESENT" can be used 966 in place of the "to_date" field. If you wish to create a Live model, ensure that 967 at least some securities have "PRESENT" as their "to_date" field. 968 - If the "to_date" column is ommitted, securites will exist in the universe 969 until "PRESENT" by default, if possible. 970 - "from" will default to "the beginning of time" if unspecified, and 971 "to" will default to "PRESENT" 972 973 - The keyword "ANY" can also be used in place of the country and currency 974 fields. 975 - Rows with "ANY" will select the optimal security based on other securities 976 in the portfolio For Country and Currency, the prefix "P_" (i.e. "P_USA") 977 means "preferred." The model will attempt to match the security to the 978 preferred specification. 979 - "country" and "currency" will default to "ANY" if the column was 980 omitted. 981 982 Parameters 983 ---------- 984 apikey: str 985 API key provided by Boosted. This key should be protected as a secret. 986 universe: Union[Pandas.DataFrame, str] 987 May be either a Pandas.DataFrame, or a path to a csv. 988 name: str 989 The name of the new universe. 990 description: str 991 Optional description of the new universe. 992 proxy: str 993 Your organization may require the use of a proxy for access. 994 The address of a HTTPS proxy in the format of <address>:<port>. 995 Examples are "123.456.789:123" or "my.proxy.com:123". 996 Do not prepend with "https://". 997 disable_verify_ssl: bool 998 Your networking setup may be behind a firewall which performs SSL 999 inspection. Either set the REQUESTS_CA_BUNDLE environment variable 1000 to point to the location of a custom certificate bundle, or set this 1001 parameter to true to disable SSL verification as a workaround. 1002 1003 Returns 1004 ------- 1005 List[str] 1006 List of any warnings, e.g. failure to map ISINs, are returned. Return 1007 empty list if no warnings are returned. 1008 """ 1009 client = BoostedClient(apikey, proxy=proxy, disable_verify_ssl=disable_verify_ssl) 1010 description = "" if description is None else description 1011 return client.create_universe(universe, name, description)
Creates a new boosted security universe.
Columns in the universe (dataframe or csv file path) to identify the universe are isin and/or symbol, from, to, country, currency.
Note that either isin or symbol are required columns.
Rules for the universe data are identical to those on the web universe creation screen:
- Make sure your CSV does not contain empty columns.
- Date columns must be in YYYY-MM-DD format.
- The "from" and "to" fields represent the date range for which a security will exist in the universe for. The keyword "PRESENT" can be used in place of the "to_date" field. If you wish to create a Live model, ensure that at least some securities have "PRESENT" as their "to_date" field.
- If the "to_date" column is ommitted, securites will exist in the universe until "PRESENT" by default, if possible.
- "from" will default to "the beginning of time" if unspecified, and "to" will default to "PRESENT"
- The keyword "ANY" can also be used in place of the country and currency fields.
- Rows with "ANY" will select the optimal security based on other securities in the portfolio For Country and Currency, the prefix "P_" (i.e. "P_USA") means "preferred." The model will attempt to match the security to the preferred specification.
- "country" and "currency" will default to "ANY" if the column was omitted.
Parameters
apikey: str API key provided by Boosted. This key should be protected as a secret. universe: Union[Pandas.DataFrame, str] May be either a Pandas.DataFrame, or a path to a csv. name: str The name of the new universe. description: str Optional description of the new universe. proxy: str Your organization may require the use of a proxy for access. The address of a HTTPS proxy in the format of
:Returns
List[str] List of any warnings, e.g. failure to map ISINs, are returned. Return empty list if no warnings are returned.
1014def