dve-lumipy-testing 1.0.389__py3-none-any.whl → 1.0.390__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: dve-lumipy-testing
3
- Version: 1.0.389
3
+ Version: 1.0.390
4
4
  Summary: Python library for Luminesce
5
5
  Author: FINBOURNE Technology
6
6
  Author-email: engineering@finbourne.com
@@ -91,37 +91,6 @@ lm.config.add('fbn-ci', '<your PAT>')
91
91
  lm.config.domain = 'fbn-ci'
92
92
  ```
93
93
 
94
- ## Query
95
- All built around the atlas object. This is the starting point for exploring your data sources and then using them.
96
-
97
- Build your atlas with `lm.get_atlas`. If you don't supply credentials it will default to your active domain in the config.
98
- If there is no active domain in your config it will fall back to env vars.
99
- ```python
100
- import lumipy as lm
101
-
102
- atlas = lm.get_atlas()
103
-
104
- ins = atlas.lusid_instrument()
105
- ins.select('^').limit(10).go()
106
- ```
107
- You can also specify the domain here by a positional argument, e.g. `lm.get_atlas('fbn-ci')` will use `fbn-ci` and will override the active domain.
108
-
109
- Client objects are created in the same way. You can submit raw SQL strings as queries using `run()`
110
- ```python
111
- import lumipy as lm
112
-
113
- client = lm.get_client()
114
- client.run('select ^ from lusid.instrument limit 10')
115
- ```
116
-
117
- You can create a `client` or `atlas` for a domain other than the active one by specifying it in `get_client` or `get_atlas`.
118
- ```python
119
- import lumipy as lm
120
-
121
- client = lm.get_client('fbn-prd')
122
- atlas = lm.get_atlas('fbn-prd')
123
- ```
124
-
125
94
  ## Connect
126
95
 
127
96
  Python providers are build by inheriting from a base class, `BaseProvider`, and implementing the `__init__` and `get_data` methods.
@@ -273,7 +242,7 @@ Directory
273
242
  ```
274
243
 
275
244
 
276
- ## Query
245
+ ## Query Using SQL
277
246
  This command runs a SQL query, gets the result back, shows it on screen and then saves it as a CSV.
278
247
 
279
248
  ### Query Examples
@@ -352,9 +321,11 @@ Authenticate by setting up the PAT token via the CLI or directly in Python (see
352
321
 
353
322
  ### Secrets File
354
323
  Initialize `get_client` using a secrets file:
324
+
355
325
  ```python
356
326
  client = get_client(api_secrets_file="secrets_file_path/secrets.json")
357
327
  ```
328
+
358
329
  File structure should be:
359
330
  ```json
360
331
  {
@@ -407,3 +378,211 @@ The following environment variables can also be set:
407
378
  - FBN_PROXY_USERNAME
408
379
  - FBN_PROXY_PASSWORD
409
380
  - FBN_ACCESS_TOKEN
381
+
382
+ # Lumipy Atlas and LumiFlex
383
+
384
+ This guide demonstrates how to use the Lumipy Atlas interface to query data providers, transform data, join datasets, create views, and interact with external services like AWS S3, Drive, and Slack.
385
+
386
+
387
+ ### Query
388
+
389
+ All built around the `atlas` object. This is the starting point for exploring your data sources and then using them.
390
+
391
+ Build your atlas with `lm.get_atlas`. If you don't supply credentials it will default to your active domain in the config.
392
+ If there is no active domain in your config it will fall back to env vars.
393
+
394
+ ```python
395
+ import lumipy as lm
396
+
397
+ atlas = lm.get_atlas()
398
+
399
+ ins = atlas.lusid_instrument()
400
+ ins.select('^').limit(10).go()
401
+ ```
402
+
403
+ You can also specify the domain here by a positional argument, e.g. `lm.get_atlas('fbn-ci')` will use `fbn-ci` and will override the active domain.
404
+
405
+ Client objects are created in the same way. You can submit raw SQL strings as queries using `run()`
406
+
407
+ ```python
408
+ import lumipy as lm
409
+
410
+ client = lm.get_client()
411
+ client.run('select ^ from lusid.instrument limit 10')
412
+ ```
413
+
414
+ You can create a `client` or `atlas` for a domain other than the active one by specifying it in `get_client` or `get_atlas`.
415
+
416
+ ```python
417
+ import lumipy as lm
418
+
419
+ client = lm.get_client('fbn-prd')
420
+ atlas = lm.get_atlas('fbn-prd')
421
+ ```
422
+
423
+
424
+
425
+ ### Querying a Provider
426
+
427
+ ```python
428
+ pf = atlas.lusid_portfolio(as_at=dt.datetime(2022, 9, 1))
429
+ df = pf.select('*').limit(10).go()
430
+ ```
431
+
432
+
433
+
434
+ ### Select New Columns
435
+
436
+ ```python
437
+ df = pf.select(
438
+ '^', # all original main columns
439
+ LoudNoises=pf.portfolio_code.str.upper(),
440
+ IntVal=7,
441
+ BoolVal=False
442
+ ).limit(10).go()
443
+ ```
444
+
445
+
446
+
447
+ ### Where Filtering
448
+
449
+ ```python
450
+ df = pf.select('*').where(pf.portfolio_scope == 'Finbourne-Examples').go()
451
+ ```
452
+
453
+
454
+
455
+ ### Order By
456
+
457
+ ```python
458
+ df = pf.select('*').where(
459
+ pf.portfolio_scope == 'Finbourne-Examples'
460
+ ).order_by(
461
+ pf.portfolio_code.ascending()
462
+ ).go()
463
+ ```
464
+
465
+
466
+
467
+ ### Case Statements and Group By
468
+
469
+ ```python
470
+ region = lm.when(pf.portfolio_code.str.contains('GLOBAL')).then('GLOBAL') \
471
+ .when(pf.portfolio_code.str.contains('US')).then('US') \
472
+ .otherwise('OTHER')
473
+
474
+ df = pf.select(Region=region).where(
475
+ pf.portfolio_scope == 'Finbourne-Examples'
476
+ ).group_by(
477
+ Region=region
478
+ ).aggregate(
479
+ PortfolioCount=pf.portfolio_code.count()
480
+ ).go()
481
+ ```
482
+
483
+
484
+
485
+ ### Having
486
+
487
+ ```python
488
+ df = pf.select(Region=region).where(
489
+ pf.portfolio_scope == 'Finbourne-Examples'
490
+ ).group_by(
491
+ Region=region
492
+ ).aggregate(
493
+ PortfolioCount=pf.portfolio_code.count()
494
+ ).having(
495
+ pf.portfolio_code.count() > 3
496
+ ).go()
497
+ ```
498
+
499
+
500
+
501
+ ### Joins
502
+
503
+ ```python
504
+ tv = pf.select('^').where(pf.portfolio_scope == 'Finbourne-Examples').to_table_var()
505
+ hld = atlas.lusid_portfolio_holding(as_at=dt.datetime(2022, 9, 1))
506
+
507
+ df = tv.left_join(hld, on=tv.portfolio_code == hld.portfolio_code).select('*').go()
508
+ ```
509
+
510
+
511
+
512
+ ### Union / Concat
513
+
514
+ ```python
515
+ df = lm.concat([query1, query2, query3]).go()
516
+ ```
517
+
518
+
519
+
520
+ ### Sampling
521
+
522
+ ```python
523
+ # Sample by fraction
524
+ df = pf.select('*').limit(200).sample(prob=0.5).go()
525
+
526
+ # Sample by count
527
+ df = pf.select('*').limit(200).sample(100).go()
528
+ ```
529
+
530
+
531
+
532
+ ### Create View
533
+
534
+ ```python
535
+ df = pf.select('*').setup_view('Lumipy.View.MyView').go()
536
+ ```
537
+
538
+
539
+
540
+ ### S3, Drive, and SaveAs Integration
541
+
542
+ ```python
543
+ # Load CSV from S3
544
+ csv = atlas.awss3_csv(file='bucket/path/file.csv')
545
+ df = csv.select('*').go()
546
+
547
+ # Save table variable to Drive
548
+ save = atlas.drive_saveas(tv, type='CSV', path='/my-path/', file_names='exported_file')
549
+ df = save.select('*').go()
550
+ ```
551
+
552
+
553
+
554
+ ### Slack Integration
555
+
556
+ ```python
557
+ # Send table var as CSV
558
+ slack = atlas.dev_slack_send(
559
+ tv,
560
+ attach_as='CSV',
561
+ channel='#channel-name',
562
+ text='Here is your result!'
563
+ )
564
+ df = slack.select('*').go()
565
+ ```
566
+
567
+
568
+
569
+ ### Built-in Analytics
570
+
571
+ ```python
572
+ df = ar.select(
573
+ ar.timestamp,
574
+ ar.duration,
575
+ Drawdown=lm.window().finance.drawdown(ar.duration)
576
+ ).go()
577
+ ```
578
+
579
+
580
+
581
+ ### Cumulative and Fractional Functions
582
+
583
+ ```python
584
+ df = ar.select(
585
+ CumeSum=ar.duration.cume.sum(),
586
+ FracDiff=ar.duration.frac_diff()
587
+ ).go()
588
+ ```
@@ -78,7 +78,7 @@ lumipy/provider/common.py,sha256=2NMoIDYEkO0km1TcRc_KWZ5NWpo02eBtByKB2_d-mpM,682
78
78
  lumipy/provider/context.py,sha256=VwsHZO46HP3G9BN4Eot_jQlbfETGKyNg2vG5wm1zL_4,5401
79
79
  lumipy/provider/factory.py,sha256=QFuSCT_byJwbFmHF669I2iz0vLAF0T9Or1ghIEUZ0ok,9257
80
80
  lumipy/provider/manager.py,sha256=A4bxCO__m5nc9GL8veOLtySbK1giMNDMml_r3B-q8y8,7218
81
- lumipy/provider/max_version.py,sha256=7mify-_MCrww_bOmuJtONL0KCg3x11CxDYxCNt0dKJM,28
81
+ lumipy/provider/max_version.py,sha256=SM-ytRJBHWLYhBmiQDYvCyoVZLdmGNzDETnyG3S6gFo,28
82
82
  lumipy/provider/metadata.py,sha256=WGfMv_tLn5W29-zMKipqBpueroe0eF-w9Hj_6QRdZAI,5483
83
83
  lumipy/provider/provider_sets.py,sha256=Z_VyiN2dBP1xuIdRiuGgyzLD7LfO4wxFvodprME2Uls,1478
84
84
  lumipy/provider/implementation/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
@@ -379,8 +379,8 @@ lumipy/test/unit/provider_tests/test_provider_factory.py,sha256=ICHlEiYS-GvKFoI5
379
379
  lumipy/test/unit/provider_tests/test_provider_manager.py,sha256=-TT-3ZGpDsFKMz4efWIy7TGAUVtZ2gTDa67DiorIioc,13456
380
380
  lumipy/test/unit/queryjob_tests/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
381
381
  lumipy/test/unit/queryjob_tests/test_queryjob.py,sha256=1UE4-VuIkAE6vo0vogq3p2iXtTukiAPxOt5Uankx7c4,1542
382
- dve_lumipy_testing-1.0.389.dist-info/METADATA,sha256=B5ZLfAXOAy6doNYMg4IL8lS_lyVt7DwCAshuHMZ8vl4,11856
383
- dve_lumipy_testing-1.0.389.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
384
- dve_lumipy_testing-1.0.389.dist-info/entry_points.txt,sha256=L7hRlqwmvzHMwaOQzygKLK-gx4k4e1q4Qz5m0DGihW8,46
385
- dve_lumipy_testing-1.0.389.dist-info/top_level.txt,sha256=DVww8LaQM3Xm0WOgo4JE0epePgCM1xGWWWxh7wuv-CY,7
386
- dve_lumipy_testing-1.0.389.dist-info/RECORD,,
382
+ dve_lumipy_testing-1.0.390.dist-info/METADATA,sha256=RPuLc5v3ZrLFV_z0CZGaXiMAP7F7fpsS7s8_LKaVu0k,14795
383
+ dve_lumipy_testing-1.0.390.dist-info/WHEEL,sha256=CmyFI0kx5cdEMTLiONQRbGQwjIoR1aIYB7eCAQ4KPJ0,91
384
+ dve_lumipy_testing-1.0.390.dist-info/entry_points.txt,sha256=L7hRlqwmvzHMwaOQzygKLK-gx4k4e1q4Qz5m0DGihW8,46
385
+ dve_lumipy_testing-1.0.390.dist-info/top_level.txt,sha256=DVww8LaQM3Xm0WOgo4JE0epePgCM1xGWWWxh7wuv-CY,7
386
+ dve_lumipy_testing-1.0.390.dist-info/RECORD,,
@@ -1 +1 @@
1
- max_version_str = '1.18.242'
1
+ max_version_str = '1.18.243'